Google Maps iOS SDK - 搜索地点 [英] Google Maps iOS SDK - Search for places

查看:151
本文介绍了Google Maps iOS SDK - 搜索地点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对iOS编程&谷歌地图iOS SDK,如果这是一个基本问题,请致歉。



我想在应用中添加一个Google地图,并让用户能够搜索各种地点(餐厅,酒吧,健身房等)在标记的某个半径内。

我知道这可以使用javascript api,但可以使用地图iOS SDK来完成吗?我已经阅读了这里的所有信息,并已经搜索了Stack Overflow&谷歌,但我真的找不到任何指向我的东西。



在文档中,Google说使用URL Scheme可以启动本机iOS应用程序并通过在搜索的参数,方向等。这是我需要使用,还是更适合webapp?



任何帮助,建议,或指导教程(除了谷歌提供的)将得到大规模赞赏。

干杯

解决方案 div>

Google地图网址计划目前只能用于打开Goog​​le地图应用程序搜索一个位置或方向。它无法搜索地点。另外,如果你的应用程序这样做了,那么它会关闭你的应用程序并切换到地图应用程序,这可能不是你想要的。只有当用户安装了 Google地图应用时,它才会起作用。



您可能希望使用 Google Places API 向您发送http请求原生应用。您可以以JSON或XML格式请求响应。然后,您需要解析响应,并使用 GMSMapView 中/ documentation / ios / start> Google Maps SDK for iOS

此博文描述了这个图书馆是博客文章的作者写的,用于包装Google Places API。你不需要这些代码的大部分,但它可能会让你知道从哪里开始。 该课程是主要的课程它处理对位置API的请求。



请注意,该库使用第三方JSON解析器 - SBJsonParser 。从版本5.0开始,iOS包含一个本机JSON解析器, NSJSONSerialization 。因此,如果您的应用支持的最低iOS版本为5.0或更高版本,则无需使用第三方库。


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

解决方案

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.

这篇关于Google Maps iOS SDK - 搜索地点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