Hi all,
I’m running into an issue after loading a geoJSON from PostGIS.
Here’s the geoJSON I’m loading:
{
“type”: “FeatureCollection”,
“features”: [
{
“type”: “Feature”,
“geometry”: {
“type”:“Polygon”,
“coordinates”: [
[
[-74.0392315441728,40.7418578982759],
[-74.0392315441728,40.7055751656336],
[-73.9940771575758,40.7055751656336],
[-73.9940771575758,40.7418578982759],
[-74.0392315441728,40.7418578982759]
]
]
},
“properties”: {
“id”: 2,
“people”: 7000
}
},
{
“type”: “Feature”,
“geometry”: {
“type”:“Polygon”,
“coordinates”:[
[
[-73.9940771575758,40.7418578982759],
[-73.9940771575758,40.7055751656336],
[-73.9489227709788,40.7055751656336],
[-73.9489227709788,40.7418578982759],
[-73.9940771575758,40.7418578982759]
]
]
},
“properties”: {
“id”: 3,
“people”: 6933
}
}
]
}
From this, I want to take the ‘people’ property of each polygon created and create a label over top of the polygon. However, I can’t seem to get to the list of DynamicObjects created. Here’s my JS trying to just get a list of the objects:
function loadLandscan(lat, lon) {
var url = webapp_url +
‘/loadLandscan?lat=’ + encodeURIComponent(lat) +
‘&lon=’ + encodeURIComponent(lon);
var geoJsonSource = new Cesium.GeoJsonDataSource();
geoJsonSource.loadUrl(url);console.log(geoJsonSource.getDynamicObjectCollection()); // Print dynamicObjectCollection
console.log(geoJsonSource.getDynamicObjectCollection().getObjects()); // Print objects in dynamicObjectCollection
viewer.dataSources.add(geoJsonSource);
}
The dynamicObjectCollection looks full from the console output of
DynamicObjectCollection {_objects: AssociativeArray, _addedObjects: AssociativeArray, _removedObjects: AssociativeArray, _suspendCount: 0, _collectionChanged: Event…}
_addedObjects: AssociativeArray
_collectionChanged: Event
_id: “ce669254-1e15-46ba-9bf9-334e3ae6f1c9”
_objects: AssociativeArray
_array: Array[2]
0: DynamicObject
1: DynamicObject
length: 2
proto: Array[0]
_hash: Object
length: (…)
values: (…)
proto: Object
_removedObjects: AssociativeArray
_suspendCount: 0
collectionChanged: (…)
id: (…)
proto: Object
However, when printing the .getObjects() function, I’m getting an empty array.
Any idea why? Thanks in advance.