调起百度地图功能介绍
鸿蒙版百度地图SDK提供简单的接口用来调起百度地图客户端(Native)来实现复杂的业务逻辑。支持的调起类型有:主图、标注、反GEO、POI检索(POI详情检索、POI周边列表检索)、两框、路线规划(步行路线规划、骑行路线规划)、导航。
当手机中安装了百度地图客户端APP(版本号为1.0.0以上),开发者可以通过BaiduMapRoutePlan类中的openBaiduMapHomePage(主图)、openBaiduMapMarkerPage(标注页)、openBaiduMapGeoCoderPage(反GEO页)、openBaiduMapRoutePage(两框页)、openBaiduMapDirectionPage(路线规划页)、openBaiduMapBusNearbyPage(公交附近页),BaiduMapPoiSearch类中的openBaiduMapPoiDetailsPage(POI详情检索页)、openBaiduMapPoiSearchPage(POI列表检索页)、openBaiduMapNearbySugPage(发现周边页),BaiduMapNavigation类中的openBaiduMapNaviPage(导航) 、openBaiduMapWalkNavi(步行导航页)、openBaiduMapBikeNavi(骑行导航页)、openBaiduMapTruckNavi(货车导航页)相关方法设置调起百度地图APP。如果未传入的坐标类型,则使用百度地图SDK的全局坐标类型。
注:通用参数和接口参数参考接口说明中鸿蒙端参数说明填写(https://lbs.baidu.com/faq/api?title=webapi/uri/harmony)
import { OpenClientUtil } from '@bdmap/util'/*** 判断是否安装百度地图APP* @return 返回false代表没有安装百度地图APP*/OpenClientUtil.checkBaiduMapInstalled()
跳转到应用市场中安装百度地图app
import { OpenClientUtil } from '@bdmap/util'/*** 跳转到应用市场中安装百度地图APP* @Param context*/let context:common.UIAbilityContext = getContext(this) as common.UIAbilityContext;OpenClientUtil.openAppMarket(context)
import { CoordType } from '@bdmap/base';import { BaiduMapRoutePlan, HomePageParamModel } from '@bdmap/util';openLink() {let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;let homeParam: HomePageParamModel = new HomePageParamModel().setBounds('915291, 403857, 056858, 308194').setCoord_type(CoordType.BD09LL);try{BaiduMapRoutePlan.openBaiduMapHomePage(homeParam, context);} catch (e) {console.log('error:', JSON.stringify(e));}}
import { BaiduMapRoutePlan, MarkerPageParamModel, SrcTypeEnum } from '@bdmap/util';openLink() {let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;let markerParam: MarkerPageParamModel = new MarkerPageParamModel().setTitle('我的位置').setContent('天安门').setLocation('39.915291,116.403857').setSrc(SrcTypeEnum.PUSH);try {BaiduMapRoutePlan.openBaiduMapMarkerPage(markerParam, context);} catch (e) {console.log('error:', JSON.stringify(e));}}
import { BaiduMapRoutePlan, GeoCoderPageParamModel, SrcTypeEnum } from '@bdmap/util';openLink() {let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;let geoParam: GeoCoderPageParamModel = new GeoCoderPageParamModel().setAddress('天安门').setSrc(SrcTypeEnum.PUSH);try {BaiduMapRoutePlan.openBaiduMapGeoCoderPage(geoParam, context);} catch (e) {console.log('error:', JSON.stringify(e));}}
import { BaiduMapPoiSearch, PoiDetailPageParamModel } from '@bdmap/util';openLink() {let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;let poiParam: PoiDetailPageParamModel = new PoiDetailPageParamModel().setUid('8d96925c6ccf855cc1f1cf38');try {BaiduMapPoiSearch.openBaiduMapPoiDetailsPage(poiParam, context);} catch (e) {console.log('error:', JSON.stringify(e));}}
import { BaiduMapPoiSearch, PoiSearchPageParamModel } from '@bdmap/util';openLink() {let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;let poiLParam: PoiSearchPageParamModel = new PoiSearchPageParamModel().setQuery('学校').setLocation('39.989813,116.314094').setRadius('1000');try {BaiduMapPoiSearch.openBaiduMapPoiNearbySearch(poiLParam, context);} catch (e) {console.log('error:', JSON.stringify(e));}}
import { BaiduMapRoutePlan, RoutePageParamModel, RoutePageTypeEnum, IsTrueEnum } from '@bdmap/util';openLink() {let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;let routeParam: RoutePageParamModel = new RoutePageParamModel().setType(RoutePageTypeEnum.WALK).setSrc(RoutePageTypeEnum.WALK).setPopRoot(IsTrueEnum.NO).setNeedLocation(IsTrueEnum.YES);try {BaiduMapRoutePlan.openBaiduMapRoutePage(routeParam, context);} catch (e) {console.log('error:', JSON.stringify(e));}}
import {BaiduMapRoutePlan,DirectionPageParamModel,IsTrueEnum,SrcTypeEnum,TravelMethodEnum,} from '@bdmap/util';openLink() {let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;let dirParam: DirectionPageParamModel = new DirectionPageParamModel().setPageflag('4').setPopRoot(IsTrueEnum.NO).setSrc(SrcTypeEnum.DUHELPER).setOrigin('故宫').setOriginName('故宫').setDestination('天安门').setDestName('天安门').setMode(TravelMethodEnum.WALKING);try {BaiduMapRoutePlan.openBaiduMapDirectionPage(dirParam, context);} catch (e) {console.log('error:', JSON.stringify(e));}}
import { BaiduMapNavigation, NaviPageParamModel } from '@bdmap/util';openLink() {let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;let naviParam: NaviPageParamModel = new NaviPageParamModel().setLocation('22.615108,114.035529').setUid('6f6241e3c05ab1a093114c5e');try {BaiduMapNavigation.openBaiduMapNavi(naviParam, context);} catch (e) {console.log('error:', JSON.stringify(e));}}
调起百度地图周边sug页功能
import { BaiduMapPoiSearch, NearbySugPageParamModel } from '@bdmap/util'openLink(){let context:common.UIAbilityContext = getContext(this) as common.UIAbilityContext;let nearbySugParam: NearbySugPageParamModel = new NearbySugPageParamModel().setPoiX(39.989813).setPoiY(116.314094)try {BaiduMapPoiSearch.openBaiduMapNearbySugPage(nearbySugParam,context)} catch (e) {console.log("error:",JSON.stringify(e))}}
调起百度地图公交附近页功能
import { BaiduMapRoutePlan, BusNearbyPageParamModel } from '@bdmap/util'openLink(){let context:common.UIAbilityContext = getContext(this) as common.UIAbilityContext;let busNearbyParam: BusNearbyPageParamModel = new BusNearbyPageParamModel().setParam('{"posX":12942656, "posY":4869801, "cityId":131}')try {BaiduMapRoutePlan.openBaiduMapBusNearbyPage(busNearbyParam,context)} catch (e) {console.log("error:",JSON.stringify(e))}}
调起百度地图步行导航功能
import { BaiduMapNavigation, WalkNaviPageParamModel } from '@bdmap/util'openLink(){let context:common.UIAbilityContext = getContext(this) as common.UIAbilityContext;let walkNaviParam: WalkNaviPageParamModel = new WalkNaviPageParamModel().setOrigin('39.915291,116.403857').setDestination('40.056858,116.308194')try {BaiduMapNavigation.openBaiduMapWalkNavi(walkNaviParam,context)} catch (e) {console.log("error:",JSON.stringify(e))}}
调起百度地图骑行导航功能
import { BaiduMapNavigation, BikeNaviPageParamModel } from '@bdmap/util'openLink(){let context:common.UIAbilityContext = getContext(this) as common.UIAbilityContext;let bikeNaviParam: BikeNaviPageParamModel = new BikeNaviPageParamModel().setOrigin('39.915291,116.403857').setDestination('40.056858,116.308194')try {BaiduMapNavigation.openBaiduMapBikeNavi(bikeNaviParam,context)} catch (e) {console.log("error:",JSON.stringify(e))}}
调起百度地图货车导航功能
import { BaiduMapNavigation, TruckNaviPageParamModel } from '@bdmap/util'openLink(){let context:common.UIAbilityContext = getContext(this) as common.UIAbilityContext;let truckNaviParam: TruckNaviPageParamModel = new TruckNaviPageParamModel().setLocation('40.057023,116.307852').setPlate_number('粤B69999').setTruck_type(TruckTypeEnum.MINIATURE).setHeight(3).setWidth(5).setLength(13).setAxle_count(TruckAxleCountEnum.Four).setPower_type(TruckPowerTypeEnum.GASOLINE).setEmission_limit(TruckGBEnum.GB4).setLoad_weight(7).setWeight(78)try {BaiduMapNavigation.openBaiduMapTruckNavi(truckNaviParam,context)} catch (e) {console.log("error:",JSON.stringify(e))}}
上一篇
下一篇
本篇文章对您是否有帮助?