Extracting lat/lon from google maps url

4,780 views
Skip to first unread message

Kelemen Viktor

unread,
Jun 4, 2011, 4:37:25 AM6/4/11
to Google Maps JavaScript API v3
hi,

i'd like to extract latitude and longitude values from google map
links.

let's say you have the following link (this is the link that you'd get
on http://maps.google.com link menu)

http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=tokyo&aq=&sll=35.675147,-95.712891&sspn=47.800848,92.724609&ie=UTF8&hq=&hnear=Tokyo,+Japan&t=h&z=9

there are a couple of lat/lon values here (sll, sspn) but none of them
seems right. In this case the first pair links to Mongolia the second
goes to Oklahoma.

the correct lat/lon would be around 35.6894875, 139.6917064.

my question is that how you can get this values from a link?

I found this site http://mapki.com/wiki/Google_Map_Parameters but i
could not really figure out the solution.

thanks and best, Viktor

Barry Hunter

unread,
Jun 4, 2011, 8:31:28 AM6/4/11
to google-map...@googlegroups.com

The coordinates aren't always included. If they where they would be in the ll= parameter. Alought that is just where the view is centered and the user may of dragged the map, not the coordinates of the searched location.

Don't know what your goal is so can't suggest alternatives ...

> --
> You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group.
> To post to this group, send email to google-map...@googlegroups.com.
> To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.
>

Kelemen Viktor

unread,
Jun 6, 2011, 1:43:06 AM6/6/11
to Google Maps JavaScript API v3
hi,

thanks.
what you mean is that the google map link is just a search query and
does not (may not) include any specific location information?

our use case is that:
Users can enter google map links and our app shows them on a map.
let's say user #1 enters 3 google map links
user #2 enters 5 google map links
now i'd like to see them all on a map.

best,
Viktor




On Jun 4, 9:31 pm, Barry Hunter <barrybhun...@gmail.com> wrote:
> The coordinates aren't always included. If they where they would be in the
> ll= parameter. Alought that is just where the view is centered and the user
> may of dragged the map, not the coordinates of the searched location.
>
> Don't know what your goal is so can't suggest alternatives ...
> On Jun 4, 2011 9:37 AM, "Kelemen Viktor" <kelemen.vik...@gmail.com> wrote:> hi,
>
> > i'd like to extract latitude and longitude values from google map
> > links.
>
> > let's say you have the following link (this is the link that you'd get
> > onhttp://maps.google.comlink menu)
>
> http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=tokyo&aq=...
>
>
>
>
>
>
>
>
>
> > there are a couple of lat/lon values here (sll, sspn) but none of them
> > seems right. In this case the first pair links to Mongolia the second
> > goes to Oklahoma.
>
> > the correct lat/lon would be around 35.6894875, 139.6917064.
>
> > my question is that how you can get this values from a link?
>
> > I found this sitehttp://mapki.com/wiki/Google_Map_Parametersbut i

Barry Hunter

unread,
Jun 6, 2011, 3:57:06 PM6/6/11
to google-map...@googlegroups.com
On 6 June 2011 06:43, Kelemen Viktor <kelemen...@gmail.com> wrote:
> hi,
>
> thanks.
> what you mean is that the google map link is just a search query and
> does not (may not) include any specific location information?

Correct,

taken to extreme, the link could look like
http://maps.google.com/?q=London

Even using 'Link' to get the generated on link, gives:
http://maps.google.com/?q=London&ie=UTF8&hq=&hnear=Westminster,+London,+United+Kingdom&t=h&z=10

which still doesn't contain any coordinates.

>
> our use case is that:
> Users can enter google map links and our app shows them on a map.

You could get perhaps close, by geocoding the 'q' param, to lookup the
location via the geocode, (but taking into account, sll, hnear, hq
too)

But links can also be like
http://maps.google.com/maps?q=pizza+express,+Crawley

which the geocoder will not help with. The old local search API might,
but Terms prevent you using that.

(I have stripped these links down, to show the actual salient info.
But the APIs do not allow you to completely reconstruct the map
totally)


> let's say user #1 enters 3 google map links
> user #2 enters 5 google map links
> now i'd like to see them all on a map.

Alas I fear that may not be totally (legally) possible. It might be
possible, by straying into 'gray' areas of the terms. But dont really
want to discuss that here.

Reply all
Reply to author
Forward
0 new messages