Google maps 谷歌地图上的边栏对地图做出反应
我有一个Google地图(API v3),上面填充了表示数据库数据的标记。我想添加一个边栏,检查哪些标记当前在地图上可见,并将它们添加到边栏,在地图移动时进行调整。这样做可能吗?我有一个程序,它加载一个包含地点标记的KML文件,将它们放在侧栏中,并在更改地图时使用Google Maps API使位置变暗/变亮。相关部分如下所示:Google maps 谷歌地图上的边栏对地图做出反应,google-maps,google-maps-api-3,google-maps-markers,Google Maps,Google Maps Api 3,Google Maps Markers,我有一个Google地图(API v3),上面填充了表示数据库数据的标记。我想添加一个边栏,检查哪些标记当前在地图上可见,并将它们添加到边栏,在地图移动时进行调整。这样做可能吗?我有一个程序,它加载一个包含地点标记的KML文件,将它们放在侧栏中,并在更改地图时使用Google Maps API使位置变暗/变亮。相关部分如下所示: google.maps.event.addListener(mapInstance, 'bounds_changed', function() { curren
google.maps.event.addListener(mapInstance, 'bounds_changed', function() {
currentBounds = mapInstance.getBounds();
for (i = 0; i < parser.docs[0].placemarks.length; i++) {
var myLi = $("#p" + i);
if (currentBounds.contains(parser.docs[0].placemarks[i].marker.getPosition())) {
myLi.css("color","#000000");
} else {
myLi.css("color","#CCCCCC");
}
}
});
在我的示例中,mapInstance是google.maps.Map的一个实例,currentPlacemark是您的一个google.maps.Marker对象的实例。这就是我要找的。谢谢
google.maps.event.addListener(mapInstance, 'bounds_changed', function() {
currentBounds = mapInstance.getBounds();
/*
Loop over Google map placemarks and check the placemark by doing:
if (currentBounds.contains(currentPlacemark.getPosition())) {
// Change CSS to make sidebar entry visible
} else {
// Change CSS to make sidebar entry invisible
}
*/
});