调用高德地图

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];

}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容