streetscape.gl icon indicating copy to clipboard operation
streetscape.gl copied to clipboard

how to change the layer's attributes dynamically

Open juzi5230 opened this issue 3 years ago • 1 comments
trafficstars

I want to modify the color of GeoJsonLayer dynamically, but failed

new GeoJsonLayer({
  id: 'HEAT_MAP' ,
  data:  geojson, // geojson is a variable, everytime before render it will be computed again
  opacity: 1,
  stroked: false,
  extruded: true,
  elevationScale: 1,
  lineWidthUnits: 'meters',
  lineWidthMinPixels:1,
  lineWidthMaxPixels:3,
  getElevation: f => Math.sqrt(f.properties.valuePerSqm) * 10,
  getFillColor: d => {
    if(d.properties.num) return [255, 0, 0] // get the attribute of num and get the colorValue
    else return [0, 0, 0, 0]
  },
  getLineWidth: 1,
  getRadius: 10,
  getLineColor: [103, 113, 121],
  pickable: true,
})

juzi5230 avatar Dec 09 '21 05:12 juzi5230

I don't understand, you are passing geojson as a variable through XVIZ?

You could also pass this data out-of-band of XVIZ, and just use the GeoJsonLayer passed as a customLayer to the LogViewer?

However, if you are constructing the GeoJsonLayer, can't you just change the getLineColor array?

twojtasz avatar Jan 02 '22 05:01 twojtasz