百度地图no result available_【整理之路二】百度地图的路径规划和调用本机地图导航...

推荐看完之后注意一下最后的东西

一、细说百度地图的路径规划

路径规划主要有这么几种

1.公交路径规划

1.1 市内公交规划(暂时不在这里说)

1.2 跨市/省公交规划

// 导入头文件

#import <BaiduMapAPI_Search/BMKSearchComponent.h>

#import <BaiduMapAPI_Map/BMKPolylineView.h>

#import <BaiduMapAPI_Utils/BMKGeometry.h>

#pragma mark: - 公交路线

- (void)showBusSearch {

//线路检索节点信息

BMKPlanNode *start = [[BMKPlanNode alloc] init];

Ingyenes emailcím start.pt domainnel = self.userLocation.location.coordinate;

start.cityName = @"南宁";

BMKPlanNode *end = [[BMKPlanNode alloc] init];

// 108.296699,22.842406

CLLocationCoordinate2D endCoordinate = CLLocationCoordinate2DMake(22.842406, 108.296699);

Ensaios não destrutivos e controlo de qualidade = endCoordinate;

end.cityName = @"南宁";

BMKMassTransitRoutePlanOption *drivingRouteSearchOption = [[BMKMassTransitRoutePlanOption alloc] init];

drivingRouteSearchOption.from = start;

drivingRouteSearchOption.to = end;

BOOL flag = [_routesearch massTransitSearch:drivingRouteSearchOption];

if (flag) {

NSLog(@"%s - 设置成功!",__func__);

}else {

debugLog(@"设置失败");

}

}

/**

*返回公共交通路线检索结果(new)回调方法

*@param searcher 搜索对象

*@param result 搜索结果,类型为BMKMassTransitRouteResult

*@param error 错误号,@see BMKSearchErrorCode

*/

- (void)onGetMassTransitRouteResult:(BMKRouteSearch*)searcher result:(BMKMassTransitRouteResult*)result errorCode:(BMKSearchErrorCode)error {

debugLog(@"公交方案-%@",result.routes);

if (error == BMK_SEARCH_NO_ERROR) {

for (int i = 0; i < result.routes.count; i++ ) {

BMKMassTransitRouteLine *massTransitRouteLine = result.routes[i];

// 保存换乘说明

NSMutableArray *instructions = [NSMutableArray array];

// 换乘的交通工具

NSMutableArray *stepTypes = [NSMutableArray array];

// 价格信息

debugLog(@"价格-%f",massTransitRouteLine.price);

debugLog(@"时间分钟-%d",massTransitRouteLine.duration.minutes);

debugLog(@"起点-%@",massTransitRouteLine.starting.title);

debugLog(@"终点-%@",massTransitRouteLine.terminal.title);

debugLog(@"路段方案%@",massTransitRouteLine.steps);

// 所有路段的信息

for ( int j = 0; j < massTransitRouteLine.steps.count; j++) {

BMKMassTransitStep *step = massTransitRouteLine.steps[j];

debugLog(@"%@",step.steps);

for ( int k = 0; k< step.steps.count; k++) {

BMKMassTransitSubStep *subStep = step.steps[k];

debugLog(@"换乘说明-%@",subStep.instructions);

[instructions addObject:subStep.instructions];

debugLog(@"路段类型-%u",subStep.stepType);

if(subStep.stepType != 5) { // 5为步行

if (subStep.vehicleInfo.name) {

[stepTypes addObject:subStep.vehicleInfo.name];

}

}

// 当路段为公交路段或地铁路段时,可以获取交通工具信息

debugLog(@"交通工具信息-%@",subStep.vehicleInfo.name);

}

}

}

}

}

#### 2.驾车路径规划

#pragma mark 驾车路线

-(void)showDriveSearch {

//线路检索节点信息

BMKPlanNode *start = [[BMKPlanNode alloc] init];

Ingyenes emailcím start.pt domainnel = self.userLocation.location.coordinate;

start.cityName = @"南宁";

BMKPlanNode *end = [[BMKPlanNode alloc] init];

CLLocationCoordinate2D endCoordinate = CLLocationCoordinate2DMake(22.842406, 108.296699);

Ensaios não destrutivos e controlo de qualidade = endCoordinate;

end.cityName = @"南宁";

BMKDrivingRoutePlanOption *drivingRouteSearchOption = [[BMKDrivingRoutePlanOption alloc] init];

drivingRouteSearchOption.from = start;

drivingRouteSearchOption.to = end;

BOOL flag = [_routesearch drivingSearch:drivingRouteSearchOption];

if (flag) {

NSLog(@"%s - 设置成功!",__func__);

}else {

debugLog(@"设置失败");

}

}

