gpt4 book ai didi

javascript - 如何在 Googlemaps api v3 中添加 Spiderfier?

转载 作者:行者123 更新时间:2023-11-30 17:56:58 24 4
gpt4 key购买 nike

我是 googlemaps 的新手。我已经阅读了 Overlapping Marker Spiderfier文档,但我仍然对如何将其实现到我的 map 中感到困惑。

这是我的尝试:

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 中找到此代码.

最佳答案

这是您的代码更新...

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);

关于javascript - 如何在 Googlemaps api v3 中添加 Spiderfier?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17920806/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com