1. A concise explanation of the problem you’re experiencing.
I’m reading in a couple JSON files and constructing a CZML, I cant seem to get the polygons to show on the map at all.
2. A minimal code example. If you’ve found a bug, this helps us reproduce and repair it.
function geoArray (GeometryArray) {
pointList =
for (var l = 0; l < GeometryArray.length; l++){
var geometryArr = GeometryArray[l];
for (var n = 0; n < geometryArr[0].length; n++){
var pointA = {“cartographicDegrees” : Cesium.Cartographic.fromDegrees(geometryArr[0][n][1], geometryArr[0][n][0])};
pointList.push(pointA);
}
return pointList
}};
var TraffickingCZML = [{
“id” : “document”,
“name” : “CZML Geometries: Country by Trafficking Cases”,
“version” : “1.0”,
clock: {
interval: ‘1990-01-01T00:00:00.000Z/2018-12-13T23:59:59.000Z’,
currentTime: ‘1990-01-01T00:00:00.000Z’,
}
}];
d3.json(‘static/data/globe.geo.json’).then(function (globe) {
if( globe ) {
d3.json(’/static/data/TraffickingGDPCounts.json’).then(function (trafficking) {
var TrafficArray = trafficking;
var arr = globe.features;
for (var i = 0; i < arr.length; i++){
var obj = arr[i];
for (var n = 0; n < TrafficArray.length; n++){
var traffickObj = TrafficArray[n];
if (traffickObj[‘properties.code’] == obj[‘properties’][‘iso_a2’]) {
if (traffickObj[‘Total’]) {
var geometryPacket ={
“id” : obj[‘properties’][‘postal’],
“name” : obj[‘properties’][‘geounit’],
“availability” : traffickObj[‘Year’] + ‘-01-01T00:00:00.000Z’ + ‘/’ + traffickObj[‘Year’] + ‘-12-31T23:59:59.999Z’,
“vertexPositions” : {“cartographicDegrees” : geoArray(obj[‘geometry’][‘coordinates’])},
“polygon” : {
“show”: true,
“material” : {
“solidColor” : {
“color” : traffickObj[‘properties.color’]
}
},
“extrudedHeight” : 100000 * traffickObj[‘Total’],
“perPositionHeight” : true,
“outline” : true,
“outlineColor” : {
“rgba” : [0, 0, 0, 255]
}
}
};
TraffickingCZML.push(geometryPacket);
};
}
}};
})}
});
var viewer = new Cesium.Viewer(‘cesiumContainer’, {
shouldAnimate : true,
terrainProvider: Cesium.createWorldTerrain(),
});
var tileset = viewer.scene.primitives.add(
new Cesium.Cesium3DTileset({
url: Cesium.IonResource.fromAssetId(3)
})
);
var promise = Cesium.CzmlDataSource.load(TraffickingCZML)
promise.then(function(dataSource) {
viewer.dataSources.add(dataSource);
});
``
``
geometry Packet looks like this in the console:
``
- {id: “CO”, name: “Colombia”, availability: “2010-01-01T00:00:00.000Z/2010-12-31T23:59:59.999Z”, vertexPositions: {…}, polygon: {…}}
- availability: “2010-01-01T00:00:00.000Z/2010-12-31T23:59:59.999Z”
- id: “CO”
- name: “Colombia”
- polygon:
- extrudedHeight: 1300000
- material:
- solidColor: {color: “CHARTREUSE”}
- proto: Object
- outline: true
- outlineColor:
- rgba: (4) [0, 0, 0, 255]
- proto: Object
- perPositionHeight: true
- show: true
- proto: Object
- vertexPositions:
- cartographicDegrees: Array(26)
- 0:
- cartographicDegrees: s {longitude: 0.046902920334411694, latitude: -1.3649328324461212, height: 0}
- proto: Object
3. Context. Why do you need to do this? We might know a better way to accomplish your goal.
Needed to break up my json objects because they were too large.
4. The Cesium version you’re using, your operating system and browser.
Using Cesium 1.52 in Chrome, Thanks so much for your help!