#pragma mark 返回驾乘搜索结果

- (void)onGetDrivingRouteResult:(BMKRouteSearch*)searcher result:(BMKDrivingRouteResult*)result errorCode:(BMKSearchErrorCode)error {

if (error == BMK_SEARCH_NO_ERROR) {

for (int i = 0; i < result.routes.count; i++) {

NSMutableArray *instruction = [NSMutableArray array];

NSMutableArray *waypoints = [NSMutableArray array];

//表示一条驾车路线

BMKDrivingRouteLine *plan = result.routes[i];

for (int k = 0; k < plan.wayPoints.count; k++) {

BMKPlanNode *node = plan.wayPoints[k];

[waypoints addObject:node.name];

}

for (int j = 0; j < plan.steps.count; j++) {

//表示驾车路线中的一个路段

BMKDrivingStep* transitStep = [plan.steps objectAtIndex:j];

[instruction addObject:transitStep.instruction];

}

}

}

}

#### 3.步行路径规划

#pragma mark: - 步行

- (void)showWalkSearch {

//线路检索节点信息

BMKPlanNode *start = [[BMKPlanNode alloc] init];

Ingyenes emailcím start.pt domainnel = self.userLocation.location.coordinate;

start.cityName = @"南宁";

BMKPlanNode *end = [[BMKPlanNode alloc] init];

CLLocationCoordinate2D endCoordinate = CLLocationCoordinate2DMake(22.842406, 108.296699);

end.pt = endCoordinate;

end.cityName = @"南宁";

BMKWalkingRoutePlanOption *drivingRouteSearchOption = [[BMKWalkingRoutePlanOption alloc] init];

drivingRouteSearchOption.from = start;

drivingRouteSearchOption.to = end;

BOOL flag = [_routesearch walkingSearch:drivingRouteSearchOption];

if (flag) {

NSLog(@"%s - 设置成功!",__func__);

}else {

debugLog(@"设置失败");

}

}

/**

*返回步行搜索结果

*@param searcher 搜索对象

*@param result 搜索结果,类型为BMKWalkingRouteResult

*@param error 错误号,@see BMKSearchErrorCode

*/

- (void)onGetWalkingRouteResult:(BMKRouteSearch*)searcher result:(BMKWalkingRouteResult*)result errorCode:(BMKSearchErrorCode)error {

debugLog(@"步行方案--%@",result.routes);

if (error == BMK_SEARCH_NO_ERROR) {

for (int i = 0; i < result.routes.count; i++) {

NSMutableArray *instructions = [NSMutableArray array];

BMKWalkingRouteLine *walkingRouteLine = result.routes[i];

//debugLog(@"途径 ---%@", walkingRouteLine.wayPointPoiList);

debugLog(@"路线长度 -- %d", walkingRouteLine.distance);

debugLog(@"需要花费的时间 %d",walkingRouteLine.duration.minutes);

for (int j = 0; j < walkingRouteLine.steps.count; j++) {

BMKWalkingStep *step = walkingRouteLine.steps[j];

debugLog(@"入口信息 -- %@",step.entraceInstruction);

debugLog(@"出口信息 -- %@",step.exitInstruction);

debugLog(@"指示信息 -- %@",step.instruction);

[instructions addObject:step.instruction];

}

}

}

}

#### 4.骑车路径规划(暂时不总结)

#### 5.根据路径规划划线

