309

I have a small application that gives the current location: longitude and latitude. Now I have to browse to google maps with the longitude and latitude. Please suggest how I can do this.

RedBlueThing
  • 42,006
  • 17
  • 96
  • 122
Deepika
  • 3,382
  • 2
  • 17
  • 14

16 Answers16

494

The best way is to use q parameter so that it displays the map with the point marked. eg.:

https://maps.google.com/?q=<lat>,<lng>
Lucio
  • 4,753
  • 3
  • 48
  • 77
Yilmaz Guleryuz
  • 9,313
  • 3
  • 32
  • 43
238

This schema has changed again (23rd October 2018). See Kushagr's answer for the latest.

This for a map with the marker (via aaronm's comment):

https://www.google.com/maps/?q=-15.623037,18.388672

For an older example (no marker on this one):

https://www.google.com/maps/preview/@-15.623037,18.388672,8z

The oldest format:

http://maps.google.com/maps?ll=-15.623037,18.388672&spn=65.61535,79.013672

RedBlueThing
  • 42,006
  • 17
  • 96
  • 122
  • 1
    Is there somewhere information about the new format? Particularly, Internet is full of examples of old format and it is hard to Google (sic) the new format from all the noise. – Mikko Ohtamaa Mar 04 '14 at 13:29
  • 48
    The "new" format above does not include a marker, if you use this format it works - https://www.google.com/maps/?q=, eg: https://www.google.com/maps/?q=-15.623037,18.388672 – AaronM Oct 15 '14 at 01:54
  • 1
    Is there a way to specify the map type (hybrid, road, etc)? – Redtopia Nov 30 '14 at 06:27
  • thanks. is it possible to show a pin on custom location? – pixparker Feb 05 '17 at 18:21
  • @pixparker See AaronM response above using google.com/maps/?q=, Also note there is no option here for zoom. – nwolybug Feb 17 '17 at 21:12
  • 3
    New best answer as per @Kushagr Arora's answer is https://www.google.com/maps/search/?api=1&query=, – dave Nov 08 '18 at 23:44
188

As of today (1st November, 2020), Google provided a provision of Universal URL which works quite efficiently on cross-platforms and thus, Google recommends this method.

Syntax: https://www.google.com/maps/search/?api=1&query=<lat>,<lng>

Example : https://www.google.com/maps/search/?api=1&query=28.6139,77.2090 (New Delhi, India)

Documentation/Source.

Kushagr Arora
  • 1,978
  • 1
  • 10
  • 11
  • 2
    The [old URL format](https://developers.google.com/maps/documentation/urls/ios-urlscheme) still applies if you need features not available in the new one. Both formats are called "Universal Links", even though some don't work on Android. I guess Google subscribes to multiverse theory. :-) – Edward Brey May 14 '19 at 13:26
  • 4
    I can confirm this is still valid as of 18th February 2021 – Ben D Feb 18 '21 at 11:14
  • 2
    I can confirm this works well for browser and android. On android it's triggers both the browser or the maps application as options to select to resolve the uri. – revobtz Apr 12 '21 at 03:44
135

As of today (2014/09/23), I've found that to get marker on exact place (not an approximation) you can use:

http://www.google.com/maps/place/49.46800006494457,17.11514008755796

Additionally, if you want to specify map center and zoom:

http://www.google.com/maps/place/49.46800006494457,17.11514008755796/@49.46800006494457,17.11514008755796,17z

If you want to use satellite map type, then append /data=!3m1!1e3

http://www.google.com/maps/place/49.46800006494457,17.11514008755796/@49.46800006494457,17.11514008755796,17z/data=!3m1!1e3

And If you want terrain view of the map, then append /data=!3m1!4b1

https://www.google.com/maps/place/49.46800006494457,17.11514008755796/@49.46800006494457,17.11514008755796,17z/data=!3m1!4b1
Lucky
  • 16,787
  • 19
  • 117
  • 151
Pogo19
  • 1,453
  • 1
  • 10
  • 13
  • Any idea how to add the map type (hybrid, etc)? – Redtopia Nov 30 '14 at 06:01
  • 1
    @Redtopia, see my updated answer for satellite map type. – Pogo19 Dec 01 '14 at 13:52
  • Thanks! Do you know what that data variable means or how to interpret it? Also, are there any docs that you know about that describe this new linking scheme? – Redtopia Dec 02 '14 at 17:15
  • 1
    @Redtopia, it is just an experimental knowledge. Actually, I had to try several URL parameters to find an answer for you. I haven't found no such documentation. Sorry! – Pogo19 Dec 03 '14 at 22:07
  • @Pogo19 is there a way to generate a google link with the nearby restaurants like http://maps.google.com/?q=, would show me the location corresponding to the lat , long along with that can i also pass in some parameter to locate the nearby restaurants as well something like http://maps.google.com/?q=, & nearBy = restaurant – Omkar Guhilot Oct 28 '15 at 12:25
  • @OmkarGuhilot Try something like this: `http://www.google.com/maps/search/restaurant/@49.46800006494457,17.11514008755796,17z` – Pogo19 Oct 29 '15 at 13:09
  • @Pogo19 Thanks a lot for your response.it is giving me a specific restaurant , i wanted the nearby restaurants for the particular lat long that i provide. – Omkar Guhilot Oct 29 '15 at 13:14
  • @OmkarGuhilot Try to change the search string, that is `/restaurant/` in my previous example URL. – Pogo19 Oct 30 '15 at 14:53
  • 2
    It's February 2016 and it appears that this method still works. Well done. – user110857 Feb 09 '16 at 22:23
  • @gmeben As long as Google Maps don't change it, it will work :) – Pogo19 Feb 10 '16 at 12:04
  • @AhmadMobaraki It is the second example: `http://www.google.com/maps/place/49.46800006494457,17.11514008755796/@49.46800006494457,17.11514008755796,17z` – Pogo19 Jun 18 '17 at 10:28
  • Thank you! there you just mentioned map center & zoom, not marker, so I did not test it – Ahmad Mobaraki Jun 18 '17 at 12:05
  • This does not work anymore as of today. Here is the current description by google how to build links: https://developers.google.com/maps/documentation/urls/guide – sieppl Feb 23 '18 at 14:47
  • August 2020 and these all work on Chrome browser on Windows. – PRMan Aug 10 '20 at 22:33
44

If you want to open Google Maps in a browser:

http://maps.google.com/?q=<lat>,<lng>

To open the Google Maps app on an iOS mobile device, use the Google Maps URL Scheme:

comgooglemaps://?q=<lat>,<lng>

To open the Google Maps app on Android, use the geo: intent:

geo:<lat>,<lng>?z=<zoom>

Garland Pope
  • 3,242
  • 1
  • 25
  • 19
Emilio Rodriguez
  • 5,709
  • 4
  • 27
  • 32
  • 2
    You can also use "google.navigation:q=latitude,longitude" to start immediately the navigation with google maps app, but does not work with some gps apps. The more generic is "geo:,?q=,(Label,Name)" as referred ojus kulkarni em previous comment (the parameters force to show the marker, helping to navigate) – Manuel Romeiro Oct 25 '17 at 02:52
22

It´s out of the scope of the question, but I think it might be also interesting to know how to link to a route. The query would look like this:

https://www.google.es/maps/dir/'52.51758801683297,13.397978515625027'/'52.49083837044266,13.369826049804715'
AlvaroSantisteban
  • 5,256
  • 4
  • 41
  • 62
19

These are URLs that work:

http://maps.google.com/?q=<LAT>,<LNG>

https://maps.google.com/?q=<LAT>,<LNG>&ll=<LAT>,<LNG>&z=18

https://www.google.com/maps/@<LAT>,<LNG>,16z

https://maps.google.com/?q=<LAT>,<LNG>&z=16

Although (for avid readers) This is the latest from google (August 22 2017):

Maps URLs
Maps URLs with map display
Maps URLs with search action

From google

Search: When searching for a specific place, the resulting map puts a pin in the specified location and displays available place details.

Important: The parameter api=1 identifies the version of Maps URLs this URL is intended for. This parameter is required in every request. The only valid value is 1. If api=1 is NOT present in the URL, all parameters are ignored and the default Google Maps app will launch, either in a browser or the Google Maps mobile app, depending on the platform in use (for example, https://www.google.com/maps).

Jadeye
  • 3,551
  • 4
  • 47
  • 63
15

This works too:

https://www.google.pl/maps/@<lat>,<lon>,<zoom>z

Example.

With pointer:

https://www.google.com/maps/place/<lat>,<lon>/@<lat>,<lon>,<zoom>z

Example.

yudhiesh
  • 6,383
  • 3
  • 16
  • 49
marioosh
  • 27,328
  • 49
  • 143
  • 192
9

To open the google maps app in android:-

geo:<lat>,<lng>?z=<zoom>

open app with marker for give location:-

geo:<lat>,<lng>?q=<lat>,<lng>(Label,Name)

open google map in ios:-

comgooglemaps://?q=<lat>,<lng>

open google maps in browser with following parameters:-

http://maps.google.com/maps?z=12&t=m&q=<lat>,<lng>
  • z is the zoom level (1-21)
  • t is the map type ("m" map, "k" satellite, "h" hybrid, "p" terrain, "e" GoogleEarth)
  • q is the search query
ojus kulkarni
  • 1,877
  • 3
  • 25
  • 41
7

Using the query parameter won't work, Google will try to approximate the location.

The location I want : http://maps.google.com/maps?ll=43.7920533400153,6.37761393942265

The approximate location (west of the actual location) : http://maps.google.com/?q=43.7920533400153,6.37761393942265

Frato
  • 476
  • 5
  • 4
5

say easily http://www.google.com/maps/place/lat,lng format

sample url:

http://www.google.com/maps/place/30.364124,48.227034

pixparker
  • 2,903
  • 26
  • 23
4

To get your current location as start point you need to use this URL:

https://www.google.com/maps/dir/?api=1&origin=Current+Location&destination=<latitude>,<longitude>

You can fill up the destination parameter with the address, name or latitude and longitude values.

3

Open the following url with the latitude and longitude and zoom level.

https://maps.google.com/?q=23.22,88.32&z=8

0

Find your location in the Google Earth program, and click the icon "View in Google Maps". The URL bar in your browser will show the URL you need.

0

Open google map and show URL schemes location and location pin

UIApplication.shared.openURL(URL(string:"https://maps.google.com/?q=\(dicLocation.stringValueForKey("latitude")),\(dicLocation.stringValueForKey("longitude")),15z")!)
Srinivasan_iOS
  • 972
  • 10
  • 12
0

if you want a dir with travel mode = walking

https://www.google.es/maps/dir/'52.51758801683297,13.397978515625027'/'52.49083837044266,13.369826049804715'/data=!4m2!4m1!3e2