Create a Dynamic Data Source For a GeoJSONLayer's URL

03-22-2023 05:49 PM
New Contributor II

Hello, I initialize my GeoJSONLayer with GeoJSON data in a BLOB url. User actions are supported such as moving the GeoJSON graphic around the map and update the symbology of the graphic through the layer's Unique Value Renderer.

However, a symbology update requires `refresh()` to be called on the layer, which resets the location of the graphic to what it was originally defined in the BLOB. How can I retain the updated position when changing the style of the graphic?

0 Kudos
1 Reply
Esri Contributor

To update the symbology, you should be able to set a new renderer on the layer instead of having to call `refresh()`, as shown in the following code snippet.

// clone renderer
let renderer = layer.renderer.clone();
// make updates
renderer.symbol = {
   type: "simple-fill",
   color: "red"
// apply renderer back to layer
layer.renderer = renderer;

Here's an example: