小编Tim*_*411的帖子

Google Maps API v3隐藏并显示绑定到标记的圆圈

我已成功使用google map api v3将圆圈绑定到我的标记.我知道这一点,因为如果我将标记拖动,圆圈也会移动.

如果单击标记,如何引用圆圈.如果不可见,我需要显示圆圈,反之亦然.

以下是创建标记和圆的代码

var markerOptions = {
title: title,
icon: markerImage,
shadow: markerShadow,
position: latlng,
map: map
}
var marker = new google.maps.Marker(markerOptions);   
// Add a Circle overlay to the map.
var circle = new google.maps.Circle({
map: map,
radius: 50*1609.34,// 50 MI
visible: false
});
//circle.bindTo('map', marker);
circle.bindTo('center', marker, 'position');
Run Code Online (Sandbox Code Playgroud)

我在stackoverflow上找到了一个答案,这让我觉得我需要做一个rem'd out map binding以及中心绑定,但这不起作用.

这是我的标记点击事件.

google.maps.event.addListener(marker, "click", function() {
var infowindowOptions = {
content: html
 }
var infowindow = new google.maps.InfoWindow(infowindowOptions);
cm_setInfowindow(infowindow);
infowindow.open(map, marker);
marker.setIcon(markerImageOut);
marker.circle({visible: true}); …
Run Code Online (Sandbox Code Playgroud)

javascript google-maps google-maps-api-3 google-maps-markers

3
推荐指数
1
解决办法
9454
查看次数