绘制配置项,开发者可以根据实际业务需要,定制各种UI展示,包括不同状态下小车、路线、路况、起终点等ICON、是否展示InfoWindow、是否自动进行地图最佳视野适配、覆盖物的压盖层级等,更多设置可以参考DisplayOptions类参考说明。
// 默认的配置this._displayOptions = new DisplayOptions.Builder().setShowOption(DisplayOptions.SHOW_START_POSITION_ICON| DisplayOptions.SHOW_END_POSITION_ICON| DisplayOptions.SHOW_CAR_ICON| DisplayOptions.SHOW_PASSENGER_ICON| DisplayOptions.SHOW_ROUTE_PLAN| DisplayOptions.SHOW_START_POSITION_INFO_WINDOW| DisplayOptions.SHOW_END_POSITION_INFO_WINDOW| DisplayOptions.SHOW_CAR_INFO_WINDOW| DisplayOptions.SHOW_WAY_POINTS).setInSpanOption(DisplayOptions.IN_SPAN_START_POSITION_ICON| DisplayOptions.IN_SPAN_END_POSITION_ICON| DisplayOptions.IN_SPAN_CAR_ICON| DisplayOptions.IN_SPAN_PASSENGER_ICON| DisplayOptions.IN_SPAN_ROUTE_PLAN| DisplayOptions.IN_SPAN_WAY_POINTS).build()
syncManager.setRoutePlanInfoFreshFinishedBack((remainingDistance: number,estimatedTime: number) => {const orderState = this.syncStateif (orderState === OrderState.LBS_ORDER_STATE_PICK_UP_PASSENGER ||orderState === OrderState.LBS_ORDER_STATE_DELIVER_PASSENGER) {syncManager.updateCarPositionInfoWindowView(new CustomBuilderEntity('builder', () => {return WindowBuilder.bind(this)(`剩余${remainingDistance.toFixed(2)}m, 大约: ${estimatedTime}s`)}))}})
核心方法,在获取到地图实例之后,将创建好的地图对象、订单管理对象、路线绘制对象传入管理器构造函数中,更多设置可以参考SynchronizationDisplayManager类参考说明:
init(mapController: MapController): void {this._mapController = mapControllerthis._syncDisplayManager = new SynchronizationDisplayManager(mapController, this._roleOptions, this._displayOptions)this.initFinishListener.forEach((listener) => {listener(mapController)})}
在对应page的生命周期中管理司乘同显管理器对象的生命周期。
onPageShow(): void {syncManager.onResume()// 开启定位this.locClient?.start()}onPageHide(): void {syncManager.onPause()// 关闭定位this.locClient?.stop()}aboutToDisappear(): void {const locClient = this.locClientconst myLocationListener = this.myLocationListenerif (locClient !== null && myLocationListener !== null) {locClient.unRegisterLocationListener(myLocationListener)}this.locClient = nullthis.myLocationListener = nullsyncManager.removeOrderStateChangeListener(this.orderStatusChanged.bind(this))syncManager.release()this.mapController?.destroy()}
上一篇
下一篇
本篇文章对您是否有帮助?