我是googlemaps的新手。我已经阅读了Overlapping Marker Spiderfier文档,但我仍然对如何在地图中实现它感到困惑。
这是我的尝试:
function initialize() {
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 7,
center: new google.maps.LatLng(40.0000, 48.0000),
mapTypeId: google.maps.MapTypeId.ROADMAP,
disableDefaultUI: true,
zoomControl: true
});
var locations = [[40.0000, 48.0000], [40.0000, 48.0000], [40.0000, 48.0000]];
var marker, i;
for (i = 0; i < locations.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][0], locations[i][1]),
map: map
});
}
}
google.maps.event.addDomListener(window, 'load', initialize);
您可以在jsfiddle。
中找到此代码答案 0 :(得分:2)
以下是您的代码更新...
function initialize() {
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 7,
center: new google.maps.LatLng(40.0000, 48.0000),
mapTypeId: google.maps.MapTypeId.ROADMAP,
disableDefaultUI: true,
zoomControl: true
});
var locations =[ [40.0000, 48.0000],[40.0000, 48.0000],[40.0000, 48.0000]];
oms = new OverlappingMarkerSpiderfier(map,
{markersWontMove: true, markersWontHide: true, keepSpiderfied: true, circleSpiralSwitchover: 40 });
var marker, i;
for (i = 0; i < locations.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][0], locations[i][1]),
map: map
});
oms.addMarker(marker);
}
}
google.maps.event.addDomListener(window, 'load', initialize);