自v7.6.1版本起,Android地图SDK支持在地图上展示3D动态轨迹。添加3D动态轨迹请参考BMTrackOptions类
代码如下:
参数选项:
/*** 设置轨迹线的类型* @param trackType* @return*/public OverlayOptions setTrackType(BMTrackType trackType)/*** 设置轨迹线的高度* 注:高度必须 >= 0,否则不绘制 单位:米* @param mHeights*/public OverlayOptions setHeights(int[] mHeights)/*** 设置轨迹点数组* @param traceLocation* @return*/public OverlayOptions setPoints(List<LatLng> traceLocation)/*** 设置轨迹线描边的宽度* @param width* @return*/public OverlayOptions setWidth(int width)/*** 设置轨迹动画的状态监听* @param mTraceAnimationListener* @return*/public OverlayOptions setTraceAnimationListener(TraceAnimationListener mTraceAnimationListener)/*** 设置轨迹颜色的取色图片* @param palette*/public OverlayOptions setPalette(BitmapDescriptor palette)/*** 设置3d轨迹底部描边的取色图片* 注:不设置 只绘制带高度的3d轨迹* @param palette*/public OverlayOptions setProjectionPalette(BitmapDescriptor palette)/*** 设置3d轨迹的不透明度(0.f ~ 1.f)* @param opacity*/public OverlayOptions setOpacity(float opacity)/*** 设置3d轨迹描边的不透明度(0.f ~ 1.f)* @param mPaletteOpacity*/public OverlayOptions setPaletteOpacity(float mPaletteOpacity)
示例:
BMTrackOptions trackOptions = new BMTrackOptions();trackOptions.setTrackType(BMTrackType.Surface);trackOptions.setPoints(points);trackOptions.setHeights(heights);trackOptions.setPalette(mPalette);trackOptions.setPaletteOpacity(0.3f);trackOptions.setProjectionPalette(mProjectionPalette);trackOptions.setWidth(10);trackOptions.setAnimationTime(5000);private TraceAnimationListener mTraceAnimationListener = new TraceAnimationListener() {@Overridepublic void onTraceAnimationUpdate(int percent) {Log.i(tag,"onTraceAnimationUpdate : " + percent);}@Overridepublic void onTraceUpdatePosition(LatLng position) {Log.i(tag,"onTraceUpdatePosition : " + position.toString());}@Overridepublic void onTraceAnimationFinish() {Log.i(tag,"TraceAnimationFinish" );}};trackOptions.setTraceAnimationListener(mTraceAnimationListener);trackOptions.setAnimateType(BMTrackOptions.BMTrackAnimateType.TraceOverlayAnimationEasingCurveLinear);Track track = (Track)mBaiduMap.addOverlay(trackOptions);
效果:
trackOptions.setTrackType(BMTrackType.Surface);
效果:
trackOptions.setTrackType(BMTrackType.Default3D);
上一篇
下一篇
本篇文章对您是否有帮助?