- (void)showCarRoutePlan {

// 计算路线方案中的路段数目

int size = (int)[self.drivingRouteLine.steps count];

BMKDrivingRouteLine *plan = self.drivingRouteLine;

int planPointCounts = 0;

for (int i = 0; i < size; i++) {

//表示驾车路线中的一个路段

BMKDrivingStep* transitStep = [plan.steps objectAtIndex:i];

if(i==0){

RouteAnnotation* item = [[RouteAnnotation alloc]init];

item.coordinate = plan.starting.location;

item.title = @"起点";

item.type = 0;

[_mapView addAnnotation:item]; // 添加起点标注

}else if(i==size-1){

RouteAnnotation* item = [[RouteAnnotation alloc]init];

item.coordinate = plan.terminal.location;

item.title = @"终点";

item.type = 1;

[_mapView addAnnotation:item]; // 添加终点标注

}

//添加annotation节点

RouteAnnotation* item = [[RouteAnnotation alloc]init];

item.coordinate = transitStep.entrace.location;

item.title = transitStep.entraceInstruction;

item.degree = transitStep.direction * 30;

item.type = 4;

[_mapView addAnnotation:item];

//轨迹点总数累计

planPointCounts += transitStep.pointsCount;

}

// 添加途经点

if (plan.wayPoints) {

for (BMKPlanNode* tempNode in plan.wayPoints) {

RouteAnnotation* item = [[RouteAnnotation alloc]init];

item.coordinate = tempNode.pt;

item.type = 5;

item.title = tempNode.name;

[_mapView addAnnotation:item];

}

}

//轨迹点

BMKMapPoint * temppoints = new BMKMapPoint[planPointCounts];

int i = 0;

for (int j = 0; j < size; j++) {

BMKDrivingStep* transitStep = [plan.steps objectAtIndex:j];

int k=0;

for(k=0;k<transitStep.pointsCount;k++) {

temppoints[i].x = transitStep.points[k].x;

temppoints[i].y = transitStep.points[k].y;

i++;

}

}

// 通过points构建BMKPolyline

BMKPolyline* polyLine = [BMKPolyline polylineWithPoints:temppoints count:planPointCounts];

[_mapView addOverlay:polyLine]; // 添加路线overlay

delete []temppoints;

[self mapViewFitPolyLine:polyLine];

}

- (void)showBusRoutePlan {

BMKMassTransitRouteLine *routeLine = self.massTransitRouteLine;

BOOL startCoorIsNull = YES;

CLLocationCoordinate2D startCoor;//起点经纬度

CLLocationCoordinate2D endCoor;//终点经纬度

NSInteger size = [routeLine.steps count];

NSInteger planPointCounts = 0;

for (NSInteger i = 0; i < size; i++) {

BMKMassTransitStep *transitStep = [routeLine.steps objectAtIndex:i];

for (BMKMassTransitSubStep *subStep in transitStep.steps) {

//添加annotation节点

RouteAnnotation *item = [[RouteAnnotation alloc]init];

item.coordinate = subStep.entraceCoor;

item.title = subStep.instructions;

item.type = 2;

[_mapView addAnnotation:item];

if (startCoorIsNull) {

startCoor = subStep.entraceCoor;

startCoorIsNull = NO;

}

endCoor = subStep.exitCoor;

//轨迹点总数累计

planPointCounts += subStep.pointsCount;

//steps中是方案还是子路段,YES:steps是BMKMassTransitStep的子路段(A到B需要经过多个steps);NO:steps是多个方案(A到B有多个方案选择)

if (transitStep.isSubStep == NO) {//是子方案,只取第一条方案

break;

}

else {

//是子路段,需要完整遍历transitStep.steps

}

}

}

//添加起点标注

RouteAnnotation *startAnnotation = [[RouteAnnotation alloc]init];

startAnnotation.coordinate = startCoor;

startAnnotation.title = @"起点";

startAnnotation.type = 0;

[_mapView addAnnotation:startAnnotation]; // 添加起点标注

//添加终点标注

RouteAnnotation *endAnnotation = [[RouteAnnotation alloc]init];

endAnnotation.coordinate = endCoor;

endAnnotation.title = @"终点";

endAnnotation.type = 1;

[_mapView addAnnotation:endAnnotation]; // 添加起点标注

//轨迹点

BMKMapPoint *temppoints = new BMKMapPoint[planPointCounts];

NSInteger index = 0;

for (BMKMassTransitStep *transitStep in routeLine.steps) {

for (BMKMassTransitSubStep *subStep in transitStep.steps) {

for (NSInteger i = 0; i < subStep.pointsCount; i++) {

temppoints[index].x = subStep.points[i].x;

temppoints[index].y = subStep.points[i].y;

index++;

}

//steps中是方案还是子路段,YES:steps是BMKMassTransitStep的子路段(A到B需要经过多个steps);NO:steps是多个方案(A到B有多个方案选择)

if (transitStep.isSubStep == NO) {//是子方案,只取第一条方案

break;

}

else {

//是子路段,需要完整遍历transitStep.steps

}

}

}

// 通过points构建BMKPolyline

BMKPolyline *polyLine = [BMKPolyline polylineWithPoints:temppoints count:planPointCounts];

[_mapView addOverlay:polyLine]; // 添加路线overlay

delete []temppoints;

[self mapViewFitPolyLine:polyLine];

}

