【发布时间】:2013-06-14 08:51:40
【问题描述】:
我想跟踪地图上的标记。单击特定标记时,我需要显示有关该标记的信息。
我正在使用一个 HashMap 变量来跟踪添加到地图上的标记。
for (int i = 0; i <= PropertyStub.size() - 1; i++) {
final LatLng MeanLatLng = new LatLng(PropertyStub.get(i).Latitude,
PropertyStub.get(i).Longitude);
if (!visibleMarkers.containsKey(PropertyStub.get(i).PropertyID)) {
visibleMarkers
.put(PropertyStub.get(i).PropertyID,
this.map.addMarker(new MarkerOptions()
.position(MeanLatLng)
.title("Property")
.icon(BitmapDescriptorFactory
.fromResource(R.drawable.pink_outside_marker))));
}
}
当我单击特定标记时,我需要该单击标记的 PropertyID 值,
public boolean onMarkerClick(Marker marker) {
marker.showInfoWindow();
tvPropertyID.setText("" + visibleMarkers.get(marker));
return true;
}
但我得到“visibleMarkers.get(marker)”为空。信息窗口上显示一个空字符串。 我在哪里做错了?请纠正我。请给我一个有用的链接。
提前致谢!!
【问题讨论】:
-
visibleMarkers.get(marker)- 你的钥匙不是字符串吗?不应该更像visibleMarkers.get(PropertyID)吗?假设 PropertyID 是一个字符串
标签: android map hashmap marker infowindow