概述
在导入高德地图的导航功能:
首先在平台上申请我们项目对应的相关的key值
其次在应用上导入的相关的jar包跟在清单文件上配置相关的key
在清单文件中配置:
调用相关方法:
AmapNaviPage.getInstance().showRouteActivity(mContext, new AmapNaviParams(null, null, new Poi(taskPlaceListBean.getTask_place_name(), p2, ""), AmapNaviType.RIDE, AmapPageType.ROUTE), null);
当然,相关的权限要提前配置清楚,具体的看高德的相关文档说明:基础功能-导航组件-开发指南-Android 导航SDK | 高德地图API
这是我调用该方法的时候,先进行一个权限判断,
public void toNavi() {
Log.d(">>>>>toNavi==", "toNavi1");
boolean permission1 = PermissionUtil.checkSelfPermission(mContext, "android.permission.ACCESS_COARSE_LOCATION");
boolean permission2 = PermissionUtil.checkSelfPermission(mContext, "android.permission.ACCESS_FINE_LOCATION");
boolean permission3 = PermissionUtil.checkSelfPermission(mContext, "android.permission.READ_EXTERNAL_STORAGE");
boolean permission4 = PermissionUtil.checkSelfPermission(mContext, "android.permission.WRITE_EXTERNAL_STORAGE");
boolean permission5 = PermissionUtil.checkSelfPermission(mContext, "android.permission.READ_PHONE_STATE");
if (!permission1 || !permission2 || !permission3 || !permission4 || !permission5) {
PermissionUtil.checkSelfPermission(ExecuteTaskActivity.
this, Manifest.permission.ACCESS_COARSE_LOCATION,
new String[]{Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION,
Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_PHONE_STATE}, "定位");
} else {
if (mCurrentLat == 0.0 || mCurrentLon == 0.0 || TextUtils.isEmpty(mCurrentAddress)) {
return;
}
if (excuteTaskModel.getResult().getTaskPlaceList() == null) return;
int currentIndex = Integer.parseInt(excuteTaskModel.getResult().getTaskZxr().getZxrTaskSort());
if (currentIndex >= excuteTaskModel.getResult().getTaskPlaceList().size()) return;
ExcuteTaskModel.ResultBean.TaskPlaceListBean taskPlaceListBean = excuteTaskModel.getResult().getTaskPlaceList().get(currentIndex);
NaviSetting.updatePrivacyShow(mContext, true, true);
NaviSetting.updatePrivacyAgree(mContext, true);
JZLocationConverter.LatLng latLng1 = new JZLocationConverter.LatLng(Double.parseDouble(taskPlaceListBean.getTask_place_latitude()), Double.parseDouble(taskPlaceListBean.getTask_place_longitude()));
latLng1 = JZLocationConverter.wgs84ToGcj02(latLng1);
latLng1 = JZLocationConverter.gcj02ToBd09(latLng1);
latLng1 = JZLocationConverter.bd09ToGcj02(latLng1);//高德导航使用gcj02坐标系
com.amap.api.maps.model.LatLng p2 = new com.amap.api.maps.model.LatLng(latLng1.latitude, latLng1.longitude);
AmapNaviPage.getInstance().showRouteActivity(mContext, new AmapNaviParams(null, null, new Poi(taskPlaceListBean.getTask_place_name(), p2, ""), AmapNaviType.RIDE, AmapPageType.ROUTE), null);
}
}
最后
以上就是妩媚大侠为你收集整理的android 地图导航开发思路出现导航不能正常的调用的情况的全部内容,希望文章能够帮你解决android 地图导航开发思路出现导航不能正常的调用的情况所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复