1

我正在编写一个包含各种场所信息的应用程序。我想为用户提供从 Apple 地图应用程序打开位置信息屏幕的能力。我知道如何让应用程序使用如下代码打开一个 MKMapItem:

- (void) showMoreInfoFor:(MKPlacemark*) destination {
    MKLocalSearchRequest* searchRequest = [[MKLocalSearchRequest alloc] init];
    searchRequest.naturalLanguageQuery = self.venue.name;
    MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(destination.coordinate, 50.0f, 50.0f);
    searchRequest.region = region;
    MKLocalSearch* search = [[MKLocalSearch alloc] initWithRequest:searchRequest];
    [search startWithCompletionHandler:^(MKLocalSearchResponse *response, NSError *error) {
        if ([response.mapItems count] > 0) {
            [[response.mapItems objectAtIndex:0] openInMapsWithLaunchOptions:nil];
        }
    }];
}

(我也尝试过跳过本地搜索,直接使用地标创建一个新的 MKMapItem destination,结果完全相同。)

但是,这会将用户带到如下所示的屏幕:

带有地标图钉的地图屏幕

我希望用户直接进入以下屏幕,而不是要求用户点击地标上的披露指示符。

地图业务信息屏幕

我也尝试过使用 Apple 地图链接(根据Apple URL Scheme Reference for Map Links),如下所示:

NSString* url = [NSString stringWithFormat:@"http://maps.apple.com/?sll=%f,%f&q=%@", destination.coordinate.latitude, destination.coordinate.longitude, [self.venue.name stringByReplacingOccurrencesOfString:@" " withString:@"+"]];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];

但这会将用户带到类似于上面第一个屏幕的屏幕,除了在许多情况下,它显示的图钉与 URL 中指定的纬度/经度相去甚远(例如,在完全不同的城市中)。它也不会深入到位置信息屏幕。

是否可以从 iOS 应用程序导航到 Apple Maps 应用程序,直接进入业务/位置信息屏幕,如上面第二个屏幕截图所示?

4

0 回答 0