Hello,
I was wondering if it is possible to click on the billboards added inside the GeoJSON, and get the GeoJSON features. I was trying to find a function to pick features, but couldn’t find for vector data. Thank you.
Hello,
I was wondering if it is possible to click on the billboards added inside the GeoJSON, and get the GeoJSON features. I was trying to find a function to pick features, but couldn’t find for vector data. Thank you.
Hi,
Once you load the geoJSON, you can access the collection of Entities. There’s a good section in our Cesium Workshop Tutorial with examples on loading a GeoJson file and configuring each feature based on the data.
Thanks,
Gabby
Hello Gabby,
thanks for your answer.
In the way you suggested I can get all the features of the entities with the code below:
var promise = Cesium.GeoJsonDataSource.load(“http://ugbd.get-it.it/proxy/?proxyTo=http://ugbd.get-it.it/geoserver/geonode/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=geonode:NAPOLI_DEFORMAZIONE_MAP&outputFormat=json”, {
markerColor: Cesium.Color.HOTPINK,
markerSymbol: “*”
});
promise.then(function(data) {
viewer.dataSources.add(data);
viewer.zoomTo(data);
var entities = data.entities.values;
for (var i = 0; i < entities.length; i++) {
console.log(entities[i].properties.wfs_ts._value);
}
});
``
However, what I need, instead of showing the data in the info box upon clicking, getting the data of the clicked point to be used. I need to use the wfs_ts value to make a request and using the values returned to draw a chart. So, after clicking each point, their corresponding chart will be drawn. Can I do this?
Thank you!
You can sett the contents of the info box to any html string and that will show in the infobox, see the Entity Features in the Viewer section of the Entities tutorial.
You can pair that with the property system you are using below. See the Property System section of the above tutorial for more info.
Thanks, hope that helps!
Gabby
Thanks a lot Gabby!
I did:
viewer.canvas.addEventListener(“click”, function(e){
setTimeout(function () {
var table = $(viewer.infoBox.frame).contents().find(“table”);
if (table) {
var url = table.find(“tr”).last().find(“td”).text();
console.log(url);
}
}, 100);
}, false);
``
which works. I also hid the infoBox with CSS. Thanks for pointing me to the right direction.
Eylül