customize the pin of map Android

2019-04-02 02:58发布

Hello I would like to add a dynamic display with a number in my point.

As in the picture, I already have the icons on the map.

Adding the numbers in point?

enter image description here

1条回答
Viruses.
2楼-- · 2019-04-02 03:35

You may use android-maps-utils to achieve such effect.

Simply create 9-patch out of your pin with empty rectangle above and make rectangle be the content.

Then use IconGenerator to create a Bitmap with your text and 9-patch like here:

IconGenerator factory = new IconGenerator(context);
factory.setBackground(your9PatchDrawable);
factory.setContentView(textViewWithWith3Point600String);
Bitmap icon = factory.makeIcon();

Then use this Bitmap to set Markers icon:

map.addMarker(new MarkerOptions().icon(BitmapDescriptorFactory.fromBitmap(icon)...);
查看更多
登录 后发表回答