I have added a few markers on my map but when I run my app, I see the markers to be very small. I have created a custom icon with the mdpi
, hdpi
, xhdpi
and xxhdpi
dimensions but I still see them small.
This is how add the markers to the map:
LatLng latLng = new LatLng(lat, lng);
MarkerOptions markerOptions = new MarkerOptions().position(latLng).title("My Marker");
markerOptions.icon(BitmapDescriptorFactory.fromResource(R.drawable.my_pin));
Marker marker = googleMap.addMarker(markerOptions);
And this is how my map looks like:
And this is what I want to achieve:
How to change marker size a little bit to be more visible?
I use Gimp and the extension Script Fu Save Android icons to create all my mipmap or icons in my apps.
After install the script, you get this menu in the menu bar:
After click on "Save Android Icons...", you'll get this window:
The extension exports all icons according with Android Icon's Sizes:
After generate all icons, just move them to your project folder
try this if hope it will help you if not tell me to delete the answer ...!
public Bitmap resizeBitmap(String drawableName,int width, int height){
Bitmap imageBitmap = BitmapFactory.decodeResource(getResources(),getResources().getIdentifier(drawableName, "drawable", getPackageName()));
return Bitmap.createScaledBitmap(imageBitmap, width, height, false);
}
then
googleMap.addMarker(new MarkerOptions()
.title("New Marker").position(yourGivenPosition).icon(BitmapDescriptorFactory.fromBitmap(resizeBitmap("your drawable name",72,64))));
First, choose the larger image and make an image asset for all sizes. For that Right click on the drawable folder and select new -> Image Asset -> select appropriate options and select image. finish and it will automatically create all size of images. Use this image as the marker.
So, now at the end, you have the only solution is that use large size image into the marker.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.