Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get latitude longitude from google map URL

I am building an android application which would store latitude and longitude information from google maps. The application receives the Send/Share intent from Google maps when user chooses location from map and extracts co-ordinates by un-shortening the goo.gl map link (e.g. http://goo.gl/maps/FcglP) embedded in intent. This task is easy if the location being shared from google maps is unknown or named "dropped pin". In that case the un-shortened URL looks like

http://maps.google.com/?q=17.50122123,74.12351323&.....

If the location is well known (http://goo.gl/maps/FcglP), e.g. some road, un-shortened URL looks like

http://maps.google.com/?q=Sutarwadi+Baner+Gaon+Rd%2C+Baner&ftid=0x3bc2becfa70b8b3f:0xd210c15f634bcec3&hl=en&gl=us

I have been searching for last three hours about how to extract the co-ordinates from this kind of URL but couldn't find any information. Is there any other method to extract co-ordinates from a given goo.gl map URL? Some already developed library or google API?

like image 914
enli Avatar asked Mar 08 '14 17:03

enli


People also ask

Can you get GPS coordinates from an address?

To get GPS coordinates using Google Maps is really easy. There are two ways you can go about it. Firstly, go to maps.google.com and type in the address or location you are interested in. Once it has loaded, you can just look in the address bar and you'll see the coordinates are contained within the URL itself.


1 Answers

2 steps:

  • Obtain a JSON with a long CID url by expanding the short URL: https://developers.google.com/url-shortener/v1/getting_started#expand
  • Retrieve information with the given URL: <longURL>&output=json
    Then, in the final JSON, you've got a viewport section with a center lat&lon location
like image 179
davelerat Avatar answered Sep 28 '22 17:09

davelerat