我想跟踪地图上的标记。点击特定标记时,我需要显示与该标记相关的信息。Android中的HashMap <String,Marker>问题
我使用一个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))));
}
}
当我点击了特定的标记,我需要的是,物业ID值点击标记,
public boolean onMarkerClick(Marker marker) {
marker.showInfoWindow();
tvPropertyID.setText("" + visibleMarkers.get(marker));
return true;
}
但我正在逐渐“visibleMarkers.get(标志)”无效。 infowindow上显示一个空字符串。 我在哪里做错了?请纠正我。请为我提供一个有用的链接。
在此先感谢!
'visibleMarkers.get(marker)' - 不是你的钥匙串吗?它不应该更像'visibleMarkers.get(PropertyID)'吗?假设PropertyID是一个字符串 –