Nikhil Gangurde Nikhil Gangurde - 4 months ago 8
AngularJS Question

i want to split (10.12345, 70.12345)

i tried to split that but i get this output on console

lattitude :-- (10.12345

longitude :-- 70.12345)

i want this as output --

lattitude :-- 10.12345

longitude :-- 70.12345

here is my piece of code ==

var latlngStr = input.toString().split(',',2);

var latlng = {lat: parseFloat(latlngStr[0]), lng: parseFloat(latlngStr[1])};

console.log("lattitude :-- "+latlngStr[0]);
console.log("longitude :-- "+latlngStr[1]);

console.log("actualdata : "+latlngStr);
console.log(+status);
$scope.geocoder.geocode({'location': latlng}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK)
{
if (results[1])
{
map.setZoom(11);
infowindow.setContent(results[1].formatted_address);
infowindow.open(map, $scope.pin);
} else
{
window.alert('No results found');
}
} else
{
//window.alert('Geocoder failed due to: ' +status);
}
});
}

Answer

input.toString().replace('(','').replace(')','').split(',',2);

Comments