jquery - How to loop through Google Map coordinates? -


I am trying to loop through this array of GPS coordinates which puts pins on Google Maps.

This is my code:

The problem is at line 27-36 .

If I change it to the following, then it will place 1 pin at that exact location, but I want it to loop through the array so that I can add several pins:

  // var marker = []; (Var i = 0; i & lt; 1; i ++) for {var point = new GLTLNG (39.72 9 308, -121.854087); Marker = new GM marker (point); Map.addOverlay (marker); Marker [i] = marker; }  

Does anyone know why this version is breaking up?

  var marker = [(39.72 9 308, -121.854087), (39.0, -121.0)]; (Var i = 0; i & lt; marker langati; i ++) {var point = new gltlng (marker [i]); Marker = new GM marker (point); Map.addOverlay (marker); Marker [i] = marker; }   

Firstly the following code is incorrect javascript.

  Var marker = [(39.72 9 308, -121.854087), (39.0, -121.0)];  

You probably mean:

  var marker = [[39.72 9 308, -121.854087], [3 9.0, -121.0]];  

Second, according to the document, not an array.

Try it instead:

  var point = new GLatLng (marker [I] [0], marker [i] [1]);  

edit

I corrected your code and hosted it on the JS bin. It seems that after fixing the above issues, we have to work:


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -