I want to extract the latitude and longitude of a set of about 50-100 pins in a Google maps web page. I don't control the page and I don't need to do it more than once so I'm looking for something quick and dirty. I've got FireFox with FireBug as well as Chrome and all I need is something that's easier than re typing all the numbers.
-
1@Jonathan: Why do you assume I would be stealing it? From what I said, it might be from a public domain data set. (In fact, I have every reason to believe that the owner would be fine with me extracting the data. The page is publicly available.) – BCS Apr 01 '10 at 06:29
-
4If it is a public dataset then why not get it rather than writing a script to farm the data from within an application? A publicly available page doesn't not mean that the data on it is free... – Jonathan Apr 01 '10 at 07:37
-
3Can you imagine a situation in which the coordinates of certain points on a map which is freely accessible would not be free? – nico Sep 11 '10 at 21:32
4 Answers
Simply click the link shortcut on the map to retreive a URL for the map with pins in.
Next add &output=kml
to the end of this url and use the link to retrieve a kml file containing all the pin data.
This kml file is actually in xml format so parsing it should be easy, you just need to look for <coordinates>
elements which contain the latitude and longitude data you need.
The kml format is documented here: http://code.google.com/apis/kml/documentation/kmlreference.html

- 739
- 6
- 15
-
-
6This doesn't works anymore. Now the trick is: https://www.google.com/maps/d/kml?mid={map_id} For example : https://www.google.com/maps/d/kml?mid=1lL6Ylpo7P3HnANcHTAzbH5hEx-E – Bruno Duyé Jun 08 '16 at 12:20
Just saving the .html file and using regex works:
These two reg-ex might be good starting points:
@[0-9]+\.[0-9]+,-[0-9]+.[0-9]+",geocode:"",sxti:"[-@A-Za-z .]+"
{id:"[A-Zloc0-9]+",fid

- 75,627
- 68
- 187
- 294
Google has change a lot the way you can extract information about google.maps and has set some limitations like numbers of queries by day.
To extract the lat and lon of Google maps you need a bit of knowledge about HMTL code and manipulating JSON/XML files. (all can be found in many tutorials.
I recommend you to extrac the data using de "Google Places API" it's VERY EASY! and you can extract about 150k locations by day for free. You have to get an account, activate your privileges of API Places (turn on/off buttom), get you secret KEY and then use a simple URL to extract the JSON/XML file. Here are two great links for that:
[1] https://developers.google.com/places/documentation/search?hl=en
[2] https://developers.google.com/places/training/basic-place-search?hl=en
If you want DETAIL info about the coordinates that you'll get, go to the section "Requesting Place Details" in the second link, that gives you info about what kind of site is that, the phone number and all the comments that users has made, if they are available.
Great coding and greetings!

- 59
- 4
Depending on the type of the map and whether the pins are set by latitude and longitude or by address, it might even work to just get the link (click on "Link" at the Google Maps page, the URL in the browser might not be the sam) and look for the "sll=[...]" parameters.

- 706
- 7
- 22
-
OK, now how do I extract the links? Keep in mind I had more than can be easily done by hand. – BCS Sep 06 '10 at 04:16
-