customize the pin of map Android

萝らか妹 提交于 2019-12-05 08:24:38

问题


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?


回答1:


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)...);


来源:https://stackoverflow.com/questions/18343785/customize-the-pin-of-map-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!