DEV Community

Matt Kenefick
Matt Kenefick

Posted on

1

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)

The Most Contextual AI Development Assistant

Pieces.app image

Our centralized storage agent works on-device, unifying various developer tools to proactively capture and enrich useful materials, streamline collaboration, and solve complex problems through a contextual understanding of your unique workflow.

👥 Ideal for solo developers, teams, and cross-company projects

Learn more