1

Is there any way to retrieve latitude and longitude using this type of google map link?

https://goo.gl/maps/7jNqZtPa5Cjf333k7

In this URL 7jNqZtPa5Cjf333k7 is not referring to place id right? I'm really struggling to extract latitude and longitude using this type of link. Really appreciate your help if somebody can give me an idea. Or else retrieving the place id also can be a help for me so I can use the link like this to retrieve the response in a JSON format.

https://maps.googleapis.com/maps/api/geocode/json?place_id=7jNqZtPa5Cjf333k7&key=YOUR_API_KEY
Mishen Thakshana
  • 1,050
  • 1
  • 14
  • 38
  • Related question: [Google Maps URL expanding - Missing Lat Lon](https://stackoverflow.com/questions/36116174/google-maps-url-expanding-missing-lat-lon) – geocodezip Jul 03 '22 at 18:27
  • In your given [URL](https://www.google.com/maps/place/Kandanawatta,+Sri+Lanka/@6.8391224,80.0308563,17z/data=!3m1!4b1!4m5!3m4!1s0x3ae2523ff96d8abf:0x4a6d8d4b6), the location (latitude, longitude) is the one after the `@` character, which is `6.8391224,80.0308563`. Next, you cannot get a place ID in Google Maps web app. This is because Google Maps web app (maps.google.com) and Google Maps APIs are two different products. – Beth Jul 06 '22 at 07:04

1 Answers1

2

There is no way to decode it without following the redirection.

That link redirects to: https://www.google.com/maps/place/Kandanawatta,+Sri+Lanka/@6.8391224,80.0308563,17z/data=!3m1!4b1!4m5!3m4!1s0x3ae2523ff96d8abf:0x4a6d8d4b68830686!8m2!3d6.8391224!4d80.0308563?hl=en-US

To decode the information in that link, see related questions:

The latitude and longitude for the location in that link is:

8m2!3d6.8391224!4d80.0308563
6.8391224,80.0308563

For Kandanawatta, Sri Lanka, the Google Places API returns:

Kandanawatta, Sri Lanka (6.837274799999999, 80.0325338)

Which is not quite the same, hard to say why without knowing where you got the "shortened" URL from.

The coordinates at the beginning (following the @):

6.8391224,80.0308563,17z

Are the center and zoom level of the map, not necessarily the location in the original request

geocodezip
  • 158,664
  • 13
  • 220
  • 245