繁体   English   中英

在MKMapView中使用谷歌地图的搜索栏建议[重复]

[英]Searchbar suggestions with google maps in MKMapView [duplicate]

可能重复:
如何使用UISearchBar搜索MKMapView?

我有一个UISearchBar与MKMapView与谷歌地图。 每当我开始打字时,我都需要建议。 那么我应该为此做些什么呢? 是否有谷歌api的网络服务?

使用CLGeocoder根据字符串生成地址结果。
这称为forward geocoding
您将获得许多可以填充到UI中的地标。

http://developer.apple.com/library/ios/#documentation/CoreLocation/Reference/CLGeocoder_class/Reference/Reference.html

这里的简单示例:

NSString *address = @"Big Ben";

CLGeocoder *coder = [[CLGeocoder alloc] init];
[coder geocodeAddressString:address completionHandler:^(NSArray *placemarks, NSError *error){

     //Do something with the returned placemarks
}];

如果具体,您还可以将结果限制为设定区域,这些都记录在上面的链接中。

  1. 创建请求http://google.com/complete/search?output=toolbar&q=YOURQUERY
  2. 收到回复并解析它。
  3. 将其显示在UITableView中作为建议。

要查看完整的插图,请阅读此帖

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM