8

I'm building a mobile-version of a website, trying to have one-click link to launch Google Maps with driving directions to the business, from the user's current location. I have it working fine for the iPhone, but when testing on Android, it views 'Current%20Location' and tries to find a business called 'Current Location'. Here is my current code:

    <a href="http://maps.google.com/maps?saddr=Current%20Location&daddr=123 Street Rd,Cityville,MD,21098">Get Directions</a>

I need a universal string to search from the current location, and can't find a definitive answer anywhere online.

Thanks in advance for any help!

jmarx34
  • 228
  • 2
  • 7
  • 25

4 Answers4

7

I am doing the same thing and now have it working on Android. I don't have an iPhone so I have no way of testing on that. You should leave the saddr parameter blank in the URL, and Google Maps will then prefill it with the user's current location. Also, use + signs instead of spaces in the destination address. Here's the corrected URL:

http://maps.google.com/maps?saddr=&daddr=123+Street+Rd,Cityville,MD,21098

Derrick Miller
  • 1,860
  • 3
  • 21
  • 37
  • 2
    To make this link work on an iPhone, just change the 'saddr' value to "Current Location". Like this. `http://maps.google.com/maps?saddr=Current%20Location&daddr=123+Street+Rd,Cityville,MD,21098` More details on the Google map API are [here](http://mapki.com/wiki/Google_Map_Parameters). – Dan Berlyoung May 08 '12 at 20:42
0

Google Maps with directions from current location

https://maps.google.com/maps?saddr=&daddr=35.658157,139.697174&sensor=TRUE

https://maps.google.com/maps?saddr=&daddr= PLUS

"location's_latitude" PLUS

"," PLUS

"location's_longitude" PLUS

"&sensor=TRUE" // for getting your current location

Probably the most accurate way using lat and long

michelito
  • 21
  • 6
0
<span class="addressAt">
     <a href="http://maps.google.com/maps?f=d&amp;hl=en&amp;region=US&amp;doflg=ptm&amp;geocode=&amp;saddr=&amp;daddr=41.75553,-88.322048" target="_blank">213 S River St
Aurora, IL</a>
</span>

This is the only way to get an accurate "my location" on the google maps mobile site. Replace the coordinates(41.75553,-88.322048) with your locations coords. All other ways just wrote in my location as the start address without actually getting the real time location.

Joe Barrett
  • 135
  • 1
  • 1
  • 10
0

Use the google gps api to get the currentlocation and pass it to maps. Even better I think there's an action to open the built-in maps application asking it to route from current location to your address.

This article on location services should help http://developer.android.com/guide/topics/location/index.html

If you're trying to do it fully through the web, I think the user has to enable location services on the google webpage for it to work.

Also, check out this javascript library that provides a platform neutral api for gps services on most devices http://code.google.com/p/geo-location-javascript/

Michael Brown
  • 9,041
  • 1
  • 28
  • 37