57

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.

jon snow
  • 3,062
  • 1
  • 19
  • 31
Brian Schroeter
  • 1,583
  • 5
  • 22
  • 41

9 Answers9

192

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)

    https://www.google.com/maps?q=760+West+Genesee+Street+Syracuse+NY+13204
    
  • No starting point (User input required to generate directions).

    https://www.google.com/maps?daddr=760+West+Genesee+Street+Syracuse+NY+13204
    
  • With a set location as starting point (Automatically generates directions with no user input required).

    https://www.google.com/maps?saddr=760+West+Genesee+Street+Syracuse+NY+13204&daddr=314+Avery+Avenue+Syracuse+NY+13204
    
  • With "My Location" as starting point (Automatically generates directions with no user input required).

    https://www.google.com/maps?saddr=My+Location&daddr=760+West+Genesee+Street+Syracuse+NY+13204
    
  • Current Location to Latitude and Longitude

    https://www.google.com/maps?saddr=My+Location&daddr=43.12345,-76.12345
    
  • Query search of a Latitude and Longitude. Also shows setting a default zoom level.

    https://www.google.com/maps?ll=43.12345,-76.12345&q=food&z=14
    
  • String search as destination

    https://www.google.com/maps?saddr=My+Location&daddr=Pinckney+Hugo+Group
    

Here is a post I made that I will keep updated as there are some even newer ways to do this!

H. Pauwelyn
  • 13,575
  • 26
  • 81
  • 144
GreatBlakes
  • 3,971
  • 4
  • 20
  • 28
  • There are additional ways to do this as well- Check out the link at the bottom of my answer for the most up-to-date syntaxes. – GreatBlakes May 21 '14 at 04:51
  • 2
    OMG. thank you. I thought I would have to do some kind of code acrobatics via Gmaps API. I'm so happy. – Seth Malaki Oct 28 '14 at 08:41
  • If i give one of these links as a href and open it in a new tab, will it work the same on ios and mobile? – Nevin Madhukar K Sep 04 '15 at 10:28
  • http://stackoverflow.com/questions/32472923/google-maps-having-directions-doesnt-work-on-mobile-no-routes-found – Nevin Madhukar K Sep 09 '15 at 08:33
  • The domain on these links should be maps.google.com -- www.google.com/maps will take you to normal google search. URL params still appear to be legit. Thanks! – Alex Sharp Oct 11 '15 at 23:13
  • 2
    It is April, 2016 and the URLs all seem to work just fine just the way GreatBlakes presented them. Awesome! – hndcrftd Apr 11 '16 at 11:49
  • @GreatBlakes Any idea how to tell Google Maps to optimize my waypoints to calculate the shortest route possible? – Steve Apr 13 '17 at 10:05
  • @Steve, unfortunately this method only allows waypoints to be in the order they are listed in the URL. – GreatBlakes Jul 12 '17 at 12:27
  • You're a god amongst men. Also try this format: `https://www.google.com/maps/dir/Current+Location/44.277549,-78.338084` – Joshua Pinter Nov 13 '19 at 03:03
  • @GreatBlakes - Is it possible to go from My Location to a place ID like `ChIJaXQRs6lZwokRY6EFpJnhNNE`? – Pikamander2 Jul 24 '20 at 12:31
  • For that you may need to first use the JS API to get the address from the Place ID: https://developers.google.com/maps/documentation/javascript/examples/geocoding-place-id . It's a shame Google doesn't just do the conversion for you in the URL. – GreatBlakes Jul 25 '20 at 15:24
12

Use My Location instead:

https://maps.google.com/?saddr=My%20Location&daddr=myDestinationAddress

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 https://developers.google.com/maps/documentation/ios-sdk/urlscheme will prompt the user to input start address.

11

Also, you can try to use

  https://maps.google.com/?daddr=53.9187068,27.5862874

It is works for me on android and ios at least. May be usefull. More details here : https://developers.google.com/maps/documentation/ios/urlscheme?utm_source=welovemapsdevelopers&utm_campaign=GM-for-iOS-sdk-1-7

Nigrimmist
  • 10,289
  • 4
  • 52
  • 53
  • 1
    The documentation at https://developers.google.com/maps/documentation/ios-sdk/urlscheme#search clearly states that if you leave the `saddr` parameter blank it will take the current location. – fsaftoiu Apr 19 '16 at 08:49
  • 1
    Hmm, that's interesting, when I specify something like `saddr=My+Location&daddr...` Google Maps app doesn't necessarily use my exact current location (every other time it's soo off). But with your solution, it's working just fine. – ekashking May 12 '18 at 04:35
11

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:

https://www.google.com/maps/dir/?api=1&destination=Googleplex,+1600+Amphitheatre+Pkwy

Christian
  • 25,249
  • 40
  • 134
  • 225
  • Yes, this is the current right was to do it as according to https://developers.google.com/maps/documentation/urls/guide#directions-action If you specify don't specify origin as @Christian rightly said, it picks the user's location as default and if the user did not grant browser permission, Google Maps will demand the user for starting point. A better bet is to add the exact `destination_id` obtainable at https://developers.google.com/places/place-id to make sure the users are shown the directions to the right destination – Obum Jun 18 '20 at 18:31
  • Yep, Only this one working properly. "Current+Location" take city as start point. "My+Location" take district of city as start point. – Max Lipsky Jan 18 '21 at 11:30
  • yep, this is the only one that worked for me both on desktop and in mobile, regardless the language of the user. Thanks! – Zoltán Süle Mar 31 '22 at 11:47
3

My+Location queryString doesn't work. But Current+Location queryString value is good work.

True link

https://www.google.com/maps?saddr=Current+Location&daddr=36.8957642,30.7089634
Yasin Özcan
  • 31
  • 1
  • 1
2

Try taking out a load of the information, and using 'Current+Location' and, oddly, using .co.uk rather than .com.

The link https://maps.google.co.uk/maps?t=m&f=d&saddr=Current+Location&daddr=312%20Ponce%20De%20Leon%20Boulevard,%20Coral%20Gables,%20FL works as expected for me (Win7, Chrome and IE9, Android Chrome).

Grim...
  • 16,518
  • 7
  • 45
  • 61
0

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

Doeye Hof
  • 1
  • 1
0

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,

https://www.google.com/maps/dir//Address1/Address2

// (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.

-2

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.

Dr.Molle
  • 116,463
  • 16
  • 195
  • 201
  • 5
    This isn't specifically true. Try this link to a house in London: https://maps.google.co.uk/maps?q=N2%200TA&t=m&&f=d&saddr=current+location&daddr=N2%200TA&source=embed The only device I've found that it doesn't work on so far are older iPads and iPhones (I've not tested newer ones). Android, IE9 and Chrome (on Windows) all start you at your location. – Grim... Feb 24 '13 at 20:42
  • Returns for me anything, but not my current location as start-adress. – Dr.Molle Feb 24 '13 at 22:40
  • Hmm, it does for me. How odd. I wonder what the difference is? – Grim... Feb 25 '13 at 11:35
  • 1
    It seems Google removed the ability to use strings such as "My location" or "Current location" in the direction fields. We now need to retrieve the current position (`navigator.geolocation.getCurrentPosition`) and to push it to the google maps start field. – Matthieu Charbonnier Nov 04 '14 at 22:45
  • The funny thing is that when google map is opened I can actually see my exact current location blinking but Google still doesn't recognize My Location or Current Location and gets a starting point somewhere else. – ekashking Jun 26 '18 at 10:38