0
我有以下javascript在使用googlemap的Web應用程序中圍繞標記繪製圓圈。位置細節來自數據庫,並且對於每個位置,我都會創建一個帶有固定半徑圓圈的標記以開始。出於某種原因,該圈子沒有出現。任何建議要解決?使用Javascript在Google Map中圍繞標記繪製圓圈
var marker, i, center;
for (i = 0; i < locations.length; i++) {
center = new google.maps.LatLng(locations[i][1], locations[i][2]);
marker = new google.maps.Marker({
position: center,
map: map
});
var circle = new google.maps.Circle({
center: center,
map:map,
radus:160930,
strokeColor: "red",
strokeOpacity:0.8,
strokeWeight: 2,
fillColor: "red"
});
circle.bindTo('center',marker,'position');
google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infowindow.setContent(locations[i][0]);
infowindow.open(map, marker);
};
})(marker, i));
}
你不需要線circle.bindTo(),只是創建你的中心圓與你的標記的位置相同。您還可以查看https://developers.google.com/maps/articles/mvcfun,瞭解標記和圈子之間更復雜的交互 – AlexB