在Android Google Maps API v2中有多个带文本的标记符。

13

我的目标是在Android Google Maps API v2地图上放置多个带文本标记。信息窗口的方法(showInfoWindow())不适用,因为一次只能显示一个信息窗口。例如,我要实现类似于这样的效果:enter image description here

正如你所看到的,每个标记都有自己的数据(对于此示例是数字)始终显示。

我如何使用Android Google Maps API v2实现这一点?

3个回答

10

3

试着用这个

LinearLayout tv = (LinearLayout) this.getLayoutInflater().inflate(R.layout.marker_dialog, null, false);

tv.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
        View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
tv.layout(0, 0, tv.getMeasuredWidth(), tv.getMeasuredHeight());

tv.setDrawingCacheEnabled(true);
tv.buildDrawingCache();
Bitmap bm = tv.getDrawingCache();

LatLng latLng = new LatLng(latitudemy, longitudemy);


BitmapDescriptor icon = BitmapDescriptorFactory.fromBitmap(bm);
BitmapDescriptorFactory.fromResource(R.mipmap.ic_launcher);
map.addMarker(new MarkerOptions().position(new LatLng(latitudemy, longitudemy)).title("origin").snippet("Srivastava").icon(icon));
// Showing the current location in Google Map
map.addMarker(new MarkerOptions().position(new LatLng(latitude, longitude)).title("destination").snippet("Srivastava").icon(icon));

定义您的自定义布局XML,其中包括ImageView和TextView XML。 - Shikhar

0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接