<?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 Re: FeatureLayer modes (MODE_SELECTION and MODE_ONDEMAND) for JS 4.x in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/featurelayer-modes-mode-selection-and-mode/m-p/1539024#M85691</link>
    <description>&lt;P&gt;That worked. Thank you so much for your help.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 16 Sep 2024 17:22:14 GMT</pubDate>
    <dc:creator>Mr_Kirkwood</dc:creator>
    <dc:date>2024-09-16T17:22:14Z</dc:date>
    <item>
      <title>FeatureLayer modes (MODE_SELECTION and MODE_ONDEMAND) for JS 4.x</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/featurelayer-modes-mode-selection-and-mode/m-p/1538394#M85672</link>
      <description>&lt;P&gt;I am new to the JS 4.x language. The JS 3.x had the modes. These helped with queries where you could zoom into a FeatureLayer&amp;nbsp; and have it turn on when zoomed to. The Featurelayer doesnt show up when using&amp;nbsp;MODE_SELECTION until it was queried and selected. Here is an exapmple of the 3.x code:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;floorOutline = new FeatureLayer (urlFloorOutline, {
                    mode: FeatureLayer.MODE_SELECTION,
                    id: 'floorOutline',
                    outFields: ["*"],
                    opacity: 0.8,
                });&lt;/LI-CODE&gt;&lt;P&gt;This was added t othe map and did not show up on the map until you ran the zoom to fucntion:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function zoomFloorOutline (id)
{
    require ([
        "esri/tasks/query",
        "esri/geometry/ScreenPoint",
        "esri/geometry/Extent",
        "esri/layers/FeatureLayer"
    ],
            function (Query, ScreenPoint, Extent, FeatureLayer)
            {
                console.log ("zoomFloorOutline")
                clearGraphics ();
                var query = new Query ();
                query.objectIds = [id];
                var myDate = new Date ();
                var myMS = myDate.getMilliseconds ();
                query.where = "(" + myMS + "=" + myMS + ")";
                console.log ("zoomFloorOutline + id")

                floorOutline.selectFeatures (query, FeatureLayer.SELECTION_NEW, function (features)
                {
                    var floorExtent = features[0].geometry.getExtent ().expand (1.5);
                    map.setExtent (floorExtent);
                });
            });
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do i do something similar with JS 4.x?&amp;nbsp; I have some code to zoom to the feature but it is visible when the map is loaded and i just want show the quereied floor.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function zoomFloorOutline (id)
{
    require ([
        "esri/rest/query",
        "esri/rest/support/Query",
        "esri/layers/FeatureLayer",
       "esri/views/layers/LayerView"
    ],
            function (query, Query, FeatureLayer,LayerView)
            {
                console.log ("zoomFloorOutline");

//                let highlight;
                view.whenLayerView (floorOutline).then (function (layerView)
                {

                    var query = floorOutline.createQuery ();
                    query.objectIds = [id];
                    query.where = "1=1";
                    floorOutline.queryFeatures (query).then (function (results)
                    {
                        const features = results.features;
                        console.log("zoom Floor" + features)
                        var geometry = features[0].geometry.extent.clone ().expand (2);
                        view.goTo (geometry);
                        
                        
                    });
                });
            });
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for any help.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Sep 2024 17:03:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/featurelayer-modes-mode-selection-and-mode/m-p/1538394#M85672</guid>
      <dc:creator>Mr_Kirkwood</dc:creator>
      <dc:date>2024-09-13T17:03:30Z</dc:date>
    </item>
    <item>
      <title>Re: FeatureLayer modes (MODE_SELECTION and MODE_ONDEMAND) for JS 4.x</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/featurelayer-modes-mode-selection-and-mode/m-p/1538399#M85673</link>
      <description>&lt;P&gt;If you're just wanting to show a particular set of features at any given time, and know the objectID values of that set, then using &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#definitionExpression" target="_self"&gt;definitionExpression&lt;/A&gt; would be one way to do so:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function hideLayerFeatures(featureLayer) {
	featureLayer.definitionExpression = "1=0";
}

function showLayerFeatures(featureLayer, ids) {
	if (Array.isArray(ids))
		featureLayer.definitionExpression = featureLayer.objectIdField + " IN(" + ids.join(",") + ")";
	else if (typeof ids == "number")
		featureLayer.definitionExpression = featureLayer.objectIdField + " = " + ids.toString();
}&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 13 Sep 2024 17:16:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/featurelayer-modes-mode-selection-and-mode/m-p/1538399#M85673</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2024-09-13T17:16:33Z</dc:date>
    </item>
    <item>
      <title>Re: FeatureLayer modes (MODE_SELECTION and MODE_ONDEMAND) for JS 4.x</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/featurelayer-modes-mode-selection-and-mode/m-p/1539006#M85689</link>
      <description>&lt;P&gt;I already have some code to grab the OBJECTID. How do I get the layer to turn on to the queried OBJECTID when I zoom to the Feature? I have set the visibility for the whole layer to "false"&lt;/P&gt;</description>
      <pubDate>Mon, 16 Sep 2024 16:59:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/featurelayer-modes-mode-selection-and-mode/m-p/1539006#M85689</guid>
      <dc:creator>Mr_Kirkwood</dc:creator>
      <dc:date>2024-09-16T16:59:52Z</dc:date>
    </item>
    <item>
      <title>Re: FeatureLayer modes (MODE_SELECTION and MODE_ONDEMAND) for JS 4.x</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/featurelayer-modes-mode-selection-and-mode/m-p/1539017#M85690</link>
      <description>&lt;P&gt;On line 25 of your 4.x code you have this to zoom to the feature:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;view.goTo (geometry);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you want to make the layer visible after zooming, you can change that line to the following:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;view.goTo(geometry).then(function() {
	floorOutline.visible = true;
});&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 16 Sep 2024 17:17:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/featurelayer-modes-mode-selection-and-mode/m-p/1539017#M85690</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2024-09-16T17:17:46Z</dc:date>
    </item>
    <item>
      <title>Re: FeatureLayer modes (MODE_SELECTION and MODE_ONDEMAND) for JS 4.x</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/featurelayer-modes-mode-selection-and-mode/m-p/1539024#M85691</link>
      <description>&lt;P&gt;That worked. Thank you so much for your help.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Sep 2024 17:22:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/featurelayer-modes-mode-selection-and-mode/m-p/1539024#M85691</guid>
      <dc:creator>Mr_Kirkwood</dc:creator>
      <dc:date>2024-09-16T17:22:14Z</dc:date>
    </item>
    <item>
      <title>Re: FeatureLayer modes (MODE_SELECTION and MODE_ONDEMAND) for JS 4.x</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/featurelayer-modes-mode-selection-and-mode/m-p/1539152#M85696</link>
      <description>&lt;P&gt;Thanks again. Here is my updated code snippet:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function zoomFloorOutline (id)
{
    require ([
        "esri/rest/query",
        "esri/rest/support/Query",
        "esri/layers/FeatureLayer",
        "esri/views/layers/LayerView"
    ],
            function (query, Query, FeatureLayer, LayerView)
            {
                console.log ("zoomFloorOutline");
                floorOutline.definitionExpression = floorOutline.objectIdField + " = " + id.toString ();
                console.log (floorOutline.definitionExpression)
                view.whenLayerView (floorOutline).then (function (layerView)
                {
                    var query = floorOutline.createQuery ();
                    query.objectIds = [id];
                    query.where = "1=1";
                    floorOutline.queryFeatures (query).then (function (results)
                    {
                        const features = results.features;
                        var geometry = features[0].geometry.extent.clone ().expand (2);
                        view.goTo (geometry).then (function ()
                        {
                            floorOutline.visible = true;
                        });
                    });
                });
            });
}&lt;/LI-CODE&gt;&lt;P&gt;How would this work with an array of OBJECTIDs? My JS 3.x looks like this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function zoomRoomUse (ids)
{
    require ([
        "esri/tasks/query",
        "esri/geometry/Extent",
        "esri/layers/FeatureLayer"
    ],
            function (Query, Extent, FeatureLayer)
            {
                console.log ("zoomRoomUse")
                var query = new Query ();
                query.objectIds = ids;
                var myDate = new Date ();
                var myMS = myDate.getMilliseconds ();
                query.where = "(" + myMS + "=" + myMS + ")";
                roomUseLayer.selectFeatures (query, FeatureLayer.SELECTION_NEW, function (features)
                {
                    var newExtent = new Extent ();
                    newExtent = features[0].geometry.getExtent ();

                    for (var k = 0; k &amp;lt; features.length; k++) {
                        newExtent = newExtent.union (features[k].geometry.getExtent ().expand (15));
                    }
                    labelRoom ();
                });
            });
}&lt;/LI-CODE&gt;&lt;P&gt;I am having trouble updating it to 4.x&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Sep 2024 20:29:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/featurelayer-modes-mode-selection-and-mode/m-p/1539152#M85696</guid>
      <dc:creator>Mr_Kirkwood</dc:creator>
      <dc:date>2024-09-16T20:29:59Z</dc:date>
    </item>
    <item>
      <title>Re: FeatureLayer modes (MODE_SELECTION and MODE_ONDEMAND) for JS 4.x</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/featurelayer-modes-mode-selection-and-mode/m-p/1539155#M85697</link>
      <description>&lt;LI-CODE lang="javascript"&gt;I tried something like this:

function zoomRoomUse (ids)
{
    require ([
        "esri/rest/query",
        "esri/rest/support/Query",
        "esri/layers/FeatureLayer",
        "esri/views/layers/LayerView"
    ],
            function (query, Query, FeatureLayer, LayerView)
            {
                console.log ("zoomFloorOutline");
                roomsUseLayer.definitionExpression = roomsUseLayer.objectIdField + " IN(" + ids.join(",") + ")";
                console.log (roomsUseLayer.definitionExpression)
                console.log(ids)
                view.whenLayerView (roomsUseLayer).then (function (layerView)
                {
                    var query = roomsUseLayer.createQuery ();
                    query.objectIds = [ids];
                    query.where = "1=1";
                    roomsUseLayer.queryFeatures (query).then (function (results)
                    {
                        const features = results.features;
                        var geometry = features[0].geometry.extent.clone ();
                        for (var k = 0; k &amp;lt; features.length; k++) {
                            geometry = geometry.union (features[k].geometry.extent.clone ());
                            view.goTo (geometry).then (function ()
                            {
                                roomsUseLayer.visible = true;
                            });
                        }
                    });
                });
            });
}&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 16 Sep 2024 20:34:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/featurelayer-modes-mode-selection-and-mode/m-p/1539155#M85697</guid>
      <dc:creator>Mr_Kirkwood</dc:creator>
      <dc:date>2024-09-16T20:34:39Z</dc:date>
    </item>
    <item>
      <title>Re: FeatureLayer modes (MODE_SELECTION and MODE_ONDEMAND) for JS 4.x</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/featurelayer-modes-mode-selection-and-mode/m-p/1539174#M85699</link>
      <description>&lt;P&gt;On line 21, instead of:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;query.where = "1=1";&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think you need this instead:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;query.where = roomsUseLayer.definitionExpression;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Or better yet, you could remove line 21 altogether, because according to the documentation for &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#createQuery" target="_self"&gt;createQuery&lt;/A&gt;, the "where" setting should already be set according to the definitionExpression.&amp;nbsp; Setting it to "1=1" would overwrite that and return all features in the layer.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Sep 2024 20:47:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/featurelayer-modes-mode-selection-and-mode/m-p/1539174#M85699</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2024-09-16T20:47:53Z</dc:date>
    </item>
    <item>
      <title>Re: FeatureLayer modes (MODE_SELECTION and MODE_ONDEMAND) for JS 4.x</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/featurelayer-modes-mode-selection-and-mode/m-p/1644499#M87542</link>
      <description>&lt;LI-CODE lang="javascript"&gt;function zoomTreeTypes (ids)
{
    require ([
        "esri/rest/query",
        "esri/rest/support/Query",
        "esri/layers/FeatureLayer",
        "esri/views/layers/LayerView"
    ],
            function (query, Query, FeatureLayer, LayerView)
            {

                treeQueryLayer.definitionExpression = treeQueryLayer.objectIdField + " IN(" + ids.join (",") + ")";
                view.whenLayerView (treeQueryLayer).then (function (layerView)
                {
                    var query = treeQueryLayer.createQuery ();
                    query.objectIds = [ids];
                    query.where = treeQueryLayer.definitionExpression;
                    treeQueryLayer.queryFeatures (query).then (function (results)
                    {
                        const features = results.features;
                        var geometry = features[0].geometry.extent.clone();
                        for (var k = 1; k &amp;lt; features.length; k++) {
                            geometry = geometry.union (features[k].geometry.extent.clone ());
                        }
                        view.goTo (geometry).then (function ()
                        {
                            treeQueryLayer.visible = true;
                            editTreeLayer.visible = false;
//                            graphics = results.features;
                        }).catch (function (error)
                        {
                            if (error.name != "view:goto-interrupted") {
                                console.error (error);
                            } else {
                                console.log ("Drawing");
                            }
                        });
                    });
                });
            });
}&lt;/LI-CODE&gt;&lt;P&gt;I am trying to zoom to a group of queried points but the above code is getting an error.&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;SPAN&gt;Uncaught (in promise) &lt;/SPAN&gt;&lt;SPAN class=""&gt;TypeError: Cannot read properties of null (reading 'clone')&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class=""&gt;at this point in the code&lt;/SPAN&gt;&lt;/DIV&gt;&lt;P&gt;var geometry = features[0].geometry.extent.clone ();&lt;/P&gt;&lt;P&gt;Is there somethung different with zooming to points?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Aug 2025 21:19:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/featurelayer-modes-mode-selection-and-mode/m-p/1644499#M87542</guid>
      <dc:creator>Mr_Kirkwood</dc:creator>
      <dc:date>2025-08-21T21:19:38Z</dc:date>
    </item>
    <item>
      <title>Re: FeatureLayer modes (MODE_SELECTION and MODE_ONDEMAND) for JS 4.x</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/featurelayer-modes-mode-selection-and-mode/m-p/1644560#M87543</link>
      <description>&lt;P&gt;As seen in &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Point.html#extent" target="_self"&gt;the documentation&lt;/A&gt;, point objects don't have an extent (the value of their extent property is null).&amp;nbsp; You might want to built a single &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Multipoint.html" target="_self"&gt;MultiPoint&lt;/A&gt; object from the points returned by your query and zoom to it instead.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Aug 2025 00:40:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/featurelayer-modes-mode-selection-and-mode/m-p/1644560#M87543</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2025-08-22T00:40:18Z</dc:date>
    </item>
  </channel>
</rss>

