So I know that google places API serves the place information (name, location, website, type ect) with JSON but I was wondering how to grab the data from the JSON?
Basically I’ve got a site where users can use the google maps API Ive set up to search for their retail shops and Id like to store all that information in a table so that way when you go to the user’s profile page you can see their google place information on a integrated map.
Maybe theres an easier way to do that but Im not sure how.
You should only use the google places api from the client. Google has a rate limit set pretty low, and it’s based on IP address (at least for the google maps api). So if you’re making too many requests from your web server, all of a sudden google cuts you off for the day. The way around this is to just do all the calls in javascript, so it’s coming from the users IP address.
When the user types their address into your form, use the google places api to get the place id, or lat/lng coordinates, then save those along with everything else in your database. Then just use that data to fetch the place json from the google places api when they view the user profile.
Update
According to the google places docs, it’s actually the “
referencetoken” you want to store, not theid.Since you want users to be able to search for their stores, you need to make 2 queries:
referencetoken.