How to extract the lat/lng of pins in google maps? - google-maps

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.

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

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

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!

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.

Related

Free geocode API allowing store names and coordinates

My application should allow users to store events and their locations and then perform search on them - so I need those locations in my database with their names and latitudes/longitudes. Google API doesnt allow storing anything else but place IDs so I have to find something else that can autocomplete/suggest places on UI and allow storing it my database.
Does anyone know such a good service?
You can simply add your points in your DB based on each point Lat & Long values. So when user is searching somewhere you have his current location(Lat-Long), Therefore you can search in your DB and get the distance of each saved point with current location and retrieve the results you want to show (i.e in JSON format).
In client-side use some auto-complete jquery library to show the nearby places and somethings like that (with additional information).
Google Map API has a service that you can show some custom marker on the map with your custom configuration like marker icon, description and etc. You can show your additional information in description as HTML format.
You can see some example here:
Customizing a Google Map: Custom Markers
Hope these tips would be helpfull. Regards.
Suddenly I've found an answer that helps me:
https://productforums.google.com/forum/#!topic/maps/hNc1OOU6Zm8
So I can use some Google's data under some conditions.

How do I get a direct link to a place on google maps with the Place Id

I have the Place Id of a place on google maps in my app. Is there a way to put the place Id in a URL and have it directly link to the page? Or does it have to be done through the URL?
I can't seem to find anything detailing this in the docs. I've tried below, but it just gets me the standard google maps page:
https://maps.google.com/maps?placeid=ChIJN1t_tDeuEmsRUsoyG83frY4
Recently, in May 2017, Google launched the new Google Maps URLs API. You can read about this API in the official documentation
https://developers.google.com/maps/documentation/urls/guide
So, from now on you can construct a URL for Google Maps using the place ID. In your particular case this URL will be
https://www.google.com/maps/search/?api=1&query=Google&query_place_id=ChIJN1t_tDeuEmsRUsoyG83frY4
Hope this helps!
Not directly, using the placeID you can get a variety of information in JSON or XML format, among them there are also the lat lng of the place and its address with which you can easily locate the map
google developer doc
The URL for a specific Google Place is returned by the places details API endpoint.
If for example you query:
https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJV2BQ4laeekgRFauLvdXbFXE&key=YOUR_API_KEY
You will see that in the returned JSON there is a key 'url' which points to https://maps.google.com/?cid=8148660811851344661
The correct format, at this time, to produce a general link that goes directly to correct google place is: https://maps.google.com/?cid=[place_id]&t=[maptype]
The map type parameter "t" is apparently necessary. Without it, google maps seems to perform a more general search when the link opens that is sometimes successful and sometimes not. With it, maps opens to correct place each time whether it opens in browser or in app on mobile.
Set this parameter to "m" for a street map and "k" for a satellite map.
A lot of answers on SO show the following syntax which often pulls unwanted results if two locations of the same name are nearby e.g.:
https://www.google.com/maps/place/Starbucks/#43.088554,-88.06579,17z/
If you are already using google places api, then you have the place_id, so i recommend using it to avoid ambiguity.

Google map search using KML

i am using google map kml field (direct iframe code from gmap)
for showing different locations/shops on map:
Google map #my site,
i need to add a search box from where user can search nearest shops to his/her location...
can any body help me in this out..
It is my understanding that the API does not provide support for searching your provided KML:
google maps API geocode finds nearby KML
Google provides a service called placesService ( https://developers.google.com/maps/documentation/javascript/places ) which lets you make requests to their database of content and return results in the form of KML near a location within some bounded area - but to my knowledge you cannot specify the source to search. (You could try testing the placesService, with a KML layer set on your map and see if it includes your data).
Assuming you are generating your KML from a database, can you could regenerate it appropriately filtered or styled based on the user's search terms. This seems the most likely solution without additional details.
I have done google map search with python. But this one searches hospitals
You need to get google place api and place in code and reconfigure for search,
it will print out name, location address, and website
https://github.com/rockcastle/GoogleMap-Scrapping

Google Maps - Places library - Search for custom placed markers in radius

I'm developing a app that makes use of the Gmaps Places library and actually, I have two questions:
1) Does anyone know how long it takes to an added place(by POST request) to show up on the map? I only need it on the app's map, so I don't care if Google doesn't approve it. I've already sent the add request and received OK as response.
2) It is possible to search for markers, placed by me, as if they were places(and using radius)? Not necessarily using the Places library. I ask this to see if is possible to come with a backup plan if the waiting mentioned above is long(clients, clients...). Then I would have the places 'offline from Gmaps', mapped inside a JSON file.
If I understand you correctly, you want to combine Google's Places API with a custom location set? Without more detail I can't really tell you what the code would look like, but you'd basically want to mash up the results you get from places with your own data and place markers based on that merge. If you're searching by radius or polygon you can do a 'within bounds' search on your dataset and return any results that are within the search zone to feed into your marker creator.

How to Extract Transit Stop locations from Google Maps?

I'm building an application that requires the name, long, and lat for the transit stops in my area.
Google Maps API displays this information, but in this scenario I can't use the API and need to extract this information to an XML format.
I'm not sure if this is possible and can't find any reference to this on the web.
Any Ideas how I can extract the transit stop long, lat, and name from Google Maps, preferably to an XML format?
Now it's possible to get this done, check this post:
Detect the nearest transit stop from the given location
And if you want to see it in action try this jsfiddle:
http://jsfiddle.net/doktormolle/aZrvs/