I have a list of polygon corrdinates. I was able to draw thses polygons inside a loop.
Is there a way that i can draw 100 polygons in one go.
Meaning i am drawing 100 polygons in a loop. Need to draw 100 polygons in one drawing instance.
Please check my code.
Cesium.Camera.DEFAULT_VIEW_FACTOR = 0.2;
var map = new Cesium.Viewer('cesiumContainer', {
infoBox: false, //Disable InfoBox widget
selectionIndicator: false, //Disable selection indicator
shouldAnimate: true, // Enable animations
navigationHelpButton: false,
animation: false,
timeline: false,
geocoder: false,
sceneMode : Cesium.SceneMode.SCENE2D,
imageryProvider : Cesium.createTileMapServiceImageryProvider({
url : Cesium.buildModuleUrl('Assets/Textures/NaturalEarthII')
}),
baseLayerPicker : false,
requestRenderMode : true
});
$(".cesium-credit-textContainer").remove();
$(".cesium-viewer-toolbar").remove();
$(".cesium-viewer-fullscreenContainer").remove();
$(".cesium-viewer-bottom").remove();
// $(".cesium-viewer-animationContainer").remove();
scene = map.scene;
scene.globe.enableLighting = false;
scene.requestRenderMode = true;
$.ajax({
url: "data.json",
type: 'GET',
success: function(res) {
var cellCoordsList = res.CellCoordsList;
for(var i = 0; i < cellCoordsList.length; i++) {
var data = Cesium.Cartesian3.fromDegreesArray([
cellCoordsList[i].Coord1.Lon, cellCoordsList[i].Coord1.Lat,
cellCoordsList[i].Coord2.Lon, cellCoordsList[i].Coord2.Lat,
cellCoordsList[i].Coord3.Lon, cellCoordsList[i].Coord3.Lat,
cellCoordsList[i].Coord4.Lon, cellCoordsList[i].Coord4.Lat
]);
drawPolygon(data);
}
}
});
function drawPolygon(data) {
var redPolygon = map.entities.add({
name : 'Red polygon on surface',
polygon : {
hierarchy : data,
material : Cesium.Color.RED
}
});
}
data format i am using:
{
“CellCoordsList”: [
{
“Coord1”: {
"Lat": "5.917",
"Lon": "69.917",
"Alt": null
},
"Coord2": {
"Lat": "6.083",
"Lon": "69.917",
"Alt": null
},
"Coord3": {
"Lat": "6.083",
"Lon": "70.083",
"Alt": null
},
"Coord4": {
"Lat": "5.917",
"Lon": "70.083",
"Alt": null
}
}
]}