Objective c 用于从数据库信息启动应用程序的Apple URL方案
我对我所经历的一个信息匮乏的问题感到非常沮丧。我找不到关于我的问题的任何信息,我开始相信我不可能做我想做的事情。这是我的问题,谢谢你的阅读 我希望在我的ViewController上有一个按钮,可以从存储在Sqlite数据库表中的经度和纬度坐标打开Apple地图。我已经通过添加地图视图成功地做到了这一点。我想复制这个功能,让用户能够点击“获取方向”按钮,它会自动弹出带有结束地址设置的Apple Maps应用程序。通过使用"finishLat"和"finishLng",我能够收集数据库信息。当使用Apple URL方案时,这可能吗 这是Mapview处理信息的示例。我想从中得到的唯一部分是“finishLat”和“finishLng”。我还需要使用“运行”功能来收集正确的地址Objective c 用于从数据库信息启动应用程序的Apple URL方案,objective-c,sqlite,Objective C,Sqlite,我对我所经历的一个信息匮乏的问题感到非常沮丧。我找不到关于我的问题的任何信息,我开始相信我不可能做我想做的事情。这是我的问题,谢谢你的阅读 我希望在我的ViewController上有一个按钮,可以从存储在Sqlite数据库表中的经度和纬度坐标打开Apple地图。我已经通过添加地图视图成功地做到了这一点。我想复制这个功能,让用户能够点击“获取方向”按钮,它会自动弹出带有结束地址设置的Apple Maps应用程序。通过使用"finishLat"和"finishLng",我能够收集数据库信息。当使用
[super viewDidLoad];
CGRect bounds = self.view.bounds;
mapview = [[MapView alloc] initWithFrame:CGRectMake(0, 0, bounds.size.width, bounds.size.height)];
[self.view addSubview:mapview];
NSArray *result = [_runs objectForKey:@"results"];
NSDictionary *arr = [result objectAtIndex:0];
arr = [arr objectForKey:@"run"];
NSMutableArray *arrPlaces = [[NSMutableArray alloc] init];
NSArray *arrDirvers = [arr objectForKey:@"drivers"];
for (int i =0; i < [arrDirvers count]; i++) {
NSDictionary *asdfg = [arrDirvers objectAtIndex:i];
Place *startPt = [[Place alloc] init];
Place *endPt = [[Place alloc] init];
NSString *temp = [asdfg objectForKey:@"startLat"];
startPt.latitude = [temp floatValue];
temp = [asdfg objectForKey:@"startLng"];
startPt.longitude = [temp floatValue];
startPt.name = [asdfg objectForKey:@"name"];
temp = [asdfg objectForKey:@"finishLat"];
endPt.latitude = [temp floatValue];
temp = [asdfg objectForKey:@"finishLng"];
endPt.longitude = [temp floatValue];
endPt.name = [asdfg objectForKey:@"name"];
[arrPlaces addObject:startPt];
[arrPlaces addObject:endPt];
}您可以创建
MKMapItem
的实例并使用openinmpswithlaunchoptions:
而不是使用openURL:
。您可以提供mklaunchoptions directions modekey
选项从用户当前位置请求方向
或者,使用
openMapsWithItems:launchOptions:
在两个已知位置之间导航。要在Apple地图应用程序中打开,请使用:
- (IBAction)GetDirections:(id)sender
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: @"http://maps.apple.com/?ll=<lattitude>,<longitude>"]];
}
-(iAction)获取方向:(id)发送方
{
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:@”http://maps.apple.com/?ll=,"]];
}
如果您想打开Apple Maps至驾驶方向屏幕,则需要使用以下url:
http://maps.apple.com/?saddr=<origin>&daddr=<destination>
http://maps.apple.com/?saddr=&daddr=
您还可以将其中一个设置为“当前%20Location”,以使用用户的当前位置
http://maps.apple.com/?saddr=<origin>&daddr=<destination>