<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Feature Layer: Update if exists, add if does not, remove if does not exist anymore in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/feature-layer-update-if-exists-add-if-does-not/m-p/1178519#M77528</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am building a React based web app which tracks some moving objects. For simplicity's sake, let's assume I track cars.&lt;/P&gt;&lt;P&gt;Cars may change position or various states over time, and they may be removed and no longer tracked.&lt;BR /&gt;I am managing the tracked objects with a Redux state, simply as an array which contains the Cars data.&lt;/P&gt;&lt;P&gt;I'm having trouble implementing the following behaviour:&lt;/P&gt;&lt;P&gt;1. If a car has been added, add him to the map.&lt;/P&gt;&lt;P&gt;2. If a car has been removed, remove him&lt;/P&gt;&lt;P&gt;3. If a car's location has changed, change it on the map as well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried using the useEffect() hook with combintation with FeaturesLayer.applyEdits(), but as seen in the image below, I am not sure how to efficiently perform the add and delete operations.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt; if (props.map.findLayerById(props.id) !== undefined) {
            console.log("FeaturesLayer:layer with id : ", props.id, "already exists")
            const featLayer = props.map.findLayerById(props.id) as FeatureLayer
            // featLayer.source = new Collection(props.source)
            featLayer.applyEdits({
                updateFeatures: updated_source,
                addFeatures: /* How to detect which features do not exist already in the layer
                                 but exist in the new source? */ [],
                deleteFeatures: /* How to detect which features do not exist in the new source anymore? */ [],

            })&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 31 May 2022 12:18:02 GMT</pubDate>
    <dc:creator>bladesv2</dc:creator>
    <dc:date>2022-05-31T12:18:02Z</dc:date>
    <item>
      <title>Feature Layer: Update if exists, add if does not, remove if does not exist anymore</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/feature-layer-update-if-exists-add-if-does-not/m-p/1178519#M77528</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am building a React based web app which tracks some moving objects. For simplicity's sake, let's assume I track cars.&lt;/P&gt;&lt;P&gt;Cars may change position or various states over time, and they may be removed and no longer tracked.&lt;BR /&gt;I am managing the tracked objects with a Redux state, simply as an array which contains the Cars data.&lt;/P&gt;&lt;P&gt;I'm having trouble implementing the following behaviour:&lt;/P&gt;&lt;P&gt;1. If a car has been added, add him to the map.&lt;/P&gt;&lt;P&gt;2. If a car has been removed, remove him&lt;/P&gt;&lt;P&gt;3. If a car's location has changed, change it on the map as well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried using the useEffect() hook with combintation with FeaturesLayer.applyEdits(), but as seen in the image below, I am not sure how to efficiently perform the add and delete operations.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt; if (props.map.findLayerById(props.id) !== undefined) {
            console.log("FeaturesLayer:layer with id : ", props.id, "already exists")
            const featLayer = props.map.findLayerById(props.id) as FeatureLayer
            // featLayer.source = new Collection(props.source)
            featLayer.applyEdits({
                updateFeatures: updated_source,
                addFeatures: /* How to detect which features do not exist already in the layer
                                 but exist in the new source? */ [],
                deleteFeatures: /* How to detect which features do not exist in the new source anymore? */ [],

            })&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 May 2022 12:18:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/feature-layer-update-if-exists-add-if-does-not/m-p/1178519#M77528</guid>
      <dc:creator>bladesv2</dc:creator>
      <dc:date>2022-05-31T12:18:02Z</dc:date>
    </item>
  </channel>
</rss>

