调用高德地图

1.调用高德地图

(1)第一种方式:

AMapRouteConfig *config = [AMapRouteConfig new];

config.appName = [self getApplicationName];

config.appScheme = [self getApplicationScheme];

config.startCoordinate = AMapCoordinateConvert( CLLocationCoordinate2DMake(_locService.userLocation.location.coordinate.latitude, _locService.userLocation.location.coordinate.longitude), AMapCoordinateTypeBaidu);

config.destinationCoordinate = AMapCoordinateConvert(CLLocationCoordinate2DMake([_model.latitude doubleValue], [_model.longitude doubleValue]), AMapCoordinateTypeBaidu);

config.routeType = AMapRouteSearchTypeWalking;

if (![AMapURLSearch openAMapRouteSearch:config]) {

[Tool MBProgressHUDWithTitle:@"没安装高德地图" OffsetY:kScreenWidth / 3 DelayTime:1.0f];

}

(2)第二种方式

// m 驾车:0:速度最快,1:费用最少,2:距离最短,3:不走高速,4:躲避拥堵,5:不走高速且避免收费,6:不走高速且躲避拥堵,7:躲避收费和拥堵,8:不走高速躲避收费和拥堵 公交:0:最快捷,2:最少换乘,3:最少步行,5:不乘地铁 ,7:只坐地铁 ,8:时间短 是

// t = 0:驾车 =1:公交 =2:步行

NSString *url = [[NSString stringWithFormat:@"iosamap://path?sourceApplication=applicationName&sid=BGVIS1&slat=%f&slon=%f&sname=%@&did=BGVIS2&dlat=%f&dlon=%f&dname=%@&dev=0&m=0&t=0",_locService.userLocation.location.coordinate.latitude, _locService.userLocation.location.coordinate.longitude, handleHelper.address, [_model.latitude doubleValue], [_model.longitude doubleValue],_model.address] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

if ([[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]])

{

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

}

else

{

[Tool MBProgressHUDWithTitle:@"没安装高德地图" OffsetY:kScreenWidth / 3 DelayTime:1.0f];

}

你可能感兴趣的:(调用高德地图)