2

I have a set of lat long points which i receive from the database for a specific event. I receive the co-ordinates in the below form:

18.9362430987942 72.8269794968548
19.0200931221883 72.8436302614116
19.0547926 72.8406549

I need to store this co-ordinates in the array and later push this array in waypoints to draw the route. But when i try to put the values in

var geoLatLong=new google.maps.LatLng(linkData);

After putting an alert for geoLatLong....I get (Nan,NaN)..Please Help.

Please find the code that i have tried for the co-ordinates i receieve from the database.

load : function(response) 
    {
        for(var i=0;i<response.length;i++)
        {
            if(response[i].linkData!='undefined')
            {
            link=response[i].linkData;
            alert(link);
            var linkValue=link.split(" ");
            var linkData=linkValue[0]+","+linkValue[1];  
            alert("linkdata"+linkData);
            var geoLatLong=new google.maps.LatLng(linkData);
            alert(geoLatLong);
            geoLatLongArray.push(geoLatLong);
            alert(geoLatLongArray);
            }
        }

    }
sTg
  • 4,313
  • 16
  • 68
  • 115

1 Answers1

1

You can't pass the lat/lon as string dataType to google.maps.LatLng. So you need to convert the dataType to float using parseFloat().

So change the code like

var lat = parseFloat(linkValue[0]);  //convert string to float
var lon = parseFloat(linkValue[1]);  //convert string to float
var geoLatLong=new google.maps.LatLng(lat, lon); 

Now push it to the geoLatLongArray.

Praveen
  • 55,303
  • 33
  • 133
  • 164