How to size custom marker icons for Android Google Maps v2?

16,107

All assets must follow the usual scaling: 0.75x (ldpi), 1x, 1.5x, 2x, 3x (xxhdpi). They also suggest you should not care too much about strange densities like tvdpi or xxxhdpi and create only for 3 major buckets: mdpi, hdpi and xhdpi.

Assuming all bugs are fixed and clickable area for Marker is the same as drawable's area, I suggest creating icons big enough, so they are easily pressed, e.g.: 48dp. Such an image would have only center (16x16dp or so) filled with opaque pixels.

If you want to have the same effect as in Google Maps app with info window appearing from the center of such image, add another Marker with 0x0px icon and force showing info window on that invisible Marker.

Share:
16,107
JJD
Author by

JJD

Android, Kotlin, Java, Git, Python, Ruby, Ruby on Rails, JavaScript, MacOS, Ubuntu #SOreadytohelp http://stackoverflow.com/10m

Updated on June 13, 2022

Comments

  • JJD
    JJD almost 2 years

    I want to design custom icons for an Android app using Google Maps v2. I know there are a bunch of design resources which describe how one would create icons for various devices and densities. Here are some information sources:

    The Android SDK contains a sample project called maps. Though it does not contain marker icons in the resource folder.

    Sample project in: $ANDROID_HOME/extras/google/google_play_services/samples/maps/

    But how would you create marker icons for Google Maps similar to those seen on the following screenshot:

    Google Maps Screenshot

    Is there any style guide telling about icon sizes for densities such as ldpi, mdpi, hdpi, xhdpi, xxhdpi or tvdpi?