在iOS5中打开坐标为的地图应用程序
在我的应用程序中,有一个“联系我们”视图,其中有一个按钮可以打开公司地址。因此,我的代码在iOS6中运行良好,我知道它在ios5中应该有所不同,但找不到正确的方法。 这是我的密码:在iOS5中打开坐标为的地图应用程序,ios5,ios6,maps,coordinates,Ios5,Ios6,Maps,Coordinates,在我的应用程序中,有一个“联系我们”视图,其中有一个按钮可以打开公司地址。因此,我的代码在iOS6中运行良好,我知道它在ios5中应该有所不同,但找不到正确的方法。 这是我的密码: // Check for iOS 6 BOOL iOS6 = NO; Class mapItemClass = [MKMapItem class]; if (mapItemClass && [mapItemClass respondsToSelector:@selector(openMapsWith
// Check for iOS 6
BOOL iOS6 = NO;
Class mapItemClass = [MKMapItem class];
if (mapItemClass && [mapItemClass respondsToSelector:@selector(openMapsWithItems:launchOptions:)])
iOS6 = YES;
switch (buttonIndex) {
case 0:
if (iOS6)
{
// Create an MKMapItem to pass to the Maps app
CLLocationCoordinate2D coordinate =
CLLocationCoordinate2DMake(26.375561, 50.170305);
MKPlacemark *placemark = [[MKPlacemark alloc] initWithCoordinate:coordinate
addressDictionary:nil];
MKMapItem *mapItem = [[MKMapItem alloc] initWithPlacemark:placemark];
[mapItem setName:@"Industrial Projects Technologies"];
// Pass the map item to the Maps app
[mapItem openInMapsWithLaunchOptions:nil];
}
else
{
// Use the iOS 5 method
}
break;
iOS5使用此代码显示源到目标的路由
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://maps.apple.com/?daddr=%@,%@&saddr=%@,%@",latitudeOfDestinationLocation,longitudeOfDestinationLocation,latitudeOfSourceLocation,longitudeOfSourceLocation]]];
显示地图上的特定点
maps.google.com/?q=latitude,longitude
示例:maps.google.com/?q=26.375561,50.170305
您还可以参考。在iOS5中使用此代码来显示源到目标的路由
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://maps.apple.com/?daddr=%@,%@&saddr=%@,%@",latitudeOfDestinationLocation,longitudeOfDestinationLocation,latitudeOfSourceLocation,longitudeOfSourceLocation]]];
显示地图上的特定点
maps.google.com/?q=latitude,longitude
示例:maps.google.com/?q=26.375561,50.170305
您也可以参考。是的,我在文档中看到了这一点,但我没有源位置和目标位置。我只是想为一个位置显示一个位置标记。我会尝试的。我没有iOS5iPhone来验证它是否有效。但是你能相应地编辑这个问题吗?编辑我的答案很高兴能帮助你!!干杯快乐编码!!是的,我在文档中看到了这一点,但我没有源位置和目标位置。我只是想为一个位置显示一个位置标记。我会尝试的。我没有iOS5iPhone来验证它是否有效。但是你能相应地编辑这个问题吗?编辑我的答案很高兴能帮助你!!干杯快乐编码!!