在iOS地图中搜索附近 [英] Search nearby in iOS Maps
问题描述
我正在尝试使用MapKit构建一个简单的应用程序,该应用程序将在应用程序启动时自动搜索特定位置,并在地图上的位置放置引脚。我看到了各种方法来加载位置(lat / lon等),但没有任何东西可以让我搜索特定的商家名称,餐馆名称等。
I am trying to build a simple application using MapKit that will automatically search for a specific place when the app launches and drop pin(s) on the map at the locations(s). I am seeing all sorts of ways to load locations (lat/lon, etc), but nothing that lets me search for a specific business name, restaurant name, etc.
我期待与Apple Maps合作。但是,如果谷歌地图是一个比它更好的解决方案。
I am expecting to work with Apple Maps. However, if Google Maps would be a better solve than so be it.
任何帮助将不胜感激。谢谢
Any help would be appreciated. Thanks
推荐答案
iOS> = 6.1提供 MKLocalSearch , MKLocalSearchRequest 搜索自然语言兴趣点。样本
iOS >= 6.1 provides MKLocalSearch, MKLocalSearchRequest to search for natural language points of interest. Sample
MKLocalSearchRequest *request = [[MKLocalSearchRequest alloc] init];
request.region = regionToSearchIn;
request.naturalLanguageQuery = @"restaurants"; // or business name
MKLocalSearch *localSearch = [[MKLocalSearch alloc] initWithRequest:request];
[localSearch startWithCompletionHandler:^(MKLocalSearchResponse *response, NSError *error) {
// do something with the results / error
}];
这篇关于在iOS地图中搜索附近的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!