Faloude Faloude - 1 year ago 89
Javascript Question

Google maps API: get lat / long separately

After sending a

request and receiving a response with status OK, you can use
to retrieve both latitude and longitude.

But how do you get the lat / long separately? I can't find the right call in the Google maps API reference

Answer Source

That location field is an object of type LatLng. To get the latitude, call it's lat() method. To get the longitude, call it's lng() method.

For example:

var latitude = results[0].geometry.location.lat();
var longitude = results[0].geometry.location.lng();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download