Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The basic problem is that if you want this to work you've got to make up your mind about what the <code>markersTest</code> object is supposed to hold. You can't seem to decide whether the elements in <code>markersTest</code> should be markers or should be arrays that tell you about where markers are going to be placed.</p> <p>Quoting from your javascript file, here are the two functions that get executed when you check/clear the checkbox:</p> <pre><code>15 function addTestMarkers(){ 16 for(var i in markersTest) { 17 var location = new google.maps.LatLng(markersTest[i][1], markersTest[i][2]); 18 marker = new google.maps.Marker({ 19 position: location, 20 map: map 21 }); 22 } 23 } 24 25 // Removes the overlays from the map, but keeps them in the array 26 function clearOverlays() { 27 if (markersTest) { 28 for (i in markersTest) { 29 markersTest[i].setMap(null); 30 } 31 } 32 } </code></pre> <p>For <code>addTestMarkers</code> to work, the <code>markersTest</code> object needs to hold descriptions of where the markers should go. For <code>clearOverlays</code> to work, the <code>markersTest</code> object needs to hold markers.</p> <p>Here's my suggestion: change the <code>markersTest</code> object as you set it up at the top of the javascript file to <code>markerDestinations</code>, and at the top of the javascript file have <code>markersTest</code> initialized with:</p> <pre><code>markersTest = {}; </code></pre> <p>Then, modify <code>addTestMarkers</code> to:</p> <pre><code>function addTestMarkers() { for(var i in markerDestinations) { var location = new google.maps.LatLng(markersDestinations[i][1], markersDestinations[i][2]); markersTest[i] = new google.maps.Marker({ position: location, map: map }); } } </code></pre> <p>The key change is to make <code>addTestMarkers</code> actually put the markers into the <code>markersTest</code> object.</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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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