<?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 setting visible property to false not hiding graphic in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setting-visible-property-to-false-not-hiding/m-p/1238767#M79593</link>
    <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am currently using ESRI 4.24. In my map, I am attempting to display or hide certain features based upon a user selection. While attempting to do this, I have failed to successfully hide any graphics when setting the visible property equal to false. I will attach some code to give a better example of my problem (this is just an example, not my code with the user selection). As you can see, I have hard coded two graphics and added them to the array "features" and created the layer using "source: features". I have set the visible property to false in two locations, but the graphic2 object still displays on the map anyway. Here is the code:&amp;nbsp;&lt;/P&gt;&lt;P&gt;require([&lt;BR /&gt;"esri/Map",&lt;BR /&gt;"esri/views/MapView",&lt;BR /&gt;"esri/symbols/SimpleMarkerSymbol",&lt;BR /&gt;"esri/symbols/PictureMarkerSymbol",&lt;BR /&gt;"esri/Graphic",&lt;BR /&gt;"esri/intl",&lt;BR /&gt;"esri/layers/FeatureLayer",&lt;BR /&gt;"esri/layers/support/FeatureFilter",&lt;BR /&gt;"esri/geometry/Point",&lt;BR /&gt;"esri/request"],&lt;BR /&gt;function(Map,MapView,SimpleMarkerSymbol,PictureMarkerSymbol,Graphic,intl,FeatureLayer,FeatureFilter,Point,esriRequest) {&lt;BR /&gt;&lt;BR /&gt;document.getElementById("nomap").innerHTML = '';&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;console.log(getCookie('maptype'));&lt;BR /&gt;let currentCookie = getCookie('maptype');&lt;BR /&gt;if (currentCookie === false){&lt;BR /&gt;currentCookie = 'oceans';&lt;BR /&gt;}&lt;BR /&gt;//setCookie('maptype',currentCookie,2592000);&lt;BR /&gt;document.getElementById('basemap-selected').value = currentCookie;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;let bmList = {&lt;BR /&gt;'oceans': 'oceans',&lt;BR /&gt;'satellite': 'hybrid',&lt;BR /&gt;'streets': 'streets-vector',&lt;BR /&gt;'topo': 'topo-vector'&lt;BR /&gt;};&lt;BR /&gt;&lt;BR /&gt;let map = new Map({&lt;BR /&gt;basemap: currentCookie&lt;BR /&gt;});&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;const view = new MapView({&lt;BR /&gt;container: "ndbcmap",&lt;BR /&gt;map: map,&lt;BR /&gt;center: [-104,38],&lt;BR /&gt;zoom: 3,&lt;BR /&gt;sliderStyle: "small",&lt;BR /&gt;popup: {&lt;BR /&gt;dockEnabled: false,&lt;BR /&gt;autoOpenEnabled: false,&lt;BR /&gt;visibleElements: {&lt;BR /&gt;closeButton: false,&lt;BR /&gt;featureNavigation: false&lt;BR /&gt;},&lt;BR /&gt;dockOptions: {&lt;BR /&gt;// Disables the dock button from the popup&lt;BR /&gt;buttonEnabled: false,&lt;BR /&gt;// Ignore the default sizes that trigger responsive docking&lt;BR /&gt;breakpoint: false&lt;BR /&gt;}&lt;BR /&gt;},&lt;BR /&gt;highlightOptions: {&lt;BR /&gt;color: [255, 0, 0, 255],&lt;BR /&gt;haloOpacity: 1,&lt;BR /&gt;fillOpacity: 1&lt;BR /&gt;}&lt;BR /&gt;});&lt;BR /&gt;&lt;BR /&gt;let basemapSelected = document.getElementById('basemap-selected');&lt;BR /&gt;basemapSelected.addEventListener('change',function(evt){&lt;BR /&gt;let newBasemap = evt.target.options[evt.target.selectedIndex].value;&lt;BR /&gt;if (newBasemap === "none" || newBasemap == null) {&lt;BR /&gt;map.basemap = "oceans";&lt;BR /&gt;} else {&lt;BR /&gt;// Find the selected basemap in the array above and use the map name to set the basemap&lt;BR /&gt;for (let x in bmList) {&lt;BR /&gt;if (x === newBasemap) {&lt;BR /&gt;map.basemap = newBasemap;&lt;BR /&gt;setCookie('maptype',x,2592000);&lt;BR /&gt;break;&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;});&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;let features = [];&lt;BR /&gt;//let stationsLayerView;&lt;BR /&gt;&lt;BR /&gt;var attr = {};&lt;BR /&gt;attr['layerid'] = 'stationsLayer';&lt;BR /&gt;attr['owner'] = 'Michael Testing';&lt;BR /&gt;attr["id"] = 1;&lt;BR /&gt;attr["name"] = 'Michael Testing';&lt;BR /&gt;&lt;BR /&gt;lon = -90;&lt;BR /&gt;lat = 30;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;let geometryPoint = new Point(lon, lat);&lt;BR /&gt;let graphic = new Graphic({&lt;BR /&gt;geometry: geometryPoint,&lt;BR /&gt;attributes: attr,&lt;BR /&gt;});&lt;BR /&gt;&lt;BR /&gt;features.push(graphic);&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;lon2 = -38;&lt;BR /&gt;lat2 = 8;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;let geometryPoint2 = new Point(lon2, lat2);&lt;BR /&gt;let graphic2 = new Graphic({&lt;BR /&gt;geometry: geometryPoint2,&lt;BR /&gt;attributes: attr,&lt;BR /&gt;visible: false,&lt;BR /&gt;});&lt;BR /&gt;graphic2.visible = false;&lt;BR /&gt;features.push(graphic2);&lt;BR /&gt;console.log(graphic2);&lt;BR /&gt;&lt;BR /&gt;let stationsRenderer = {&lt;BR /&gt;type: "simple",&lt;BR /&gt;symbol: {&lt;BR /&gt;type: "simple-marker",&lt;BR /&gt;style: "diamond",&lt;BR /&gt;color: [ 255, 255, 0, 255 ],&lt;BR /&gt;size: 11,&lt;BR /&gt;outline: {&lt;BR /&gt;color: [30,30,30,255],&lt;BR /&gt;width: 1,&lt;BR /&gt;style: "solid"&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;};&lt;BR /&gt;console.log(features);&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;stationsLayer = new FeatureLayer({&lt;BR /&gt;source: features, // autocast as an array of esri/Graphic&lt;BR /&gt;// create an instance of esri/layers/support/Field for each field object&lt;BR /&gt;objectIdField: "ObjectID",&lt;BR /&gt;outFields: ["*"],&lt;BR /&gt;//popupTemplate: template,&lt;BR /&gt;renderer: stationsRenderer,&lt;BR /&gt;"fields": [{&lt;BR /&gt;"name": "id",&lt;BR /&gt;"alias": "id",&lt;BR /&gt;"type": "integer"&lt;BR /&gt;}, {&lt;BR /&gt;"name": "owner",&lt;BR /&gt;"alias": "owner",&lt;BR /&gt;"type": "string"&lt;BR /&gt;}, {&lt;BR /&gt;"name": "name",&lt;BR /&gt;"alias": "name",&lt;BR /&gt;"type": "string"&lt;BR /&gt;}, {&lt;BR /&gt;"name": "layerid",&lt;BR /&gt;"alias": "layerid",&lt;BR /&gt;"type": "string"&lt;BR /&gt;}&lt;BR /&gt;],&lt;BR /&gt;});&lt;BR /&gt;&lt;BR /&gt;map.add(stationsLayer);&lt;BR /&gt;&lt;BR /&gt;});&lt;/P&gt;</description>
    <pubDate>Wed, 07 Dec 2022 18:03:10 GMT</pubDate>
    <dc:creator>Michael0345</dc:creator>
    <dc:date>2022-12-07T18:03:10Z</dc:date>
    <item>
      <title>setting visible property to false not hiding graphic</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setting-visible-property-to-false-not-hiding/m-p/1238767#M79593</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am currently using ESRI 4.24. In my map, I am attempting to display or hide certain features based upon a user selection. While attempting to do this, I have failed to successfully hide any graphics when setting the visible property equal to false. I will attach some code to give a better example of my problem (this is just an example, not my code with the user selection). As you can see, I have hard coded two graphics and added them to the array "features" and created the layer using "source: features". I have set the visible property to false in two locations, but the graphic2 object still displays on the map anyway. Here is the code:&amp;nbsp;&lt;/P&gt;&lt;P&gt;require([&lt;BR /&gt;"esri/Map",&lt;BR /&gt;"esri/views/MapView",&lt;BR /&gt;"esri/symbols/SimpleMarkerSymbol",&lt;BR /&gt;"esri/symbols/PictureMarkerSymbol",&lt;BR /&gt;"esri/Graphic",&lt;BR /&gt;"esri/intl",&lt;BR /&gt;"esri/layers/FeatureLayer",&lt;BR /&gt;"esri/layers/support/FeatureFilter",&lt;BR /&gt;"esri/geometry/Point",&lt;BR /&gt;"esri/request"],&lt;BR /&gt;function(Map,MapView,SimpleMarkerSymbol,PictureMarkerSymbol,Graphic,intl,FeatureLayer,FeatureFilter,Point,esriRequest) {&lt;BR /&gt;&lt;BR /&gt;document.getElementById("nomap").innerHTML = '';&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;console.log(getCookie('maptype'));&lt;BR /&gt;let currentCookie = getCookie('maptype');&lt;BR /&gt;if (currentCookie === false){&lt;BR /&gt;currentCookie = 'oceans';&lt;BR /&gt;}&lt;BR /&gt;//setCookie('maptype',currentCookie,2592000);&lt;BR /&gt;document.getElementById('basemap-selected').value = currentCookie;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;let bmList = {&lt;BR /&gt;'oceans': 'oceans',&lt;BR /&gt;'satellite': 'hybrid',&lt;BR /&gt;'streets': 'streets-vector',&lt;BR /&gt;'topo': 'topo-vector'&lt;BR /&gt;};&lt;BR /&gt;&lt;BR /&gt;let map = new Map({&lt;BR /&gt;basemap: currentCookie&lt;BR /&gt;});&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;const view = new MapView({&lt;BR /&gt;container: "ndbcmap",&lt;BR /&gt;map: map,&lt;BR /&gt;center: [-104,38],&lt;BR /&gt;zoom: 3,&lt;BR /&gt;sliderStyle: "small",&lt;BR /&gt;popup: {&lt;BR /&gt;dockEnabled: false,&lt;BR /&gt;autoOpenEnabled: false,&lt;BR /&gt;visibleElements: {&lt;BR /&gt;closeButton: false,&lt;BR /&gt;featureNavigation: false&lt;BR /&gt;},&lt;BR /&gt;dockOptions: {&lt;BR /&gt;// Disables the dock button from the popup&lt;BR /&gt;buttonEnabled: false,&lt;BR /&gt;// Ignore the default sizes that trigger responsive docking&lt;BR /&gt;breakpoint: false&lt;BR /&gt;}&lt;BR /&gt;},&lt;BR /&gt;highlightOptions: {&lt;BR /&gt;color: [255, 0, 0, 255],&lt;BR /&gt;haloOpacity: 1,&lt;BR /&gt;fillOpacity: 1&lt;BR /&gt;}&lt;BR /&gt;});&lt;BR /&gt;&lt;BR /&gt;let basemapSelected = document.getElementById('basemap-selected');&lt;BR /&gt;basemapSelected.addEventListener('change',function(evt){&lt;BR /&gt;let newBasemap = evt.target.options[evt.target.selectedIndex].value;&lt;BR /&gt;if (newBasemap === "none" || newBasemap == null) {&lt;BR /&gt;map.basemap = "oceans";&lt;BR /&gt;} else {&lt;BR /&gt;// Find the selected basemap in the array above and use the map name to set the basemap&lt;BR /&gt;for (let x in bmList) {&lt;BR /&gt;if (x === newBasemap) {&lt;BR /&gt;map.basemap = newBasemap;&lt;BR /&gt;setCookie('maptype',x,2592000);&lt;BR /&gt;break;&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;});&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;let features = [];&lt;BR /&gt;//let stationsLayerView;&lt;BR /&gt;&lt;BR /&gt;var attr = {};&lt;BR /&gt;attr['layerid'] = 'stationsLayer';&lt;BR /&gt;attr['owner'] = 'Michael Testing';&lt;BR /&gt;attr["id"] = 1;&lt;BR /&gt;attr["name"] = 'Michael Testing';&lt;BR /&gt;&lt;BR /&gt;lon = -90;&lt;BR /&gt;lat = 30;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;let geometryPoint = new Point(lon, lat);&lt;BR /&gt;let graphic = new Graphic({&lt;BR /&gt;geometry: geometryPoint,&lt;BR /&gt;attributes: attr,&lt;BR /&gt;});&lt;BR /&gt;&lt;BR /&gt;features.push(graphic);&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;lon2 = -38;&lt;BR /&gt;lat2 = 8;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;let geometryPoint2 = new Point(lon2, lat2);&lt;BR /&gt;let graphic2 = new Graphic({&lt;BR /&gt;geometry: geometryPoint2,&lt;BR /&gt;attributes: attr,&lt;BR /&gt;visible: false,&lt;BR /&gt;});&lt;BR /&gt;graphic2.visible = false;&lt;BR /&gt;features.push(graphic2);&lt;BR /&gt;console.log(graphic2);&lt;BR /&gt;&lt;BR /&gt;let stationsRenderer = {&lt;BR /&gt;type: "simple",&lt;BR /&gt;symbol: {&lt;BR /&gt;type: "simple-marker",&lt;BR /&gt;style: "diamond",&lt;BR /&gt;color: [ 255, 255, 0, 255 ],&lt;BR /&gt;size: 11,&lt;BR /&gt;outline: {&lt;BR /&gt;color: [30,30,30,255],&lt;BR /&gt;width: 1,&lt;BR /&gt;style: "solid"&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;};&lt;BR /&gt;console.log(features);&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;stationsLayer = new FeatureLayer({&lt;BR /&gt;source: features, // autocast as an array of esri/Graphic&lt;BR /&gt;// create an instance of esri/layers/support/Field for each field object&lt;BR /&gt;objectIdField: "ObjectID",&lt;BR /&gt;outFields: ["*"],&lt;BR /&gt;//popupTemplate: template,&lt;BR /&gt;renderer: stationsRenderer,&lt;BR /&gt;"fields": [{&lt;BR /&gt;"name": "id",&lt;BR /&gt;"alias": "id",&lt;BR /&gt;"type": "integer"&lt;BR /&gt;}, {&lt;BR /&gt;"name": "owner",&lt;BR /&gt;"alias": "owner",&lt;BR /&gt;"type": "string"&lt;BR /&gt;}, {&lt;BR /&gt;"name": "name",&lt;BR /&gt;"alias": "name",&lt;BR /&gt;"type": "string"&lt;BR /&gt;}, {&lt;BR /&gt;"name": "layerid",&lt;BR /&gt;"alias": "layerid",&lt;BR /&gt;"type": "string"&lt;BR /&gt;}&lt;BR /&gt;],&lt;BR /&gt;});&lt;BR /&gt;&lt;BR /&gt;map.add(stationsLayer);&lt;BR /&gt;&lt;BR /&gt;});&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 18:03:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setting-visible-property-to-false-not-hiding/m-p/1238767#M79593</guid>
      <dc:creator>Michael0345</dc:creator>
      <dc:date>2022-12-07T18:03:10Z</dc:date>
    </item>
    <item>
      <title>Re: setting visible property to false not hiding graphic</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setting-visible-property-to-false-not-hiding/m-p/1238832#M79594</link>
      <description>&lt;P&gt;As mentioned in &lt;A href="https://community.esri.com/t5/arcgis-api-for-javascript-questions/map-not-displaying-renderer-after-adding/m-p/1192266#M77921" target="_self"&gt;this post&lt;/A&gt;, 4.x doesn't give direct access to the underlying data (i.e. graphics) of a FeatureLayer; basically, your graphic reference is a copy of the data it's using internally.&lt;/P&gt;&lt;P&gt;There are other options for dynamically setting visibility; perhaps the best is to use the &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#definitionExpression" target="_self"&gt;definitionExpression&lt;/A&gt; property (e.g. "id&amp;lt;&amp;gt;1").&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 17:57:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/setting-visible-property-to-false-not-hiding/m-p/1238832#M79594</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2022-12-07T17:57:19Z</dc:date>
    </item>
  </channel>
</rss>

