我将有一个坐标,我需要,例如,检查它是否在任何梅西商店或沃尔玛商店半英里之内。有没有办法做到这一点,而不存储每一个沃尔玛/梅西商店的坐标,但只使用关键字“沃尔玛”或"macys"?
发布于 2013-10-12 19:53:41
您可以使用MKLocalSearch。请注意,如果要同时搜索梅西百货和沃尔玛,您将使用两个不同的搜索对象进行两次搜索,因为正如文档中所述:
MKLocalSearch对象启动基于地图的搜索操作,并异步地将结果传递回应用程序。搜索对象设计为只执行一次搜索操作。要执行几个不同的搜索,必须创建该类的单独实例并分别启动它们。
总之,基本代码看起来类似于:
// create new search request
MKLocalSearchRequest *request = [[MKLocalSearchRequest alloc] init];
request.naturalLanguageQuery = @"Walmart";
request.region = mapView.region; // or create your `region` manually if not using a map
// initiate new search
MKLocalSearch *localSearch = [[MKLocalSearch alloc] initWithRequest:request];
[localSearch startWithCompletionHandler:^(MKLocalSearchResponse *response, NSError *error) {
for (MKMapItem *item in response.mapItems) {
// do whatever you want with the results
}];
}];https://stackoverflow.com/questions/19338227
复制相似问题