- (void)showWalkRoutePlan {

BMKWalkingRouteLine *plan = self.walkingRouteLine;

NSInteger size = [plan.steps count];

int planPointCounts = 0;

for (int i = 0; i < size; i++) {

BMKWalkingStep *transitStep = [plan.steps objectAtIndex:i];

if(i==0){

RouteAnnotation *item = [[RouteAnnotation alloc]init];

item.coordinate = plan.starting.location;

item.title = @"起点";

item.type = 0;

[_mapView addAnnotation:item]; // 添加起点标注

}else if(i==size-1){

RouteAnnotation *item = [[RouteAnnotation alloc]init];

item.coordinate = plan.terminal.location;

item.title = @"终点";

item.type = 1;

[_mapView addAnnotation:item]; // 添加起点标注

}

//添加annotation节点

RouteAnnotation *item = [[RouteAnnotation alloc]init];

item.coordinate = transitStep.entrace.location;

item.title = transitStep.entraceInstruction;

item.degree = transitStep.direction *30;

item.type = 4;

[_mapView addAnnotation:item];

//轨迹点总数累计

planPointCounts += transitStep.pointsCount;

}

//轨迹点

BMKMapPoint *temppoints = new BMKMapPoint[planPointCounts];

int i = 0;

for (int j = 0; j < size; j++) {

BMKWalkingStep *transitStep = [plan.steps objectAtIndex:j];

int k=0;

for(k=0;k<transitStep.pointsCount;k++) {

temppoints[i].x = transitStep.points[k].x;

temppoints[i].y = transitStep.points[k].y;

i++;

}

}

// 通过points构建BMKPolyline

BMKPolyline *polyLine = [BMKPolyline polylineWithPoints:temppoints count:planPointCounts];

[_mapView addOverlay:polyLine]; // 添加路线overlay

delete []temppoints;

[self mapViewFitPolyLine:polyLine];

}

#pragma mark - 显示大头针

- (BMKAnnotationView *)mapView:(BMKMapView *)mapView viewForAnnotation:(id <BMKAnnotation>)annotation {

if (![annotation isKindOfClass:[RouteAnnotation class]]) return nil;

return [self getRouteAnnotationView:mapView viewForAnnotation:(RouteAnnotation *)annotation];

}

#pragma mark 获取路线的标注,显示到地图

- (BMKAnnotationView*)getRouteAnnotationView:(BMKMapView *)mapview viewForAnnotation:(RouteAnnotation*)routeAnnotation {

BMKAnnotationView *view = nil;

switch (routeAnnotation.type) {

case 0:

{

view = [mapview dequeueReusableAnnotationViewWithIdentifier:@"start_node"];

if (view == nil) {

view = [[BMKAnnotationView alloc] initWithAnnotation:routeAnnotation reuseIdentifier:@"start_node"];

view.image = [UIImage imageNamed:@"map_start"];

//[UIImage imageWithContentsOfFile:[self getMyBundlePath1:@"images/icon_nav_start"]];

view.centerOffset = CGPointMake(0, -(view.frame.size.height * 0.5));

view.canShowCallout = true;

}

view.annotation = routeAnnotation;

}

break;

case 1:

{

view = [mapview dequeueReusableAnnotationViewWithIdentifier:@"end_node"];

if (view == nil) {

view = [[BMKAnnotationView alloc] initWithAnnotation:routeAnnotation reuseIdentifier:@"end_node"];

view.image = [UIImage imageNamed:@"map_end"];

//[UIImage imageWithContentsOfFile:[self getMyBundlePath1:@"images/icon_nav_end"]];

view.centerOffset = CGPointMake(0, -(view.frame.size.height * 0.5));

view.canShowCallout = true;

}

view.annotation =routeAnnotation;

}

break;

case 4:

{

view = [mapview dequeueReusableAnnotationViewWithIdentifier:@"route_node"];

if (view == nil) {

view = [[BMKAnnotationView alloc] initWithAnnotation:routeAnnotation reuseIdentifier:@"route_node"];

view.canShowCallout = true;

} else {

[view setNeedsDisplay];

}

UIImage *image = [UIImage imageWithContentsOfFile:[self getMyBundlePath1:@"images/icon_direction"]];

view.image = [image imageRotatedByDegrees:routeAnnotation.degree];

view.annotation = routeAnnotation;

}

break;

default:

break;

}

return view;

}

