在地图上显示多个标记标题

时间:2013-05-19 20:42:59

标签: android google-maps google-maps-api-2

我在地图上成功添加了多个标记。使用showInfoWindow仅显示最后添加的标记的标题。那么有没有办法一次显示所有标记的标题? 谢谢:)

3 个答案:

答案 0 :(得分:2)

无法直接显示所有信息窗口。

我建议使用自定义标记图标和Canvas在标记上方绘制文字,这看起来像信息窗口。

答案 1 :(得分:1)

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

答案 2 :(得分:0)

AFAIK这是Google Map API V2的功能,在任何给定时间只显示一个InfoWindow

相关问题