Convert String to latlng google maps -
i want convert string pattern "(53.324523, 43.252352)" latlng. found right function:
var input = latlngarray[i]; var latlngstr = input.split(",",2); var lat = parsefloat(latlngstr[0]); var lng = parsefloat(latlngstr[1]); latlngarray[i] = new google.maps.latlng(lat, lng);
the problem can't proper lat. when use alert display it says nan, while lng variable displays right value.
got it. thx help.
var input = latlngarray[i].substring(1, latlngarray[i].length-1); var latlngstr = input.split(",",2); var lat = parsefloat(latlngstr[0]); var lng = parsefloat(latlngstr[1]); latlngarray[i] = new google.maps.latlng(lat, lng);
quick fix after var input. looks '(' messing lat conversion:
input = input.replace('(','');
Comments
Post a Comment