效果
代码
/**
* 渲染多边形效果
*/
polygon3dAdd:function(){
var data =[
{
id: "智能监测-01",
color: [0, 1, 0.3, 0.5],
velocity: 0.4,
height: 70,
intensity: 1,
style: 3,
coordinates: [
[492908.96875, 2492044.8000000003, 1],
[492904.30562500004, 2491953.92, 1],
[492975.33437500003, 2491950.24, 1],
[492968.324375, 2492034.88, 1],
]
},
{
id: "智能监测-02",
color: [0, 1, 0.3, 0.5],
velocity: 0.4,
height: 50,
intensity: 10,
style: 4,
coordinates: [
[492846.5625, 2492068, 1],
[ 492850.21875, 2492011, 1],
[ 492804.40625, 2492009, 1],
[492803.59375, 2492075, 1]
]
}
]
var polygon3dList = [];
for(var i=0;i<data.length;i++){
let o = {
id: data[i].id,
coordinates: data[i].coordinates,
color: data[i].color, //颜色值
height: data[i].height, //3D多边形的高度
intensity: data[i].intensity, //亮度
style: data[i].style, //3DPolygon的样式 请参照API开发文档选取枚举
tillingX: 0, //可选,仅当3DPolygon的样式支持贴图显示,贴图横向平铺
tillingY: 0 //可选,仅当3DPolygon的样式支持贴图显示,贴图纵向平铺
};
polygon3dList.push(o);
}
ak_api.polygon3dAdd(polygon3dList); //标注
var obj = new Object();
obj.x=492931.30957;
obj.y=2491799.909043;
obj.z=185.334395;
obj.pitch=-32.3396;
obj.yaw=-92.659271;
obj.flyTime=0;
ak_api.setCamer(obj);
},
ak_api.js
/**
* @param {Object} data
* 渲染多边形边框 发光
*/
polygon3dAdd:async function(data) {
__g.polygon3d.add(data);
},
/**
* 定位视角
*/
setCamer:function(object){
//参数:x, y, z, pitch, yaw, flyTime
__g.camera.set(object.x, object.y, object.z, object.pitch, object.yaw, object.flyTime);
},
3D Polygon的样式
清除
//清除多边形
polygon3dClear:function(){
ak_api.polygon3dClear();
},