0
votes

I'm trying to display a tractor's route in google maps and having the following problem (I like to call it "The Guinea Problem":

http://i901.photobucket.com/albums/ac215/MigerusanTTE/coordserrorfinal.jpg

In the pic you can see that the starting point of my polyline starts from lat 0, long 0. I dont know why this is happening because on my while loop I put an alert when it starts and the latlng values are correct when it begins...

Here you have a portion of the code for markers and polylines:

    //If i==0 (my FOR variable for looping), coords_prev=coords.


    //alert(coords); //alert I put to see what was happening D:
    var marker    =  new google.maps.Marker(
    {
      position: coords,
      map: map,
      icon:direccion_ico
    });
    }

   //contructing the line

    var line = [coords_prev, coords];

    var polyline = new google.maps.Polyline({
      path: line,
      strokeColor: color,
      strokeOpacity: 0.6,
      strokeWeight: 3
    });


    linesArray.push(polyline);
    polyline.setMap(map);
    coords_prev = coords;  //I equal these for the next loop

Tell me what you think...and If I forgot to mention something important too.

1

1 Answers

0
votes

On the line

   var line = [coords_prev, coords];

This is fine for the second point, but for the very first point, you won't have anything in coords_prev. Thus, for the very first segment, it will start at 0,0 and go to coords.