Reputation: 495
A client has requested a page with a text input which takes a postcode and returns an array of local shops in the area.
How would I achieve this with the google maps API or something similar, this is the first time I have come across such a demand and a push in the right direction would be very helpful.
Thanks, Dan
Upvotes: 6
Views: 2783
Reputation: 15961
I'm not entirely certain about how to do this in Google Maps completely, but you can get the details of a place (including the all important longitude and latitude) very easily through the Geocoding API.
For example: http://maps.googleapis.com/maps/api/geocode/json?address=WC1&sensor=false
Although you are able to put addresses, rather than postcodes in there. You could then use this information with your own database of places. For example, you can download the GeoNames database and use something like this answer to find the closest places in your database.
Alternatively, you can use something like the FourSquare API to get a list of places in the area. You could even use the service to pull features like the tips or who is around. When I was looking for the Geocode API, I stumbled upon the Google Places API. I haven't used it and it's in developer preview at the moment, but the documentation looks interesting at least.
You might want to just check the TOS on whatever service you use. I remember at one stage that you couldn't use the map API if you're not displaying a map on the page, etc.
Upvotes: 3