1

我一生都无法弄清楚为什么setMap(null)不起作用。我真的很不高兴有多少关于使用 bindTo 添加覆盖的文档,但没有一个关于如何删除它的词。我究竟做错了什么?

我正在.radius_type点击创建圆圈。然后,当我将下拉菜单切换为不同的形状时,它不会删除圆圈。

我这样称呼地图:

var map = new google.maps.Map(document.getElementById('map'), {...}

// this toggles the shapes, but I can't get it to remove the circle for the marker
$('.radius_type.selectee').click(function(){
      var shape = $(this).find('span').html();
      var opts= {...};

    switch(shape){
        case 'circle':  // Here is the added circle to the second marker.
            var circle = new google.maps.Circle(opts);
            circle.setOptions({radius:17063,map:map});
            circle.bindTo('center',markers[1],'position');

            // It binds, now how to remove it?

            break;

        case 'square':
            //tried - circle.setMap(null);
            //tried - map.setMap(null);
            //tried - google.map.event.setMap(null);
            //tried - every web page on the topic.
            //
            // I don't understand how to unbind the circle from the marker.
            var rect = new google.maps.rect(opts);

            break;

        case 'draw':
            draw.setDrawingMode(google.maps.drawing.OverlayType.POLYGON);
            break;
    }
});
4

2 回答 2

2

用于 $('element').on('change',function())删除圆圈

于 2012-10-16T15:47:09.013 回答
0

您可以尝试以下代码片段:

circle.setCenter(null); 
circle.unbind('center');
于 2016-04-11T12:01:53.453 回答