最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Extracting Coordinates from a link Google Map API - Stack Overflow

programmeradmin7浏览0评论

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

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.

;key=YOUR_API_KEY

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./maps/api/geocode/json?place_id=7jNqZtPa5Cjf333k7&key=YOUR_API_KEY
Share Improve this question asked Jul 3, 2022 at 18:07 Mishen ThakshanaMishen Thakshana 1,5845 gold badges24 silver badges62 bronze badges 2
  • Related question: Google Maps URL expanding - Missing Lat Lon – geocodezip Commented Jul 3, 2022 at 18:27
  • In your given URL, 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.) and Google Maps APIs are two different products. – Beth Commented Jul 6, 2022 at 7:04
Add a ment  | 

1 Answer 1

Reset to default 4

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

That link redirects to: https://www.google./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:

  • Decoding the Google Maps embedded parameters
  • how do i decode/encode the url parameters for the new google maps?
  • Embed URL to coordinates, kml or geojson

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

发布评论

评论列表(0)

  1. 暂无评论