Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Separate LatLng into String Google Maps

Tags:

google-maps

I got my latlng from my draggable marker.. How can I separate the getLatLng value into lat and longitude? Remember, not String to LatLng. Thanks

like image 980
Brandon Young Avatar asked Jan 19 '26 07:01

Brandon Young


2 Answers

To clarify you've got a LatLng value and you want the separate values for each?

var myLatLng = myMarker.getPosition();
var lat = myLatLng.lat();
var lng = myLatLng.lng();

You should look at the docs for LatLng in the reference

like image 81
tkone Avatar answered Jan 22 '26 10:01

tkone


Instead, you can try to use geocoder to separate your latlng

geocoder.getLatLng(yourlatlng, function(point){
    if(!point){
        alert(address + " not found");
    }else{
        lat = point.y;
        longi = point.x;
    }                                                   
});
like image 21
Bennett Young Avatar answered Jan 22 '26 11:01

Bennett Young



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!