ionic : - convert string to latitude, longitude append more digit at end?

Viewed 451

i want to convertstring to latlng suppose string is 23.097278,72.446139 i want to convert it to latlng, when i split strings i get result as i want but when i converting to latlng it appends some digits at end of co ordinate for example centerPoint : (23.081295, 72.49794399999996), what i have done so far is below plz help me to solve it.

temp="23.097278,72.446139";
let temp1 = temp.split(',');

let coordinatesLat = temp1[0];
let coordinatesLong = temp1[1];

console.log("temp1 : " +coordinatesLong);

let centerPoint = new google.maps.LatLng(coordinatesLat, coordinatesLong);
console.log("centerPoint : " +centerPoint);

output in log

temp1 :  72.497944
centerPoint : (23.081295, 72.49794399999996)
1 Answers

Try to convert it to float

var latDouble = parseFloat(lat); var longDouble = parseFloat(long);

Related