Obtain list of My Places from Google Maps

Multi tool use
Multi tool use


Obtain list of My Places from Google Maps



I am trying to obtain the list of places the user has saved on Google Maps. Now I know there isnt an API for this (for whatever reason), but I saw here:



"My Places" Google Maps API



That apparently there used to be a way to obtain the URL, but it does not seem to work with my list of places.



E.g.



https://www.google.com/maps/@46.889424,0.1194148,6z/data=!4m3!11m2!2s1KbZtik1IdXyNhwfXEb3P9vaZvzU!3e3



Does not seem to work if I append &output=kml or &output=json



I created this list on Google Maps, then hit share and obtained that link.



I even tried parsing the resulting HTML but it seems everything is handled by some Javascript Engine and I can't find any reference to Google Ids there --- I dont even know how they handle clicks!



Any help? There must be a way to retrieve this information programmatically!



EDIT:



I managed to get something working by visiting the shared link, then processing the html and storing the window.APP_INITIALIZATION_STATE variable. I then convert it to an javascript array and loop over it. Deep inside the array/map structure, I managed to get the google name and google place id out of that array. That seems to work a bit, but when trying with lists over 20 items long, google only gets the first 20 and is waiting for the user to 'scroll down' to get the next 20. That seems to trigger another call to get the next 20 results and looks a bit like:


window.APP_INITIALIZATION_STATE



https://www.google.com/search?tbm=map&fp=1&authuser=0&hl=en&gl=nl&pb=!4m8!1m3!1d54065472.4384380........



I can see the original feature id being included at the end of the url, but have no idea how to construct this url in full though to get the next 20 items.... Any ideas?




2 Answers
2



Your saved places list actually has what you call a feature ID attribute, this isn't a common practice and Google frowns upon this technique but take a look at this URL:



https://www.google.com/maps/preview/entity?authuser=0&hl=en&gl=us&pb=!1m10!1s0x0%3A0x3743ae09a161976b!3m8!1m3!1d14318.72623152007!2d-98.2296425!3d26.2070353!3m2!1i1024!2i768!4f13.1!12m3!2m2!1i392!2i106!13m57!2m2!1i203!2i100!3m2!2i4!5b1!6m6!1m2!1i86!2i86!1m2!1i408!2i200!7m42!1m3!1e1!2b0!3e3!1m3!1e2!2b1!3e2!1m3!1e2!2b0!3e3!1m3!1e3!2b0!3e3!1m3!1e8!2b0!3e3!1m3!1e3!2b1!3e2!1m3!1e9!2b1!3e2!1m3!1e10!2b0!3e3!1m3!1e10!2b1!3e2!1m3!1e10!2b0!3e4!2b1!4b1!9b0!14m3!1snyc5W-WeHY3r5gLwkoRI!7e81!15i10112!15m19!2b1!5m4!2b1!3b1!5b1!6b1!10m1!8e3!14m1!3b1!17b1!24b1!25b1!26b1!30m1!2b1!36b1!52b1!53b1!21m28!1m6!1m2!1i0!2i0!2m2!1i458!2i768!1m6!1m2!1i974!2i0!2m2!1i1024!2i768!1m6!1m2!1i0!2i0!2m2!1i1024!2i20!1m6!1m2!1i0!2i748!2m2!1i1024!2i768!22m1!1e81!29m0!30m1!3b1



Highlighted is the feature ID from the link you posted:
https://www.google.com/maps/@46.889424,0.1194148,6z/data=!4m3!11m2!2s1KbZtik1IdXyNhwfXEb3P9vaZvzU!3e3



Along with other maps parameters; when you hit that link you're actually manually triggering the same callback that Google's own scripts in maps use to parse the data to feed back to the maps UI; if you look at array item 2, or {c:..} you'll find a stringified array with the contents of your list, now depending on the program language you're using all it takes is a little tweaking (find/replace, loop through, lint and trim, etc.) to this array and you can pull your results; the cool thing is if you add or remove a place the next time you hit that end point it's updated in real-time.



Some people may call it a "hack"; but it gets the job done. :)



Hope I pointed you to a direction in the event you haven't found a solution; give this a shot.



Note the URL has to be pasted in its entirety, SO truncated the hyperlink; copy and paste the whole thing in one shot and a text file from Google with the arrays will be produced; in my case I curl the URLs I need and parse the returned strings as needed to pull data from Google where their API has limitations. Just a tip. :)





thanks for your help, this is a good approach -- I've managed to get something out of the url, I've edited the question to reflect that
– Gabriel Sanmartin
2 days ago





You welcome, it took me some time myself to figure it out. If you want to pass through pagination; Google by default displays 20 results page page in the Maps Places viewer UI. Your URL needs extra parameters to skip from page to page, it will be the same feature ID but you will need to modify the string for each 20 results by including &tch=1&ech=2 (next 20, 20 through 40), &tch=1&ech=3 (next 20 - 40 through 60); the ech parameter is the pagination indicator, give it a shot.
– Ilan P
2 days ago



This was the only API was able to find was this:


https://www.google.com/bookmarks/?output=xml



Used in a browser you would have to first log in through Google's OAuth. It would then return your saved places. Not sure at the moment how you would embedded the authentication to do this programmatically, but this might send you in the right direction.





this is a good effort, however this is just returning "starred" places, whilst now you can save in multiple lists. Still, its the best I've seen
– Gabriel Sanmartin
Jul 1 at 20:35






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

g2Z lyRa Gx7Im,FI 8PmGkyxj17H LYk 5USYtN5S7Rmgkgcqh1ujCCF
4v2VnZgSk1y3ngRgxtWMPm,es2Cq rn0TIgeI3aPdzT xdRc0Ev,2oHSKvzqoM4vmd0YTk

Popular posts from this blog

Rothschild family

Cinema of Italy