#pragma mark 根据overlay生成对应的View

-(BMKOverlayView *)mapView:(BMKMapView *)mapView viewForOverlay:(id<BMKOverlay>)overlay {

if ([overlay isKindOfClass:[BMKPolyline class]]) {

BMKPolylineView* polylineView = [[BMKPolylineView alloc] initWithOverlay:overlay];

polylineView.fillColor = [[UIColor cyanColor] colorWithAlphaComponent:1];

polylineView.strokeColor = [[UIColor blueColor] colorWithAlphaComponent:0.7];

polylineView.lineWidth = 3.0;

return polylineView;

}

return nil;

}

#pragma mark 根据polyline设置地图范围

- (void)mapViewFitPolyLine:(BMKPolyline *) polyLine {

CGFloat ltX, ltY, rbX, rbY;

if (polyLine.pointCount < 1) return;

BMKMapPoint pt = polyLine.points[0];

ltX = pt.x, ltY = pt.y;

rbX = pt.x, rbY = pt.y;

for (int i = 0; i < polyLine.pointCount; i++) {

BMKMapPoint pt = polyLine.points[i];

if (pt.x < ltX) {

ltX = pt.x;

}

if (pt.x > rbX) {

rbX = pt.x;

}

if (pt.y > ltY) {

ltY = pt.y;

}

if (pt.y < rbY) {

rbY = pt.y;

}

}

BMKMapRect rect;

rect.origin = BMKMapPointMake(ltX , ltY);

rect.size = BMKMapSizeMake(rbX - ltX, rbY - ltY);

[_mapView setVisibleMapRect:rect];

_mapView.zoomLevel = _mapView.zoomLevel - 0.3;

}

// RouteAnnotation 自定义的类

/** 路线的标注*/

@interface RouteAnnotation : BMKPointAnnotation

@property (nonatomic) int type; ///<0:起点 1:终点 2:公交 3:地铁 4:驾乘 5:途经点

@property (nonatomic) int degree;

@end

@implementation RouteAnnotation

@end

#### 二、使用本机的地图导航

通常自己的手机都会安装有百度地图、高德地图、腾讯等等

* 1.实现步骤

* 1.1 添加应用白名单

<string>baidumap</string>

<string>iosamap</string>

<string>comgooglemaps</string>

<string>qqmap</string>

* 1.2 info.plist添加对应的url schemes

百度地图: baidumap://

腾讯地图: qqmap://

谷歌地图: comgooglemaps://

高德地图: iosamap://

1.3 使用的第三方框架

pod 'LCActionSheet' // 弹窗选择

pod 'JZLocationConverter' // 经纬度转换(主要解决百度地图和谷歌地图用的不是同一种标准的问题)

1.4 具体实现代码

// 引入头文件

#import <LCActionSheet/LCActionSheet.h>

#import <JZLocationConverter/JZLocationConverter.h>

#pragma mark - 导航方法

- (NSArray *)getInstalledMapApp

{

NSArray *locationArray = [self.poiMD.address_x_y componentsSeparatedByString:@","];

// lat lng

CLLocationCoordinate2D endLocation = CLLocationCoordinate2DMake([locationArray.lastObject floatValue], [locationArray.firstObject floatValue]);

NSMutableArray *maps = [NSMutableArray array];

//苹果地图

NSMutableDictionary *iosMapDic = [NSMutableDictionary dictionary];

iosMapDic[@"title"] = @"苹果地图";

[maps addObject:iosMapDic];

//百度地图

if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"baidumap://"]]) {

NSMutableDictionary *baiduMapDic = [NSMutableDictionary dictionary];

baiduMapDic[@"title"] = @"百度地图";

NSString *urlString = [[NSString stringWithFormat:@"baidumap://map/direction?origin={{我的位置}}&destination=latlng:%f,%f|name=北京&mode=driving&coord_type=gcj02",endLocation.latitude,endLocation.longitude] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

baiduMapDic[@"url"] = urlString;

[maps addObject:baiduMapDic];

}

//高德地图

if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"iosamap://"]]) {

NSMutableDictionary *gaodeMapDic = [NSMutableDictionary dictionary];

gaodeMapDic[@"title"] = @"高德地图";

NSString *urlString = [[NSString stringWithFormat:@"iosamap://navi?sourceApplication=%@&backScheme=%@&lat=%f&lon=%f&dev=0&style=2",@"导航功能",@"nav123456",endLocation.latitude,endLocation.longitude] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

gaodeMapDic[@"url"] = urlString;

[maps addObject:gaodeMapDic];

}

//谷歌地图

if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"comgooglemaps://"]]) {

NSMutableDictionary *googleMapDic = [NSMutableDictionary dictionary];

googleMapDic[@"title"] = @"谷歌地图";

NSString *urlString = [[NSString stringWithFormat:@"comgooglemaps://?x-source=%@&x-success=%@&saddr=&daddr=%f,%f&directionsmode=driving",@"导航测试",@"nav123456",endLocation.latitude, endLocation.longitude] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

googleMapDic[@"url"] = urlString;

[maps addObject:googleMapDic];

}

//腾讯地图

if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"qqmap://"]]) {

NSMutableDictionary *qqMapDic = [NSMutableDictionary dictionary];

qqMapDic[@"title"] = @"腾讯地图";

NSString *urlString = [[NSString stringWithFormat:@"qqmap://map/routeplan?from=我的位置&type=drive&tocoord=%f,%f&to=终点&coord_type=1&policy=0",endLocation.latitude, endLocation.longitude] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

qqMapDic[@"url"] = urlString;

[maps addObject:qqMapDic];

}

return maps;

}

- (void)showLCActionSheet {

NSArray *maps = [self getInstalledMapApp];

NSMutableArray *mapsA = [NSMutableArray array];

for (NSDictionary *dict in maps) {

[mapsA addObject:dict[@"title"]];

}

LCActionSheet *actionSheet = [LCActionSheet sheetWithTitle:@"请选择" cancelButtonTitle:@"取消" clicked:^(LCActionSheet * _Nonnull actionSheet, NSUInteger buttonIndex) {

debugLog(@"当前选择 --- %d",buttonIndex);

if (buttonIndex == 0) { // 当前选择了取消

return ;

}

if ((buttonIndex - 1) == 0) { // 苹果地图无论如何都是有的

[self navAppleMap];

return;

}

NSDictionary *dic = [self getInstalledMapApp][buttonIndex - 1];

NSString *urlString = dic[@"url"];

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]];

} otherButtonTitleArray:mapsA];

actionSheet.blurEffectStyle = UIBlurEffectStyleLight;

actionSheet.scrolling = YES;

actionSheet.visibleButtonCount = 3.6f;

[actionSheet show];

}

// 苹果地图

- (void)navAppleMap

{

NSArray *locationArray = [self.poiMD.address_x_y componentsSeparatedByString:@","];

// lat lng

CLLocationCoordinate2D endLocation = CLLocationCoordinate2DMake([locationArray.lastObject floatValue], [locationArray.firstObject floatValue]);

CLLocationCoordinate2D gps = [JZLocationConverter bd09ToWgs84:endLocation];

MKMapItem *currentLoc = [MKMapItem mapItemForCurrentLocation];

MKMapItem *toLocation = [[MKMapItem alloc] initWithPlacemark:[[MKPlacemark alloc] initWithCoordinate:gps addressDictionary:nil]];

NSArray *items = @[currentLoc,toLocation];

NSDictionary *dic = @{

MKLaunchOptionsDirectionsModeKey : MKLaunchOptionsDirectionsModeDriving,

MKLaunchOptionsMapTypeKey : @(MKMapTypeStandard),

MKLaunchOptionsShowsTrafficKey : @(YES)

};

[MKMapItem openMapsWithItems:items launchOptions:dic];

}

