产品服务
解决方案
文档与支持
定价

绘制面

下载开发文档

多边形是一组Latlng点按照传入顺序连接而成的封闭图形,开发者可以通过Polygon设置多边形的位置、边框和填充颜色。

示例代码如下:

// 添加多边形覆盖物
let pathArr: LatLng[] = [
new LatLng(39.9122, 116.2575),
new LatLng(40.0191, 116.4624),
new LatLng(39.913506, 116.4955)
];
let opts:IPolygonOption = {
points: pathArr,
fillcolor:'#0f0',
stroke: new Stroke({
strokeWidth: 12,
color: '#ff00dd',
strokeStyle: SysEnum.StrokeStyle.SQUARE
})
}
this.polygon = new Polygon(opts);
this.polygon.setPoints(pathArr);
this.polygon.setFillcolor('#f9f');
this.polygon.addEventListener(OverlayEvent.CLICK, () => {
this.polygon?.setFillcolor('rgba(0,0,255,0.6)');
promptAction.showToast({
message: '点击多边形',
duration: 2000,
});
});
this.mapController.addOverlay(this.polygon);

绘制AOI检索图形

AoiSearch.newInstance().requestAoi({
latLngList: [new LatLng(40.070754, 116.324175)]
})
.then((res: AoiResult) => {
if (res) {
if (res.aoiList) {
for (let item of res.aoiList) {
if(item.polygon){
let aoi_poly = new Polygon({
points: item.polygon,
fillcolor: '#ff0000',
alpha: 0.5
})
this.mapController.addOverlay(aoi_poly)
}
}
}
}
})

上一篇

位置短地址分享

下一篇

请求状态码说明

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