DEV Community 👩‍💻👨‍💻

Matt Kenefick
Matt Kenefick

Posted on

Snippet: Grab lat/lon from Google Maps URL

I needed to grab several latitude/longitude coordinates recently from Google Maps without using an API. This line can be executed in the console to quickly produce the coordinates derived from the URL.

[_, lat, lng] = location.href.match(/@([-0-9]+\.[0-9]+),([-0-9]+\.[0-9]+),/); console.log(lat, lng);
// 39.9532614 -75.1539449
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Let's Get Hacking

Join the DEV x Linode Hackathon 2022 and use your ingenuity and creativity to build using Linode.

→ Join the Hackathon <-