我正在使用此代码在谷歌地图上绘制标记(隐藏在屏幕上不可见的标记)
for (MyMapPointModel item : items) {
// If the item is within the the bounds of the screen
if (bounds.contains(item.getLatLng())) {
// If the item isn't already being displayed
if (!visibleMarkers.containsKey(item.getId())) {
// Add the Marker to the Map and keep track of it with
// the HashMap
// getMarkerForItem just returns a MarkerOptions object
customMarker = getMap().addMarker(getMarkerForItem(item));
visibleMarkers.put(item.getId(), customMarker);
drawMarker(item.getLatLng(), item.getThumbUri(), item.getId());
}
} else { // If the marker is off screen
// If the course was previously on screen
if (visibleMarkers.containsKey(item.getId())) {
// 1. Remove the Marker from the GoogleMap
visibleMarkers.get(item.getId()).remove();
// 2. Remove the reference to the Marker from the
// HashMap
visibleMarkers.remove(item.getId());
}
}
}
我在哈希图中存储带有项目 id 的标记我想调用一个带有录音标记详细信息的活动,我无法从 onMarkerClick 侦听器获取项目 id(他只提供标记对象)。我错过了什么,如果我是什么?有没有人有更好的主意?