自定义地图Android的图钉 [英] customize the pin of map Android

查看:207
本文介绍了自定义地图Android的图钉的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我想添加一个带有数字的动态显示.

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.

将数字相加吗?

推荐答案

您可以使用 android- maps-utils 来达到这种效果.

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

只需在您的图钉上创建9-patch,上面有一个空矩形,然后使矩形成为内容.

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

然后使用IconGenerator使用文本和9补丁程序创建Bitmap,如下所示:

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

然后使用此Bitmap设置Marker的图标:

Then use this Bitmap to set Markers icon:

map.addMarker(new MarkerOptions().icon(BitmapDescriptorFactory.fromBitmap(icon)...);

这篇关于自定义地图Android的图钉的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