Background: My map is created by instantiating feature layers via the API. I'm not interfacing with an ArcGIS MapServer directly.
For my map's layers, I have a need to update the attributes associated with each geometry in the layer. The reason is the attribute data determines the color of each geometry's symbol. So imagine an update mechanism that gets the latest attribute values from the server.
Right now, I have a fairly crude async timer that periodically does the following actions to remove existing layers, and then instantiates new layers using the updated data (layersData)
While this works, I end up with a quick flash of the plotted symbols whenever the layers get removed and re-added. Is there another pattern allowable by the JS API that allows more seamless update/replacement of active layers?
One thing to note, the plotted graphics may not all have unique ids. So this makes a delta detection approach problematic. I basically just want a way to replace the existing layers with new layers, without a UI reflow of the empty layers state. Thanks
Solved! Go to Solution.
Hmmm, seemed to have flipped my problem. I got the updating functionality working on a sample dataset, but now after I've modified my JSON structure (nothing I thought would break it), my app cannot parse the JSON to construct the graphic (and then the feature layer) .
I've attached my JSON (not geoJSON) snippet below:
[
{
"TechnicianID":"SomeID",
"TechnicianName":"Mr Man",
"OrderNumber":"1111111",
"JobCode":"ABC",
"State":"NC",
"StateStart":"12:00:00 AM",
"StateDuration":"05:0:05",
"StateDurationSeconds":5,
"AverageStateDuration":2,
"Latitude":35,
"Longitude":-80,
"Flag":null
},
{
"TechnicianID":"SomeID2",
"TechnicianName":"Mr Man2",
"OrderNumber":"11111112",
"JobCode":"ABCD",
"State":"NC",
"StateStart":"12:00:00 AM",
"StateDuration":"05:0:05",
"StateDurationSeconds":5,
"AverageStateDuration":2,
"Latitude":35,
"Longitude":-80,
"Flag":null
},
{
"TechnicianID":"SomeID3",
"TechnicianName":"Mr Man3",
"OrderNumber":"11111113",
"JobCode":"ABCE",
"State":"NC",
"StateStart":"12:00:00 AM",
"StateDuration":"05:0:05",
"StateDurationSeconds":5,
"AverageStateDuration":2,
"Latitude":35,
"Longitude":-80,
"Flag":null
}
]
I'm in the Esri JS 4.8 API, if that makes any difference -- any idea how I'd parse this JSON to successfully construct a graphic that could be converted into a FL (for popups)?
Andrew,
You should start a new thread and post the code you are using to get, parse and update your FeatureLayer.