I'm trying to do what seemed to be an easy thing but has resulted in some confusion. I'm trying to have a link going to Google Maps with the destination address pre-filled and the from address to inherit the user's current location. From what someone else had instructed, if I used 'current location' as the 'from address', it'd do everything for me.
Instead, when I access the URL from a different location, it's still loading the original "current location" and not the actual current location.
I'm sure it's something stupidly easy, but I'm hoping that someone could point me in the right direction.
The link can be found here.
39 Answers
For those still looking, here are some methods of linking to Google Maps:
Spaces can be changed to + or encoded as %20.
Linking to a location (No directions)
No starting point (User input required to generate directions).
With a set location as starting point (Automatically generates directions with no user input required).
With "My Location" as starting point (Automatically generates directions with no user input required).
Current Location to Latitude and Longitude
Query search of a Latitude and Longitude. Also shows setting a default zoom level.
String search as destination
Here is a post I made that I will keep updated as there are some even newer ways to do this!
11Use My Location instead:
Current Location only works on OS'es with English locale setup.
I haven't found any documentation on this. However leaving saddr blank as suggested here will prompt the user to input start address.
The answers of GreatBlakes and Jon Alslund-Lanthén suggest a way that sometimes gives you the right result but that can fail if the language of your user isn't English.
As of 2019, the best way seems to be:
3Also, you can try to use
It is works for me on android and ios at least. May be usefull. More details here :
2Try taking out a load of the information, and using 'Current+Location' and, oddly, using .co.uk rather than .com.
The link works as expected for me (Win7, Chrome and IE9, Android Chrome).
1My+Location queryString doesn't work. But Current+Location queryString value is good work.
True link
If you make the destination and the current location the same that will work.
So you should copy/past the destination address also in to my location, than plan route and copy the URL.
This will work
I am assuming you want this link to open on a mobile phone.
None of the strings mentioned populated my actual GPS Location on iOS 14 or the recent versions of android.
This is what did work for me,
// (double slashes intended) - indicates a custom starting point.
On desktop it leave this field unpopulated, but on mobile it takes your actual GPS location.
Looks like I do not need a google api key after all.
What you expect to be the users location is not what you expect, "current location" will be taken by google as any other address, and google tries to find a place that matches the query.
When somebody told you that "current location" will force google to resolve the location of the user, this is wrong.
You may geolocate the user on your own and then create the link based on the geolocation-result.
5