How can I use Google Maps API to search both places and postcodes? - objective-c

I've been using the Google Maps Places API to do search a map for the iPhone, like in the Maps app itself. I use a line like this:
https://maps.googleapis.com/maps/api/place/search/json?location=%f,%f&rankby=distance&name=%#&sensor=true&key=%#
using NSString to enter the missing information. However, unlike the Maps app, this search only works for local places and not for postcodes or other information. It would appear that if I want it to accept postcodes, I have to create a geocode request:
https://maps.googleapis.com/maps/api/geocode/json?address=W1A+1AA&sensor=true
But then of course, this doesn't search place information. Like the Maps app, I want my app to seamlessly return the best results of both.
Before I go ahead and code it so that it uses two separate APIs, is there a better way of doing this? Should I be using a different API that works more like the search in the Maps app?

I've looked into this for something like looking into a specific service, let's say sushi, at a zip code for those who don't want to use location services. Unfortunately, it seems like you have to make two calls, one for geocoding and the other through Google Places to get the locations that are within the radius of the coordinates given in the geocoding call.
See:
Find all parks for a given zipcode with google maps
and
https://groups.google.com/forum/?fromgroups#!msg/google-places-api/P3iDK5kO7OM/Cek4BzeXMA4J

Related

How can I save or get data about places near me without breaking policies

This is more of a general programming question.
I'm trying to create an app, think of it as a Yelp clone. I have most of it working but I'm missing one important feature. The data of the places around me. For now I'm only focused on food, so I'd like it if I search something like "Pizza", it'd show me all the pizza joints near me.
I was originally planning to use Google Places API. However if you havent heard, they're changing their pricing and lowering the free tier and upping the cost by a huge margin.
There's also the problem of saving the data. One workaround I saw a user suggest was to just keep using Google's API, but every time you make the query, store the data in your own DB as well (I only need address and name and latitude and longitude) so eventually, you'd have what you need in a sense. However I also want to have something like a simple rating system for each place like Yelp, but Google (and all other places like MapBox, Here Maps, etc) states something along the lines of "info from their API should not be stored or cached for more than 24hrs" but it's very broad and not specific.
So what I was planning to do was, call the Google API, grab the 3 info I need (Address, Name, Lat/Lng), add more fields to store the rating, likes, whatever else the user will add. Then store it in my database, but that doesn't seem like a solution now.
So does anyone have any ideas or advice? Or know of a service where I can get the details of all the food places? And if possible, can anyone confirm that storing the Name, Address, Lat&Lng is a violation of their policy since in my eyes, it's public data, but something like the rating that Google provides, or the pictures that Google provides, now that's Google property.
For obtaining places you can use OpenStreetMap, e.g. using Overpass API. Since larger traffic can be expected you should run your own database(s) instead of using the public APIs.
However OSM doesn't contain ratings. So you have to combine this data with some other publicly available rating system.

API for searching for specific places by proximity

I would like to return specific places (stores like Target, Macy's, etc.) by location (latitude, longitude).
I have been using the google places api and entering the different stores in the name parameter. The results are inconsistent at best.
Is this the api I should be using to return specific stores by name and proximity? The google places api near by search has only a single name parameter. I would ideally like to search for several specific stores in a single request to the endpoint for performance reasons.
In conclusion
What api should I be using to return specific stores by name and proximity?
The Google Places API is the correct Google API to use; however, as you mentioned it does not support multiple name or keyword parameters. There is an active Places API - Feature Request for this here, please star it if you wish to see it resolved and to be notified of future changes.
Instead of using the name parameter, try using the keyword parameter. The keyword parameter is matched against all available fields, including but not limited to name, type, and address, as well as customer reviews and other third-party content. This can often yield more or better results.
It seems as if the foursquare api does let you search for multiple specific places.
Here is an example url that does the trick:
https://api.foursquare.com/v2/venues/search?ll=34.017717,-118.159335&query=Target Victoria's Secret Macy's &intent=browse&radius=16094&oauth_token=mytoken
g
So I'm abandoning Google Places and going with FourSquare.

Google Maps Web site and API : different results

Why do calls to the Google Maps Geocoder API return different results than what I see in my browser?
This one returns many items :
http://maps.google.fr/maps?q=McDonald,+paris
This one returns a ZERO_RESULT :
http://maps.googleapis.com/maps/api/geocode/xml?McDonald,+paris&sensor=false
FAQ: https://developers.google.com/maps/faq#geocoder_differences
The API geocoder finds postal addresses. The Maps geocoder uses lots of data, including business data, to find results.
There is the Places API which can find locations based on type/class, but it may not work for business names. Documentation

limit address search by distance

I recently joined a team working on an application that maintains listings with addresses. The user searches, and includes their zipcode, and the application displays the distance to each listing. Currently we use the Google Maps API for this. Reading through questions here on StackOverflow seem to suggest that this is the best way of doing things:
php/mysql zip code proximity search
Search engine by distance
However, while reading through the API documentation, this seems to be expressly forbidden unless we also show a map for each result (and possibly also for each result we filter out, depending on how you read the following statement):
Use of the Distance Matrix API must relate to the display of information on a Google Map; for example, to determine origin-destination pairs that fall within a specific driving time from one another, before requesting and displaying those destinations on a map. Use of the service in an application that doesn't display a Google map is prohibited.
( https://developers.google.com/maps/documentation/distancematrix/ )
What's the best way to accomplish this without running afoul of any API terms?
do you consider the Geo::PostalCode module (perl)? It uses maxmind database to calculate distances between locations (and there is bind in different languages).

google places - Get a list of street addresses from a lat/long

I need to be able to search for addresses within the radius of 500M-1000M from a lat-long. Google places seems to be able to do this and give it to me in JSON which is awesome, but it is only returning businesses and establishments. I want every postal address in this radius. I have tried adding:
&types=street_address but it returns no results.
Is this possible and has anyone got any info on how to do this.
Have you tried the Google Maps API Web Services
- in the Viewport Biasing section you can set bounds.