Google Maps API: Change default marker image

1
Hello, I'm testing the Google Maps API in my android app, and I learned that you can change the default bookmark icon, but when I added my PNG image to the project, the icon got an absurdly large size. How can I do this not to tell you that my image has a resolution of 512x512?

    
asked by anonymous 06.05.2017 / 04:39

1 answer

2

You need to have this image in several dimensions, so the android itself will be charged to raise the best quality depending on the device. Below the required icon sizes:

MDPI - 48px

HDPI - 72px

XHDPI - 96px

XXHDPI - 144px

XXXHDPI - 192px

Then set the location of the image in icon.

private static final LatLng MELBOURNE = new LatLng(-37.813, 144.962);
  private Marker melbourne = mMap.addMarker(new MarkerOptions()
                            .position(MELBOURNE)
                            .title("Melbourne")
                            .snippet("Population: 4,137,400")
                            .icon(BitmapDescriptorFactory.fromResource(R.drawable.arrow)));
    
06.05.2017 / 05:15