浏览器版本低!无法浏览完整内容,建议升级或更换浏览器。
自定义地面覆盖物
下载开发文档

鸿蒙地图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);

上一篇

绘制文字

下一篇

POI检索

本篇文章对您是否有帮助?