推荐

iOS学习中会感觉遇到许多难题 但是你该怎么去解决这些问题 一个学习的氛围要有 你可以在群里交流 而且我们这个群有大厂的大佬帮忙分析群里还有你想要的大厂面试题

[点击进群 密码:111](正在跳转)

74ad347158e06d513bfb315751792466.png

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/352058.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

最短路径—Dijkstra算法和Floyd算法

Dijkstra算法 1.定义概览 Dijkstra(迪杰斯特拉)算法是典型的单源最短路径算法&#xff0c;用于计算一个节点到其他所有节点的最短路径。主要特点是以起始点为中心向外层层扩展&#xff0c;直到扩展到终点为止。Dijkstra算法是很有代表性的最短路径算法&#xff0c;在很多专业课…

实现两个数的交换(异或,加减)

1、 通常我们通过设置临时变量来实现两个数的交换&#xff0c;如下&#xff1a; void swap(int *a,int *b){int temp;temp*a;*a*b;*btemp;} 2、还可以通过异或来实现两个不同整数的交换&#xff0c;如下&#xff1a; void swap(int &a,int &b){tempa^b; //设a为临…

url override and HttpSession implements session

背景 HttpSession默认使用Cookie存储Session ID&#xff0c;如果在用户禁用浏览器Cookie的功能后&#xff0c;仍打算运用HttpSession来进行会话管理&#xff0c;那么可以搭配URL重写来实现。 实现方法 使用HttpServletResponse的encodeURL()方法协助产生URL。  服务器端调用r…

怎么用python写名字_python中的__name__ 到底是个什么玩意?应该怎么用到它?

本文的文字及图片来源于网络,仅供学习、交流使用,不具有任何商业用途,版权归原作者所有,如有问题请及时联系我们以作处理以下文章来源于腾讯云 作者&#xff1a;Python进击者( 想要学习Python&#xff1f;Python学习交流群&#xff1a;1039649593&#xff0c;满足你的需求&…

用RAII技术管理资源及其泛型实现

前言 RAII的含义是“资源获取即初始化”。 一段看似安全的代码 首先看一段代码&#xff1a; try{int *p new int[100];// ... do somethingdelete[] p; }catch(exception &e){ // ..... } 这段代码中&#xff0c;我们先进行了动态内存分配&#xff0c;使…

使用Lambda在AWS云上使用Java

如今&#xff0c;Amazon Web Services越来越受欢迎。 Java是AWS的一等公民&#xff0c;它很容易上手。 部署应用程序有些不同&#xff0c;但是仍然很容易和方便。 AWS Lambda是一种计算服务&#xff0c;您可以在其中将代码上传到AWS Lambda&#xff0c;并且该服务可以使用AWS…

Lintcode--3(366)--斐波那契数列

题目&#xff1a;查找斐波纳契数列中第 N 个数。所谓的斐波纳契数列是指&#xff1a;前2个数是 0 和 1 。第 i 个数是第 i-1 个数和第i-2 个数的和。斐波纳契数列的前10个数字是&#xff1a;0,1,1,2,3,5,8,13,21... 程序&#xff1a; class Solution { public: /* * para…

nt6启动菜单自动修复工具_轻量级windows系统修复,清理工具——Dism++

收藏分享计划读完需要4分钟速读仅需 2 分钟Dism是一款操作简单&#xff0c;轻量级的系统维护工具。Dism 作为第三版清理工具更加深入系统底层&#xff0c;功能和清理效果都非常不错1 简介Dism 是由初雨团队采用微软内部 API 编写的一款开源免费的实用工具&#xff0c;最开始的名…

【日常小记】linux中强大且常用命令:find、grep

在linux下面工作&#xff0c;有些命令能够大大提高效率。本文就向大家介绍find、grep命令&#xff0c;他哥俩可以算是必会的linux命令&#xff0c;我几乎每天都要用到他们。本文结构如下&#xff1a; find命令 find命令的一般形式 find命令的常用选项及实例 find与xargs grep命…

Spring----最小化Spring配置

