Sachin Gedam
Sachin Gedam

Reputation: 13

How to get current location latitude, longitude and zip code in one call

We are developing a google map based application to load custom markers on google map. As part of enhancement, we are implementing "Use my current location feature". For this we are using geolocation and position object to identify current location latitude and longitude and its working as expected. Now as a requirement, on screen we have to show current location's zip code also. For the same we are giving another call to get Zip Code based on latitude and longitude.

So my question is, is there any API method using which we can get latitude, longitude and current address details including zip code in one call itself?

This is DNN based web application running on IIS server

navigator.geolocation.getCurrentPosition(success, error); //Code to get latitude and longitude var lat = position.coords.latitude.toString(); var longt = position.coords.longitude.toString();

======= $.ajax({ url: 'https://maps.googleapis.com/maps/api/geocode/json?latlng=' + lat + ',' + longt + '&key=keyvalue', type: "GET", dataType: 'json', async: false, success: function (data) { var results = data.results; var postalCode = getPostalCode(results); currentZipLocation = postalCode; } });

Need help to find a method to get current location latitude, longitude and zip code in one method call

Upvotes: 0

Views: 961

Answers (1)

Angelica
Angelica

Reputation: 717

This feature is not currently available in the Google Maps Platform APIs. Once you got the coordinates from HTML5 Geolocation, you'll need to make a reverse geocoding request to get additional details for that coordinate.

If you are interested to have this feature, you can file this as feature request in Google's Public Issue Tracker: https://developers.google.com/maps/support/#issue_tracker

Issue Tracker is a tool used internally at Google to track bugs and feature requests during product development.

Upvotes: 0

Related Questions