let polygon = viewer.entities.add({
polygon: {
hierarchy: [Cesium.Cartesian3.fromDegrees(104.4555, 30.3333, 1000),Cesium.Cartesian3.fromDegrees(104.4555, 30.3333, 500),Cesium.Cartesian3.fromDegrees(104.4855, 30.3533, 500),Cesium.Cartesian3.fromDegrees(104.4855, 30.3533, 1000)],
fill: true,
material: Cesium.Color.YELLOW,
outline: true,
outlineColor: Cesium.Color.RED,
outlineWidth: 2,
heightReference: Cesium.HeightReference.NONE,
perPositionHeight: true,//是否使用每个点高度
},
});
viewer.zoomTo(polygon);
这段代码在superMap包加载的地图中会报错,但是使用原生cesium包加载的地图不会报错。
原生包:
<script src="https://cesium.com/downloads/cesiumjs/releases/1.83/Build/Cesium/Cesium.js"></script>
<link href="https://cesium.com/downloads/cesiumjs/releases/1.83/Build/Cesium/Widgets/widgets.css" rel="stylesheet">