Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Maps iOS SDK - Search for places

I'm new to both iOS programming & the Google Maps iOS SDK, so apologies if this is a basic question.

I want to include a Google map, in an app and give users the ability to search for various places (restaurants, bars, gyms, etc) within a certain radius of a marker.

I know this is possible using the javascript api, but can it be done using the maps iOS SDK? I have read all of the information here and have searched Stack Overflow & Google but I can't really find anything that gives me any pointers.

Within the documentation, Google say that using a URL Scheme you can launch a native iOS app and pass in parameters for searches, directions etc. Is this what I need to be using, or is that more tailored to a webapp?

Any help, advice, or pointers to tutorials (other than the ones provided by Google) would be massively appreciated.

Cheers

like image 930
Jim Avatar asked Feb 25 '13 21:02

Jim


People also ask

Is Google Maps iOS SDK free?

The Maps SDK for iOS uses a pay-as-you-go pricing model.

Where do I get google Places API key iOS?

Go to the Google Maps Platform > Credentials page. On the Credentials page, click Create credentials > API key. The API key created dialog displays your newly created API key. Click Close.


1 Answers

The Google Maps URL Scheme can currently only be used to open the Google Maps app to search for a location or for directions. It can't search for places. Also, if your own app did this, then it would shut down your app and switch to the maps app, which may not be what you want. It will also only work if the user has installed the Google Maps app.

You would probably want to use the Google Places API to make http requests from your native app. You can request a response in either JSON or XML format. Then you'll need to parse the response, and use it to add markers to a GMSMapView using the Google Maps SDK for iOS.

This blog post describes this library which the blog post's author wrote to wrap the Google Places API. You wouldn't need most of this code, but it might give you an idea of where to start. This class is the main one which handles the requests to the places API.

Note that this library uses a third-party JSON parser - SBJsonParser. As of version 5.0 iOS includes a native JSON parser, NSJSONSerialization. So if your app's minimum supported iOS version is 5.0 or higher, you don't need to use a third-party library.

like image 64
Saxon Druce Avatar answered Oct 21 '22 02:10

Saxon Druce