Google Maps iOS SDK - Search for places

后端 未结 1 1429
攒了一身酷
攒了一身酷 2020-12-30 06:24

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 th

1条回答
  •  说谎
    说谎 (楼主)
    2020-12-30 06:33

    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.

    0 讨论(0)
提交回复
热议问题