Note that there are some explanatory texts on larger screens.

plurals
  1. POAdd markers after removing them from Google Maps
    primarykey
    data
    text
    <p>I want to add new markers after removing markers from Google maps. However, my code isn't doing what I expected. After the removal, no new marker could be added.</p> <p>Code <strong>snippet</strong>:</p> <pre><code>function codeAddress(coordinates) { console.log("called"); var myLatlng = new google.maps.LatLng(coordinates.lb,coordinates.mb); var marker = new google.maps.Marker({ map: map, position: myLatlng }); markersArray[markerid] = marker; markerid++; } function deleteOverlays() { if (markersArray) { for (i in markersArray) { markersArray[i].setMap(null); } } markersArray = {}; markerid = 0; } function go(){ var cMin = document.getElementById('costMin').value; var cMax = document.getElementById('costMax').value; var religion = document.getElementById('religion').value; // remove previous marker layer deleteOverlays(); console.log(coorList.length); for(var i = 0; i &lt; coorList.length; ++i){ //codeAddress(); if(religion != ""){ if(coorList[i].cost1 &gt;= cMin &amp;&amp; coorList[i].cost1 &lt;= cMax &amp;&amp; coorList[i].religion.toLowerCase() ==religion.toLowerCase()){ codeAddress(coorList[i]); } } else{ if(coorList[i].cost1 &gt;= cMin &amp;&amp; coorList[i].cost1 &lt;= cMax){ codeAddress(coorList[i]); } } } } &lt;input id="costMin" type="textbox" &gt; &lt;input id="costMax" type="textbox" &gt; &lt;input id="religion" type="textbox" &gt; &lt;input type="button" value="Go" onclick="go();"&gt; </code></pre> <p>When I placed a console.log("called") within the codeAddress() function, it seems like the function is not called at all after the click. If I get rid of deleteOverlays() from the go() function, the codeAddress will be called. Is there anything wrong with my code?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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