Sparky
Sparky

Reputation: 43

Current Location in Google Maps using only a URL

So I would like to use a URL to retrieve and display ONLY the users CURRENT LOCATION.

For example: A user with a smartphone (iPhone, Android, etc) opens a link [http://maps.google.com/CURRENTLOCATION] on their phone, and it shows their current location on the user's device in either Google Maps app or browser, as reported by their GPS/wireless location. The actual link itself should should remain static, and display the location wherever they are.

Is this possible?

Thanks in advance!

Upvotes: 0

Views: 22013

Answers (2)

JackCA
JackCA

Reputation: 4885

This is discussed front and center in the Google Maps geolocation API: Detecting the User's Location

According to the documentation, the user will need using an HTML5 equipped browser for this to work. You will need to write the Javascript which looks pretty vanilla.

Edit: This only works if you are using your own domain and have implemented the Maps API (which is really simple), not Google's own maps.google.com

Upvotes: 1

dermatthias
dermatthias

Reputation: 1180

If you have the lat/long coordinates (which I suppose you get through the gps/wireless device), you can use something like this:

http://maps.google.de/maps?q=loc:48.0000,9.000

which opens the Google Maps website with the coordinates N48.0 E9.0 (as decimal coords) centered.

Or, if you need a static map (and not a full fledged JavaScript map), use this link and adjust the values inside the URL:

http://maps.google.com/maps/api/staticmap?center=48.00,9.00&zoom=14&size=512x512&maptype=roadmap&markers=color:blue|48.0,9.0&sensor=true

Valid values for the arguments are:

  • for maptype: roadmap, terrain, satellite
  • for zoom: 1 to 20

Upvotes: 4

Related Questions