为 iOS 设备外部地图应用程序提供一个接口。
#import <TPDMapsApp/TPDMapsApp.h>
...
NSArray *installedApps = [TPDMapsApp installedMapsApps];
TPDMapsApp *app = [installedApps firstObject];
NSLog(%"Using map app: %@", app.name);
BOOL opened = app.openWithQuery(@"Philz Coffee");
if (! opened) {
// Something went wrong...
}
opened = app.openForDirectionsWithStart:@"1 Stockton St, San Francisco, CA"
destination:@"3101 24th St, San Francisco, CA"
travelMode:TPDMapsAppTravelModeTransit];
if (! opened) {
// Something went wrong...
}
使用 CocoaPods。
$ edit Podfile
pod 'TPDMapsApp', '~> 1.1.0'
$ pod install
$ open App.xcworkspace
然后您需要更新应用程序的 Info.plist
,如下所述:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>comgooglemaps</string>
<string>waze</string>
</array>
TPDMapsApp 在 MIT 许可证下可用。有关更多信息,请参阅 LICENSE 文件。