Skip to content Skip to sidebar Skip to footer

How Can I Remove Marker With Bonded Circle From The Map?

I did bind the circle with marker to make view like: But when I try to remove marker from the map, the circle still exists. Hmm, How can I remove marker with circle? Relevant co

Solution 1:

If you want to remove the Circle when you remove the marker, you need to remove it also.

 cityCircle.setMap(null);

You will need to keep a reference to the circle to do that (not tested):

function removeMarker(){
  if(selectedMarker)
    selectedMarker.setMap(null); 
    selectedMarker._mycityCircle.unbindAll();
    selectedMarker._mycityCircle.setMap(null);  
}

....

function createCircle()
{
  var circle = {
    strokeColor: "#006DFC",
    strokeOpacity: 0.4,
    strokeWeight: 2,
    fillColor: "#006DFC",
    fillOpacity: 0.15,
    map: mapA,
    center: selectedMarker.getPosition(),
    radius: 50// in meters
  };

  cityCircle.bindTo('center', selectedMarker, 'position');
  selectedMarker._mycityCircle = cityCircle;
}

Post a Comment for "How Can I Remove Marker With Bonded Circle From The Map?"