在Spring的配置文件中&#xff0c;我们可以使用<bean>元素定义Bean,以及使用<constructor-arg>或着<property>元素装配bean,这对于包含少量Bean的应用来说以经非常不错了&#xff0c;但是随着应用的发展&#xff0c;我们不得不编写越来越复杂的XML配置。为解…

Lintcode--2(56)--两数之和

题目&#xff1a;给一个整数数组&#xff0c;找到两个数使得他们的和等于一个给定的数 target。 你需要实现的函数twoSum需要返回这两个数的下标, 并且第一个下标小于第二个下标。注意这里下标的范围是 0 到 n-1。注意事项你可以假设只有一组答案。样例给出 numbers [2, 7, 11…

qml如何发布程序_首创PC端小程序直播发布会,360如何与手机厂商一起共振?

文 | Toby Lu全新的线上发布会形式&#xff0c;正在搅动着手机品牌营销江湖。疫情之下&#xff0c;线上发布会的形式成为手机品牌产品亮相的最佳形式&#xff0c;与传统的联合各家媒体做直播不同&#xff0c;聚焦于一个媒体平台&#xff0c;全场景、全链路的营销模式&#xff0…

CUBA Platform 6.3的新增功能

我们很自豪地宣布新版本的CUBA平台和Studio全面上市&#xff01; 也许这是有史以来功能最丰富的平台版本之一–在各个级别都有重要的变化&#xff1a;体系结构&#xff0c;可扩展性&#xff0c;API可用性和性能。 本文介绍了该平台的主要增强功能。 发行说明中提供了完整的更…

Python字符串的编码与解码(encode与decode)

首先要搞清楚&#xff0c;字符串在Python内部的表示是unicode编码&#xff0c;因此&#xff0c;在做编码转换时&#xff0c;通常需要以unicode作为中间编码&#xff0c;即先将其他编码的字符串解码&#xff08;decode&#xff09;成unicode&#xff0c;再从unicode编码&#xf…

Linux复习笔记

常用命令&#xff1a; pwd &#xff1b;cd&#xff1b; ls&#xff1b; cp&#xff1b; mv&#xff1b; rm &#xff1b;cat&#xff1b; stat&#xff1b; 01234567---r---w-rw---xr-x-wxrwx目录&#xff1a; root: 在root下: useradd mjq 创建mjq用户 passwd mjq 创建密…

Lintcode--4(1)--A+B

题目&#xff1a;给出两个整数a和b, 求他们的和, 但不能使用 等数学运算符。 说明&#xff1a; a和b都是 32位 整数么&#xff1f;是的我可以使用位运算符么&#xff1f;当然可以 样例&#xff1a;如果 a1 并且 b2&#xff0c;返回3显然你可以直接 return a b&#xff0c;但…

1w存银行一年多少利息_100万存银行一年利息多少?能赚多少钱?

100万存银行一年利息多少&#xff0c;是否可以辞掉工作什么都不做随着经济水平的提升&#xff0c;大家手上的存款也越来越多了&#xff0c;众所周知&#xff0c;将资金存放在银行是可以赚取利息收益的&#xff0c;那么如果我们有100万的存款资金后&#xff0c;一年可以获得多少…

Notepad++背景颜色设置

经常试用notepad看代码&#xff0c;白色的背景连续看的时间长了眼睛很容变花&#xff0c;所以找了相关的设置选项&#xff0c;分享给大家 具体设置步骤如下&#xff1a; 然后如下设置 这样前景色背景色已经发生改变了哟&#xff0c;下面再修改下选中行的背景色吧&#xff0c;你…

思维水题

题目链接&#xff1a;https://codeforces.com/problemset/problem/1082/A 题目意思&#xff1a; 一本书有1到n页&#xff0c;起始页数是x&#xff0c; 一次翻页只能翻d&#xff08;向前或者向后翻&#xff0c;但是不能翻出去&#xff0c;例如n5,x1 y5,d10 &#xff09; …

常用的位运算

1、按位与 & 0 & 0 0&#xff1b;0 & 1 0&#xff1b;1 & 0 0&#xff1b;1& 1 1 同时为1则结果为1&#xff0c;否则为0&#xff1b; 如3 & 8 3 00000011 5 00000101 结果为 00000001 2、按位或 || 0|00; 0|11; 1|01; 1|11; 两…