私は一生、なぜ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;
}
});