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 に答える