鸿蒙地图SDK可以通过Marker类方法支持在底图上叠加地面覆盖物(自定义图片),效果图如下:
示例代码:
// 创建一个画布context: OffscreenCanvasRenderingContext2D = new OffscreenCanvasRenderingContext2D(80, 27, this.settings);context.clearRect(0, 0, 100, 50);context.fillStyle = '#ff76b5e3';context.fillRect(0, 0, 100, 50);context.textBaseline = 'top';context.lineWidth = 1;context.font = '32px monospace';context.strokeStyle = '#fff';context.fillStyle = '#666';pixelMap:ImageBitmap | PixelMap = context.getPixelMap(0, 0, 100, 50);// 生成image对象image:ImageEntity = new ImageEntity(pixelMap, vp2px(100), vp2px(50));// 生成marker对象marker = new Marker({position: new LatLng(40.05690, 116.307761),icon: image,yOffset: 0,isFlat: false,isDraggable: true,rotate: 0,scaleX: 2,scaleY: 2,alpha: 0.9,isTop: true,animaType: SysEnum.AnimateDefine.JUMP});// 添加到地图mapController?.addOverlay(this.marker);
上一篇
下一篇
本篇文章对您是否有帮助?