esm7 / obsidian-map-view

Interactive map view for Obsidian.md
MIT License
621 stars 33 forks source link

FR: Use Google Maps link directly as input data #196

Open ryanwwest opened 1 year ago

ryanwwest commented 1 year ago

I'm rather new to this plugin, so pardon if this idea has already been considered. I appreciate the comments and logic on how Google Maps can be used to quickly get coordinates to put into the [](geo:) links. However, I have a lot of pre-created location notes that just use Google maps links directly within for example [Statue of Liberty](https://www.google.com/maps/place/Statue+of+Liberty/@40.6892534,-74.0470753,17z/data=!3m1!4b1!4m6!3m5!1s0x89c25090129c363d:0x40c6a5770d25022b!8m2!3d40.6892494!4d-74.0445004!16zL20vMDcycDg?entry=ttu). That way, I can click this link to open the place directly inside Google Maps.

I'd love to be able to use the above directly in obsidian-map-view as well (both a bare link and one in []()). From what I've seen, Google Maps URLs always seem to have the same coordinates needed for regular geo: links, and by supporting this, it could also include the context of pulling up the location on Google Maps for directions, notes there, sharing, etc. This would make it a lot easier to just paste in a link of a restaurant I ate at and want to remember (no need to make a geo: link or even think about it), and also be able to pull up future restaurant reviews on Google while still having the map context in Obsidian.

esm7 commented 1 year ago

I really like this idea, but are you sure that Google links always have the coordinates with them? In my experience links from Google Maps (and specifically Google Places) have multiple forms, depending on what link you copy or share, and whether you do it from mobile or desktop. And it might be very confusing to users if they can't know in advance when they paste a Google Maps link if it's going to be registered as a location to Map View or not.

ryanwwest commented 1 year ago

Did a bit of experimenting just now. You're right that this couldn't work for all URLs within https://google.com/maps/* - for example, there's a unique URL for directions between 2+ places which no longer conforms to the one-point requirements. Search results don't work either, nor street view, etc., though those aren't what I was thinking of anyway.

For all URLs corresponding to actual single places that I could find, it seems like the URL always eventually has latitude and longitudes embedded. However, when copying a Share link from the Android app, it defaults to a URL shortener, for example https://maps.app.goo.gl/EXe9jqooX3sXoZm7A. This resolves to a URL with lat/long coordinates but I understand that would present an issue to fetching/storing the associated coordinate data.

A 'solution' could be only recognize Google Maps links with the coordinates within the URL, which seems pretty reasonable to me since by following the normal workflow via Google Maps they have to look for and find those coordinates (to copy them over) anyway, and since some types of Google Maps links like the above examples wouldn't work no matter what so the user already has to be semi-aware. It's an annoying hiccup but a user can get the right link by letting their browser resolve the shortened URL into the full one and paste that in.

Maybe there are other URL formats I'm unaware of.

ryanwwest commented 1 year ago

To be honest, I prefer not having shortened URLs in notes anyway because of the loss in value that can be derived from the URL data (such as lat/long, even if I were not using this plugin). But that's just me.

esm7 commented 1 year ago

I'm convinced. Will prioritize it.

eb2ai commented 1 year ago

I want to tag on to this fantastic idea. I do the same thing with Apple Maps, and this would be invaluable!

This is an example on how I've linked to maps.

[Easter Island](http://maps.apple.com/?q=-27.128500000000003,-109.33602969583333)

Apple's page on their URL structure