Note that there are some explanatory texts on larger screens.

plurals
  1. POremoving marker google map doesn't work API v3
    text
    copied!<p>i'm currently working on google map and i'm going through a problem i can't solve myself. i've been following some docs and answer on stackOverflow but i can't get it work properly ..</p> <p>i have one and only one marker on my map, all i want to do is removing it to put a new one each time the dragent event is firing ...</p> <p>When i'm debugging the code, it seems like my marker ain't deleted from the map or i don't .. i don't really understand the behavior ..</p> <p>So here is the code : </p> <p>my google map instance : </p> <pre><code> var map = new google.maps.Map(document.getElementById('map-canvas'), { zoom: levelZoom, center: new google.maps.LatLng(50.6548670, 3,1888100), }); </code></pre> <p>the manip : </p> <pre><code>var markerHome = null; function deleteCurrentMarkers(){ if (markerHome != null){ console.log("set markerHome to null"); markerHome.setMap(null); markerHome = null; } } function setRelayMap(dataSource, currentCoords, myFilterObject){ var i; var lt = currentCoords.lat; var lg = currentCoords.lng; deleteCurrentMarkers(); markerHome = new google.maps.Marker({position: new google.maps.LatLng(lt, lg), map: map, icon: "icoMaps/initPos.png"}); google.maps.event.addListener(map, 'dragend', function() { var centerObj = map.getCenter(); var newObj = {"lat": centerObj.lat(), "lng": centerObj.lng()}; console.log("in dragend"); getDataFromServer(newObj, myFilterObject); }); google.maps.event.addListener(map, 'zoom_changed', function() { levelZoom = map.getZoom(); }); } </code></pre> <p>can you see anything that could cause my problem ? </p> <p>thank you for helping :)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload