How to link out to map services?

iljitsch

Ars Tribunus Angusticlavius
8,474
Subscriptor++
Some years ago, I made a web app that tracks certain events. These events happen at certain locations. What I did back then is find the GPS coordinates and make a Google Maps URL to let people navigate there. (Addresses wouldn’t work as many of these events happen in parks etc.) These links look like this:

http://maps.google.com/maps?q=52.3606,4.8755&z=13

So that means that under normal circumstances, when you click that link, you get the Google Maps web view. On an iPhone with the Google Maps app installed you get asked whether you want to use that to view the location. I assume something similar happens on Android.

Google also has a Google Maps URL Scheme for iOS to directly link to the Google Maps app, but that seems to be no longer necessary as of IOS 9.

For something else I used Apple Maps links instead. These links look like this:

https://maps.apple.com/?q=52.3606,4.8755

When you click on them on stuff running Apple’s OSes, you get a prompt asking you whether you want to open it in the native Maps app. On other OSes, you are redirected to Google Maps.

Of course there’s also numerous other maps services, such as OpenStreetMap...

I’m thinking on mobile, getting to a native maps app is probably what you want most of the time because then you can get directions. On the desktop, staying in the browser may be better more of the time. But browser/OS detection, really?

My question is: what is a good way to handle this? On the one hand using the Apple links works well as one link does what most people want most of the time. But then again, being able to choose* between Apple Maps and Google Maps would be nice. But that either means having two links, having an intermediate popup or something, or having the user select a choice that’s saved as a cookie.

Please tell me the one perfect way to handle this conundrum.

* Apparently the EU hasn’t forced Apple to allow users to select their preferred mapping service just yet... Uninstalling the Maps app doesn’t help, as iOS won’t offer to use Google Maps, but just asks you whether you want to reinstall Apple Maps.
 

ImpossiblyStupid

Smack-Fu Master, in training
81
Subscriptor
Please tell me the one perfect way to handle this conundrum.
Well, the one correct way is to use a geo: URI. Problem: trillion dollar tech companies are prissy little toddlers. I don't know what the OS/browser support of the alternative maps: URI is these days.

Honestly, I'd say the best way to use their efforts at lock-in against them is to only ever link to OpenStreetMap, and wait for them to intercept those links if they want to claim support for a "default" mapping app.
 

iljitsch

Ars Tribunus Angusticlavius
8,474
Subscriptor++
Yeah, that RFC 5870 geo: URI scheme took flight like a lead balloon. (As someone who wrote a few RFCs in my day that went nowhere, I can sympathize.)

Interestingly, that maps: URI scheme has left no traces on the web (well, based on Google searches, anyway). But you just replace the URL part from an Apple or Google maps link and replace it with maps: leaving the query string and its formatting in place like so:

maps:?q=52.3606,4.8755&z=13

Works on Apple stuff and in Chrome on the Mac (not running the latest versions, though, and in Safari not if you enter the URI in the URL bar manually) but on Chromium on Linux I get a prompt asking me if I want to run xdg-open. Sure, why not. Which just opens a new blank Chromium window. This is probably fixable, but it does sink maps: as a general purpose solution.

Can anyone confirm this works on Android?

Ok, I'm thinking the best solution is to use the maps: scheme if Android supports it to cover mobile, and then an onmouseover() that pops up a set of links to Google, Apple, Bing, OpenStreetMap for on the desktop.
 

ImpossiblyStupid

Smack-Fu Master, in training
81
Subscriptor
Chromium on Linux I get a prompt asking me if I want to run xdg-open. Sure, why not. Which just opens a new blank Chromium window. This is probably fixable, but it does sink maps: as a general purpose solution.
Yeah, the "correct" secondary solution is to set up an OS (or app-level) URL handler for geo/maps/whatever. Chicken-and-egg, though, since without wide adoption you still have to include links to set that up alongside any "universal" mapping link.

Ok, I'm thinking the best solution is to use the maps: scheme if Android supports it to cover mobile, and then an onmouseover() that pops up a set of links to Google, Apple, Bing, OpenStreetMap for on the desktop.
Or essentially follow the "social media" model, and give a list of icons corresponding to each service.
 

iljitsch

Ars Tribunus Angusticlavius
8,474
Subscriptor++
Or essentially follow the "social media" model, and give a list of icons corresponding to each service.
Yeah, I suppose. But I want to avoid confusion and optimize for the case where people are on their way to the event and want to get directions. As it turns out that the maps: URI scheme is not supported on Android, apparently it's an Apple-only thing, I'll just use the Apple link which will give you the native maps app on mobile and Google Maps on the desktop for non-Apple users.