I have the map center, and comes as a Floating Point number.
How can I get it as 2 separated variables like this:
var lat = ...
var lng = ...
I have the float:
var NewMapCenter = map.getCenter();
I tried to pass the float toWords(x)
but didn't work
I tried to subtract the (,)
and split
it, but didn't work
var latlngStr = (StrNewMapCenter.substr(1, (StrNewMapCenter.length-1))).split(",",2);
var NewMapCenter = parseFloat(latlngStr[0]);
I tried, this but comes as an event, but I need it without needing to click.
google.maps.event.addListener(map, 'click', function(event) {
var myLatLng = event.latlng;
var Newlat = position.coords.latitude;
var Newlng = position.coords.longitude;
}
Thanks Sebastian
var NewMapCenter = map.getCenter();
will give you LatLng object, so you can call
var latitude = NewMapCenter.lat();
var longitude = NewMapCenter.lng();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With