简体   繁体   English

iOS 6 MKMapView搜索位置

[英]iOS 6 MKMapView Search for Places

I want to search for places such as "Apple Store", "Italian Restaurant" etc. and also for address such as "5th Ave, New York, NY, United States". 我想搜索“ Apple Store”,“ Italian Restaurant”等地方,以及“ 5th Ave,New York,NY,United States”之类的地址。

How can I search for places and set MKPlacemark for each place I find? 如何搜索地点并为找到的每个地点设置MKPlacemark?

如果您担心Google Maps API的请求限制,则可以改用一些开源Maps API,例如Nominatim API,请访问http://wiki.openstreetmap.org/wiki/Nominatim

From iOS 6.1 Apple introduced a new search API - MKLocalSearch . 从iOS 6.1开始,Apple引入了新的搜索API- MKLocalSearch You create a MKLocalSearchRequest using string and region to search in (the region is just a hint for the search, it doesn't guarantee results will fall within this region) and use this request to initialise a MKLocalSearch , which asynchronously gives you the results in an MKLocalSearchResponse object. 您使用字符串和区域创建一个MKLocalSearchRequest来进行搜索(该区域只是搜索的提示,它不保证结果会落在MKLocalSearch域内),并使用此请求初始化MKLocalSearch ,从而异步地为您提供结果一个MKLocalSearchResponse对象。 It was only introduced in january, so it has it's issues at this stage - you only ever get 10 results per search, plus some of the results are strange, but it's definitely worth checking out. 它是在一月份才引入的,因此在此阶段就存在问题-每次搜索只能获得10个结果,而且其中一些结果很奇怪,但是绝对值得一试。 There's also no way to specify the type of object (town/business/landmark etc.) you're searching for, which is a shame. 也没有办法指定您要搜索的对象类型(城镇/商业/地标等),这很遗憾。 Here's a cool tutorial . 这是一个很酷的教程 Note that the more precise the region you supply the better the results. 请注意,您提供的区域越精确,结果越好。

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

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