/*** gsp.bi.stage.findSelectedFeatures method does not work with V2 painter* due to lack of "key" property in undecorated Feature objects.** This is a replacement workaround method that is using gsp.bi.stage.findSelectedFeatureIds ** 2018-03-07 Piotr Szrajber <piotr.szrajber@hexagongeospatial.com>*/functionfindSelectedFeatures(config,callback,errback){config=config||{};gsp.bi.stage.findWidgets({descriptors:[{chartM:{chart:"choropleth"}}],stageId:config.stageId},function(widgets){if(!widgets||!widgets[0]){if(typeoferrback==="function")errback("Cannot find any choropleth!");}debugger;varchart=widgets[0].chart,chartModel=widgets[0].chartM,keyProperty=chartModel.key,decorator=chart.featureData(),geoJson=chart.geoJson(),featureIds=chart.dimension().top(Infinity).map(function(d){returnd[keyProperty]}),decoratedFeatures=geoJson.features.map(decorator),filteredFeatures=decoratedFeatures.filter(function(feature){returnfeatureIds.indexOf(feature.key)!==-1;}),undecoratedFeatures=filteredFeatures.map(function(feature){return{type:"Feature",geometry:feature.geometry,properties:feature.properties// it is possible to pass computed aggregations by accessing feature.value.*};});callback({type:"FeatureCollection",crs:geoJson.crs,features:undecoratedFeatures});});}// usage: findSelectedFeatures({stageId: "yourStageId"}, console.log)
Comments (1)
Piotr Szrajber
Handled stageId
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.
Handled stageId