<?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 Featureeffect  issue in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/featureeffect-issue/m-p/1616846#M87187</link>
    <description>&lt;P&gt;&amp;lt;!doctype html&amp;gt;&lt;BR /&gt;&amp;lt;html lang="en"&amp;gt;&lt;BR /&gt;&amp;lt;head&amp;gt;&lt;BR /&gt;&amp;lt;meta charset="utf-8" /&amp;gt;&lt;BR /&gt;&amp;lt;meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" /&amp;gt;&lt;BR /&gt;&amp;lt;title&amp;gt;Intro to FeatureLayer | Sample | ArcGIS Maps SDK for JavaScript 4.33&amp;lt;/title&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;link rel="stylesheet" href="&lt;A href="https://js.arcgis.com/4.33/esri/themes/light/main.css" target="_blank" rel="noopener"&gt;https://js.arcgis.com/4.33/esri/themes/light/main.css&lt;/A&gt;" /&amp;gt;&lt;BR /&gt;&amp;lt;script src="&lt;A href="https://js.arcgis.com/4.33/" target="_blank" rel="noopener"&gt;https://js.arcgis.com/4.33/&lt;/A&gt;"&amp;gt;&amp;lt;/script&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;style&amp;gt;&lt;BR /&gt;html,&lt;/P&gt;&lt;P&gt;let map, view, Programs, Well, Segment, ProgramIds, SegmentIds, WellIds, searchWidget, sketchGeometry, Selectedvalue, results, layer, zoomin, zoomout;&lt;BR /&gt;let sketchRecButton, sketchButton, zoomToSelectButton, clearButton, distanceMeasurement2D, areaMeasurement2D;&lt;BR /&gt;let sketchGeometries = [];&lt;/P&gt;&lt;P&gt;const [MapView, Map, FeatureLayer, ImageryLayer, GroupLayer, GraphicsLayer, Graphic, geometryEngine, Search, Home, Expand, SketchViewModel, geometryEngineAsync, LayerList,&lt;BR /&gt;AreaMeasurement2D, PictureMarkerSymbol, SimpleLineSymbol, Legend, reactiveUtils, AreaMeasurement2DViewModel, DistanceMeasurement2D, BasemapToggle] =&lt;BR /&gt;await $arcgis.import(["@arcgis/core/views/MapView.js", "@arcgis/core/Map.js", "@arcgis/core/layers/FeatureLayer.js", "@arcgis/core/layers/ImageryLayer.js", "@arcgis/core/layers/GroupLayer.js",&lt;BR /&gt;"@arcgis/core/layers/GraphicsLayer.js", "@arcgis/core/Graphic.js", "@arcgis/core/geometry/geometryEngine.js", "@arcgis/core/widgets/Search.js",&lt;BR /&gt;"@arcgis/core/widgets/Home.js", "@arcgis/core/widgets/Expand.js", "@arcgis/core/widgets/Sketch/SketchViewModel", "@arcgis/core/geometry/geometryEngineAsync.js",&lt;BR /&gt;"@arcgis/core/widgets/LayerList.js", "@arcgis/core/widgets/AreaMeasurement2D.js", "@arcgis/core/symbols/PictureMarkerSymbol.js", "@arcgis/core/symbols/SimpleLineSymbol.js",&lt;BR /&gt;"@arcgis/core/widgets/Legend.js", "@arcgis/core/core/reactiveUtils.js", "@arcgis/core/widgets/AreaMeasurement2D.js", "@arcgis/core/widgets/DistanceMeasurement2D.js",&lt;BR /&gt;"@arcgis/core/widgets/BasemapToggle.js"&lt;BR /&gt;]);&lt;/P&gt;&lt;P&gt;import { wellRenderer, segmentRenderer, boundaryRenderer, configLayers, sources, popupWellheads, labelClass } from '/js/renderer.js';&lt;/P&gt;&lt;P&gt;//Well = new FeatureLayer({ url: "&lt;A href="https://ucwgis00001.aramco.com/arcgisserver/rest/services/URGIS/WellsUTM/MapServer/0" target="_blank"&gt;https://ucwgis00001.aramco.com/arcgisserver/rest/services/URGIS/WellsUTM/MapServer/0&lt;/A&gt;", labelingInfo: [labelClass], renderer: wellRenderer });&lt;BR /&gt;//Segment = new FeatureLayer({ url: "&lt;A href="https://ucwgis00001.aramco.com/arcgisserver/rest/services/URGIS/URSegments/MapServer/0" target="_blank"&gt;https://ucwgis00001.aramco.com/arcgisserver/rest/services/URGIS/URSegments/MapServer/0&lt;/A&gt;" });&lt;BR /&gt;let savedAssetsInfo = [];&lt;BR /&gt;const polygonGraphicsLayer = new GraphicsLayer();&lt;/P&gt;&lt;P&gt;export class renderMaps {&lt;BR /&gt;static dotNetHelper;&lt;BR /&gt;static setDotNetHelper(value) {&lt;BR /&gt;renderMap.dotNetHelper = value;&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;export function renderMapValue(value) {&lt;BR /&gt;if (value !== null &amp;amp;&amp;amp; value !== undefined) {&lt;BR /&gt;Selectedvalue = value;&lt;BR /&gt;//console.log(`SelectedValue: ${value}`);&lt;BR /&gt;} else {&lt;BR /&gt;// console.log("No value selected");&lt;BR /&gt;Selectedvalue = "Well";&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;export async function renderMap() {&lt;BR /&gt;&lt;BR /&gt;const mapImage = document.getElementById("map-image");&lt;BR /&gt;const loader = document.getElementById("loader");&lt;BR /&gt;//mapImage.style.display = "block";&lt;BR /&gt;//loader.style.display = "flex";&lt;BR /&gt;if (mapImage) {mapImage.style.display = "block"; }&lt;BR /&gt;if (loader) {loader.style.display = "flex";}&lt;BR /&gt;if (!mapImage || !loader) {console.error("Either map-image or loader element was not found.");}&lt;/P&gt;&lt;P&gt;//satellite&lt;BR /&gt;map = new Map({ basemap: "satellite" });&lt;BR /&gt;view = new MapView({&lt;BR /&gt;map: map,&lt;BR /&gt;center: [35, 26],&lt;BR /&gt;zoom: 6,&lt;BR /&gt;container: "view-div",&lt;BR /&gt;ui: {&lt;BR /&gt;components: ["attribution"] // Only show attribution, hide zoom widget&lt;BR /&gt;}&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;let basemapToggle = new BasemapToggle({&lt;BR /&gt;view: view, // The view that provides access to the map's "streets-vector" basemap&lt;BR /&gt;nextBasemap: "hybrid" // Allows for toggling to the "hybrid" basemap&lt;BR /&gt;});&lt;BR /&gt;// Wait for view to be ready&lt;BR /&gt;await view.when();&lt;BR /&gt;&lt;BR /&gt;// Add feature layers&lt;BR /&gt;if (configLayers) {&lt;BR /&gt;configLayers.forEach((layerInfo) =&amp;gt; {&lt;BR /&gt;let layer;&lt;BR /&gt;switch (layerInfo.id) {&lt;BR /&gt;case "Segment":&lt;BR /&gt;layer = new FeatureLayer({ id: layerInfo.id, url: layerInfo.url, renderer: segmentRenderer });&lt;BR /&gt;Segment = layer;&lt;BR /&gt;break;&lt;BR /&gt;case "Well":&lt;BR /&gt;layer = new FeatureLayer({ id: layerInfo.id, url: layerInfo.url, labelingInfo: [labelClass], renderer: wellRenderer, popupTemplate: popupWellheads });&lt;BR /&gt;Well = layer;&lt;BR /&gt;break;&lt;BR /&gt;case "boundary":&lt;BR /&gt;layer = new FeatureLayer({ id: layerInfo.id, url: layerInfo.url, renderer: boundaryRenderer });&lt;BR /&gt;break;&lt;BR /&gt;default:&lt;BR /&gt;console.error(`Unknown layer ID: ${layerInfo.id}`);&lt;BR /&gt;return;&lt;BR /&gt;}&lt;BR /&gt;map.add(layer);&lt;BR /&gt;});&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// Add polygon graphics layer&lt;BR /&gt;map.add(polygonGraphicsLayer);&lt;/P&gt;&lt;P&gt;// Wait for layers to be loaded&lt;BR /&gt;await Promise.all(configLayers.map((layerInfo) =&amp;gt; map.findLayerById(layerInfo.id).when()));&lt;/P&gt;&lt;P&gt;await view.watch("updating", (updating) =&amp;gt; {&lt;BR /&gt;if (!updating) {&lt;BR /&gt;// This function will execute once the map stops updating (is fully loaded/rendered)&lt;BR /&gt;console.log("Map is fully loaded and stationary.");&lt;BR /&gt;mapImage.style.display = "none"; // Hide the low-opacity image&lt;BR /&gt;loader.style.display = "none";&lt;BR /&gt;const viewDiv = document.getElementById("view-div");&lt;BR /&gt;if (viewDiv) {&lt;BR /&gt;viewDiv.style.opacity = 1;&lt;BR /&gt;const legendLabels = document.querySelectorAll('.esri-legend__layer-cell.esri-legend__layer-cell--info');&lt;BR /&gt;// console.log(legendLabels); // Check if the elements are being found&lt;BR /&gt;legendLabels.forEach((label) =&amp;gt; {&lt;BR /&gt;if (label.textContent === 'Segments') {&lt;BR /&gt;console.log("Segment selected");&lt;BR /&gt;const previousElementSibling = label.previousElementSibling;&lt;BR /&gt;previousElementSibling.style.backgroundColor = "#9028F180";&lt;BR /&gt;previousElementSibling.style.height = '26px';&lt;BR /&gt;previousElementSibling.style.width= '26px';&lt;BR /&gt;previousElementSibling.style.borderTop = '2px solid #9028F1';&lt;BR /&gt;}&lt;BR /&gt;});&lt;BR /&gt;const legendsymbol = document.querySelectorAll('.esri-legend__layer-cell.esri-legend__layer-cell--symbols');&lt;BR /&gt;/*console.log(legendsymbol);*/&lt;BR /&gt;legendsymbol.forEach((symbol) =&amp;gt; {&lt;BR /&gt;//console.log(symbol.lastChild.firstChild.firstChild.ariaLabel);&lt;BR /&gt;if (symbol.lastChild.firstChild.firstChild.ariaLabel == "Preview for Segments") {&lt;BR /&gt;symbol.lastChild.firstChild.style.opacity = 0;&lt;BR /&gt;}&lt;BR /&gt;});&lt;BR /&gt;} else {&lt;BR /&gt;console.error("view-div element was not found.");&lt;BR /&gt;// You can also add additional error handling or fallback behavior here&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;});&lt;BR /&gt;// Add search widget&lt;BR /&gt;const searchWidget = new Search({&lt;BR /&gt;view: view,&lt;BR /&gt;sources: sources,&lt;BR /&gt;includeDefaultSources: false,&lt;BR /&gt;locationEnabled: false,&lt;BR /&gt;allPlaceholder: "Search By ID and Name..."&lt;BR /&gt;});&lt;BR /&gt;const expandSearch = new Expand({ content: searchWidget, view: view, expanded: false, expandIcon: "search" });&lt;BR /&gt;view.ui.add(expandSearch, { position: "top-right" });&lt;/P&gt;&lt;P&gt;//const polygonLayers = configLayers.filter((layerInfo) =&amp;gt; ["Segment", "boundary"].includes(layerInfo.id));&lt;BR /&gt;const polygonLayers = configLayers.filter((layerInfo) =&amp;gt; ["Segment"].includes(layerInfo.id));&lt;BR /&gt;const polygonGroupLayer = new GroupLayer({&lt;BR /&gt;id: "polygons",&lt;BR /&gt;title: "Polygons",&lt;BR /&gt;layers: polygonLayers.map((layerInfo) =&amp;gt; map.findLayerById(layerInfo.id))&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;map.add(polygonGroupLayer,0);&lt;/P&gt;&lt;P&gt;const legend = new Legend({&lt;BR /&gt;view: view,&lt;BR /&gt;layerInfos: configLayers.reduce((acc, layerInfo) =&amp;gt; {&lt;BR /&gt;const layer = map.findLayerById(layerInfo.id);&lt;BR /&gt;if (layerInfo.id === "Well") {&lt;BR /&gt;acc.push({ layer: layer, title: "Legends" });&lt;BR /&gt;} else if (["Segment"].includes(layerInfo.id)) {&lt;BR /&gt;acc.push({ layer: layer, title: "" }); // Hide the layer title&lt;BR /&gt;}&lt;BR /&gt;return acc;&lt;BR /&gt;}, []).concat([&lt;BR /&gt;{ layer: polygonGroupLayer, title: "Polygons" }&lt;BR /&gt;])&lt;BR /&gt;});&lt;BR /&gt;const expandLegend = new Expand({ content: legend, view: view, expanded: false, expandIcon: "information", collapseIcon:"information" });&lt;BR /&gt;view.ui.add(expandLegend, "top-right");&lt;/P&gt;&lt;P&gt;const addedLayerTitles = new Set();&lt;BR /&gt;// Create a new div to hold the layer list&lt;BR /&gt;const layerListDiv = document.createElement("div");&lt;BR /&gt;layerListDiv.id = "layer-list-div";&lt;BR /&gt;layerListDiv.style.width="300px";&lt;BR /&gt;layerListDiv.style.height="max-content";&lt;BR /&gt;layerListDiv.style.paddingLeft = "10px";&lt;/P&gt;&lt;P&gt;// Create a new LayerList&lt;BR /&gt;const layerList = new LayerList({&lt;BR /&gt;view: view,&lt;BR /&gt;visibilityAppearance: "none",&lt;BR /&gt;listItemCreatedFunction: (event) =&amp;gt; {&lt;BR /&gt;const item = event.item;&lt;/P&gt;&lt;P&gt;if (item.layer.type === "basemap") {&lt;BR /&gt;return;&lt;BR /&gt;}&lt;BR /&gt;if (item.layer.title === "URSegments") {&lt;BR /&gt;item.layer.title = "Segment";&lt;BR /&gt;} else if (item.layer.title === "WellsUTM") {&lt;BR /&gt;item.layer.title = "Well";&lt;BR /&gt;}&lt;BR /&gt;else if (item.layer.title === null || item.layer.title === "Polygons") {&lt;BR /&gt;return;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;if (addedLayerTitles.has(item.layer.title)) {&lt;BR /&gt;return;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;addedLayerTitles.add(item.layer.title);&lt;/P&gt;&lt;P&gt;// Create a custom checkbox element&lt;BR /&gt;const checkbox = document.createElement("input");&lt;BR /&gt;checkbox.type = "checkbox";&lt;BR /&gt;checkbox.id = "checkbox-" + item.layer.id;&lt;BR /&gt;checkbox.checked = item.visible; // Set initial state&lt;/P&gt;&lt;P&gt;// Add an event listener to manage layer visibility&lt;BR /&gt;checkbox.addEventListener("change", () =&amp;gt; {&lt;BR /&gt;item.visible = checkbox.checked;&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;// Watch the item's visibility property to keep the checkbox in sync&lt;BR /&gt;// with other potential visibility changes (e.g., zoom level changes)&lt;BR /&gt;reactiveUtils.watch(() =&amp;gt; item.visible, (visible) =&amp;gt; {&lt;BR /&gt;checkbox.checked = visible;&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;// Create a container for the label and checkbox&lt;BR /&gt;const container = document.createElement("div");&lt;BR /&gt;container.style.display = "flex";&lt;BR /&gt;container.style.justifyContent = "space-between";&lt;BR /&gt;container.style.alignItems = "center";&lt;BR /&gt;container.style.marginBottom = "10px";&lt;/P&gt;&lt;P&gt;const label = document.createElement("span");&lt;BR /&gt;label.textContent = item.layer.title;&lt;BR /&gt;container.appendChild(label);&lt;/P&gt;&lt;P&gt;container.appendChild(checkbox);&lt;/P&gt;&lt;P&gt;// Append the container to the layer list div&lt;BR /&gt;layerListDiv.appendChild(container);&lt;/P&gt;&lt;P&gt;// Add CSS rule to change checkbox checked color to green&lt;BR /&gt;const style = document.createElement("style");&lt;BR /&gt;style.innerHTML = `input[type="checkbox"] {&lt;BR /&gt;accent-color: green;&lt;BR /&gt;width: 20px;&lt;BR /&gt;height: 20px;&lt;BR /&gt;}&lt;BR /&gt;input[type="checkbox"]:checked {&lt;BR /&gt;accent-color: green;&lt;BR /&gt;}`;&lt;BR /&gt;document.head.appendChild(style);&lt;BR /&gt;}&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;// Add the layer list div to the view&lt;BR /&gt;view.container.appendChild(layerListDiv);&lt;/P&gt;&lt;P&gt;const expandLayerList = new Expand({&lt;BR /&gt;content: layerListDiv,&lt;BR /&gt;view: view,&lt;BR /&gt;expanded: false,&lt;BR /&gt;expandIcon: "layers"&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;view.ui.add(expandLayerList, { position: "top-right" });&lt;/P&gt;&lt;P&gt;distanceMeasurement2D = new DistanceMeasurement2D({&lt;BR /&gt;view,&lt;BR /&gt;visible: false,&lt;BR /&gt;});&lt;BR /&gt;areaMeasurement2D = new AreaMeasurement2DViewModel({&lt;BR /&gt;view,&lt;BR /&gt;visible: false,&lt;BR /&gt;});&lt;BR /&gt;// Retrieve button elements&lt;BR /&gt;const recButton = document.getElementById("select-by-rectangle");&lt;BR /&gt;const polyButton = document.getElementById("select-by-freehandpolygon");&lt;BR /&gt;zoomToSelectButton = document.getElementById("zoomtoSelect");&lt;BR /&gt;clearButton = document.getElementById("Clear");&lt;BR /&gt;zoomin = document.getElementById("zoomInButton");&lt;BR /&gt;zoomout = document.getElementById("zoomOutButton");&lt;/P&gt;&lt;P&gt;//zoomIn.addEventListener('click', zoomIn);&lt;BR /&gt;//zoomout.addEventListener('click', zoomIn);&lt;BR /&gt;zoomToSelectButton.style.opacity = 0.5;&lt;BR /&gt;clearButton.style.opacity = 0.5;&lt;/P&gt;&lt;P&gt;const areaButton = document.getElementById("areaButton");&lt;BR /&gt;const distanceButton = document.getElementById("distanceButton");&lt;BR /&gt;const measureClearButton = document.getElementById("measureClearButton");&lt;/P&gt;&lt;P&gt;// Add draw tool widget&lt;BR /&gt;const measureToolWidget = document.createElement("div");&lt;BR /&gt;measureToolWidget.classList.add("esri-widget", "draw-tool-widget");&lt;BR /&gt;measureToolWidget.style.display = "flex";&lt;BR /&gt;measureToolWidget.style.flexDirection = "column";&lt;/P&gt;&lt;P&gt;const buttonsmeasure = ["areaButton", "distanceButton","measureClearButton"];&lt;BR /&gt;buttonsmeasure.forEach((id) =&amp;gt; {&lt;BR /&gt;const button = document.getElementById(id);&lt;BR /&gt;if (button) {&lt;BR /&gt;measureToolWidget.appendChild(button);&lt;BR /&gt;button.addEventListener("click", () =&amp;gt; {&lt;BR /&gt;switch (id) {&lt;BR /&gt;case "areaButton":&lt;BR /&gt;break;&lt;BR /&gt;case "distanceButton":&lt;BR /&gt;break;&lt;BR /&gt;case "measureClearButton":&lt;BR /&gt;break;&lt;BR /&gt;}&lt;BR /&gt;});&lt;BR /&gt;}&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;const expandDraw = new Expand({ content: measureToolWidget, view: view, expanded: false, expandIcon: "measure" });&lt;BR /&gt;view.ui.add(expandDraw, { position: "top-right" });&lt;/P&gt;&lt;P&gt;// event listener for distance measurements&lt;BR /&gt;distanceButton.addEventListener("click", function () {&lt;BR /&gt;setActiveWidget(null);&lt;BR /&gt;if (!this.classList.contains("active")) {&lt;BR /&gt;setActiveWidget("distance");&lt;BR /&gt;} else {&lt;BR /&gt;setActiveButton(null);&lt;BR /&gt;}&lt;BR /&gt;});&lt;BR /&gt;// event listener for area measurements&lt;BR /&gt;areaButton.addEventListener("click", function () {&lt;BR /&gt;setActiveWidget(null);&lt;BR /&gt;if (!this.classList.contains("active")) {&lt;BR /&gt;setActiveWidget("area");&lt;BR /&gt;} else {&lt;BR /&gt;setActiveButton(null);&lt;BR /&gt;}&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;measureClearButton.addEventListener("click", function () {&lt;BR /&gt;setActiveWidget(null);&lt;BR /&gt;});&lt;BR /&gt;// Array of buttons for easier management&lt;BR /&gt;const buttons = [recButton, polyButton, zoomToSelectButton, clearButton];&lt;/P&gt;&lt;P&gt;// Add event listeners to buttons&lt;BR /&gt;buttons.forEach((button) =&amp;gt; {&lt;BR /&gt;if (button) {&lt;BR /&gt;button.addEventListener("click", () =&amp;gt; {&lt;BR /&gt;switch (button.id) {&lt;BR /&gt;case "select-by-rectangle":&lt;BR /&gt;// polygonGraphicsLayer.removeAll();&lt;BR /&gt;sketchViewModel.create("rectangle");&lt;BR /&gt;break;&lt;BR /&gt;case "select-by-freehandpolygon":&lt;BR /&gt;//polygonGraphicsLayer.removeAll();&lt;BR /&gt;sketchViewModel.create("polygon");&lt;BR /&gt;break;&lt;BR /&gt;case "zoomtoSelect":&lt;BR /&gt;zoomtoFeature();&lt;BR /&gt;break;&lt;BR /&gt;case "Clear":&lt;BR /&gt;clearSelection();&lt;BR /&gt;break;&lt;BR /&gt;}&lt;BR /&gt;});&lt;BR /&gt;}&lt;BR /&gt;});&lt;BR /&gt;// Add buttons to the view&lt;BR /&gt;buttons.forEach((button) =&amp;gt; {&lt;BR /&gt;view.ui.add(button, { position: "top-right" });&lt;BR /&gt;});&lt;BR /&gt;// Add sketch view model&lt;BR /&gt;const sketchViewModel = new SketchViewModel({&lt;BR /&gt;view: view,&lt;BR /&gt;layer: polygonGraphicsLayer,&lt;BR /&gt;updateOnGraphicClick: false,&lt;BR /&gt;});&lt;BR /&gt;sketchViewModel.on("create", (event) =&amp;gt; {&lt;BR /&gt;if (event.state === "complete") {&lt;BR /&gt;sketchGeometry = event.graphic.geometry;&lt;BR /&gt;sketchGeometries.push(event.graphic.geometry);&lt;BR /&gt;//view.graphics.removeAll();&lt;BR /&gt;//polygonGraphicsLayer.removeAll();&lt;BR /&gt;//savedAssetsInfo = [];&lt;/P&gt;&lt;P&gt;if (configLayers) {&lt;BR /&gt;const selectedLayer = configLayers.find((layerInfo) =&amp;gt; layerInfo.id === Selectedvalue);&lt;BR /&gt;if (selectedLayer) {&lt;BR /&gt;selectFeatures(selectedLayer, sketchGeometries);&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;// Remove empty layers&lt;BR /&gt;layerList.when(() =&amp;gt; {&lt;BR /&gt;layerList.operationalItems.forEach((item) =&amp;gt; {&lt;BR /&gt;if (item.layer.title === null) layerList.view.map.remove(item.layer);&lt;BR /&gt;});&lt;BR /&gt;});&lt;BR /&gt;view.ui.add(zoomin, { position: "top-right" });&lt;BR /&gt;view.ui.add(new Home({ view: view }), { position: "top-right"});&lt;BR /&gt;view.ui.add(zoomout, { position: "top-right" });&lt;BR /&gt;// zoomin.addEventListener()&lt;BR /&gt;zoomin.addEventListener("click", function () { zoomIn(); });&lt;BR /&gt;zoomout.addEventListener("click", function () { zoomOut(); });&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;export async function queryLayers(assetSegmentIds) {&lt;BR /&gt;removeGraphics();&lt;BR /&gt;const wells = assetSegmentIds.filter(item =&amp;gt; item.assetType === "Well");&lt;BR /&gt;const segments = assetSegmentIds.filter(item =&amp;gt; item.assetType === "Segment");&lt;/P&gt;&lt;P&gt;polygonGraphicsLayer.removeAll();&lt;BR /&gt;let programsGraphicsLayer = new GraphicsLayer();&lt;BR /&gt;let wellsGraphicsLayer = new GraphicsLayer();&lt;BR /&gt;let segmentsGraphicsLayer = new GraphicsLayer();&lt;/P&gt;&lt;P&gt;switch (Selectedvalue) {&lt;BR /&gt;case "Segment":&lt;BR /&gt;SegmentIds = segments.map(item =&amp;gt; "'" + item.parentAsset.id + "'");&lt;BR /&gt;queryAndAddGraphics(Segment, segmentsGraphicsLayer, "URECD.URSegmentTable.SEGMENT_ID", SegmentIds);&lt;BR /&gt;break;&lt;BR /&gt;case "Well":&lt;BR /&gt;WellIds = wells.map(item =&amp;gt; "'" + item.parentAsset.id + "'");&lt;BR /&gt;queryAndAddGraphics(Well, wellsGraphicsLayer, "URECD.URGIS_Wells.WELL_ID", WellIds);&lt;BR /&gt;break;&lt;BR /&gt;default:&lt;BR /&gt;// You can add a default case to handle any other values&lt;BR /&gt;console.log("No matching case found");&lt;BR /&gt;break;&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;let addedGraphics = []; // Initialize an empty array to store added graphics&lt;/P&gt;&lt;P&gt;async function queryAndAddGraphics(layer, graphicsLayer, whereClause, ids) {&lt;BR /&gt;if (ids !== "" &amp;amp;&amp;amp; ids.length) {&lt;BR /&gt;const query = {&lt;BR /&gt;where: whereClause + " IN (" + ids + ")",&lt;BR /&gt;returnGeometry: true&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;try {&lt;BR /&gt;const results = await layer.queryFeatures(query);&lt;BR /&gt;if (results) {&lt;BR /&gt;addGraphics(results);&lt;BR /&gt;enableButtonsfromComponent(results);&lt;BR /&gt;}&lt;BR /&gt;} catch (error) {&lt;BR /&gt;console.error(error);&lt;BR /&gt;}&lt;BR /&gt;} else if (savedAssetsInfo.length === 0) {&lt;BR /&gt;// console.log("Map features selected");&lt;BR /&gt;} else if (typeof removeGraphics === 'function') {&lt;BR /&gt;removeGraphics();&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;function addGraphics(results) {&lt;BR /&gt;if (results.features.length &amp;gt; 0) {&lt;BR /&gt;const symbol = getSymbol(results.features[0].geometry.type);&lt;/P&gt;&lt;P&gt;// Check if graphics already exist in the layer&lt;BR /&gt;const existingGraphics = new Set(view.graphics.items.map(graphic =&amp;gt; graphic.geometry));&lt;BR /&gt;const newGraphics = results.features.filter(feature =&amp;gt; {&lt;BR /&gt;return !existingGraphics.has(feature.geometry);&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;if (newGraphics.length &amp;gt; 0) {&lt;BR /&gt;const graphics = newGraphics.map((feature) =&amp;gt; {&lt;BR /&gt;const graphic = new Graphic();&lt;BR /&gt;graphic.geometry = feature.geometry;&lt;BR /&gt;graphic.symbol = symbol;&lt;BR /&gt;return graphic;&lt;BR /&gt;});&lt;BR /&gt;addedGraphics.push(...graphics);&lt;BR /&gt;view.graphics.addMany(graphics);&lt;BR /&gt;}&lt;BR /&gt;} else {&lt;BR /&gt;// Clear the graphics in the layer if the query is empty&lt;BR /&gt;view.graphics.removeAll();&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;function getSymbol(geometryType) {&lt;BR /&gt;switch (geometryType) {&lt;BR /&gt;case "point":&lt;BR /&gt;return {&lt;BR /&gt;type: "simple-marker",&lt;BR /&gt;color: "#17CBE8",&lt;BR /&gt;size: 10,&lt;BR /&gt;};&lt;BR /&gt;case "polygon":&lt;BR /&gt;return {&lt;BR /&gt;type: "simple-fill",&lt;BR /&gt;color: "#8FA6FA",&lt;BR /&gt;opacity: 0.7,&lt;BR /&gt;outline: {&lt;BR /&gt;color: [128, 128, 128, 0.5],&lt;BR /&gt;width: "0.5px"&lt;BR /&gt;}&lt;BR /&gt;};&lt;BR /&gt;default:&lt;BR /&gt;throw new Error(`Unsupported geometry type: ${geometryType}`);&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;function removeGraphics() {&lt;BR /&gt;view.graphics.removeAll();&lt;BR /&gt;clearAddedGraphics();&lt;BR /&gt;}&lt;BR /&gt;function clearAddedGraphics() {&lt;BR /&gt;addedGraphics = [];&lt;BR /&gt;}&lt;BR /&gt;function zoomtoFeature() {&lt;BR /&gt;if (view.graphics.length &amp;gt; 0) {&lt;BR /&gt;view.goTo(view.graphics);&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;function clearSelection() {&lt;BR /&gt;results = { features: [] };&lt;BR /&gt;addGraphics(results);&lt;BR /&gt;polygonGraphicsLayer.removeAll();&lt;BR /&gt;view.graphics.removeAll();&lt;BR /&gt;polygonGraphicsLayer.removeAll();&lt;BR /&gt;removeGraphics();&lt;BR /&gt;savedAssetsInfo = [];&lt;BR /&gt;enableButtons(savedAssetsInfo);&lt;BR /&gt;sendArrayListToCSharp(savedAssetsInfo);&lt;BR /&gt;sketchGeometries = [];&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;async function selectFeatures(layerInfo, _geometry) {&lt;BR /&gt;const savedAssetsInfo = []; // Declare locally&lt;BR /&gt;const layer = map.findLayerById(layerInfo.id);&lt;/P&gt;&lt;P&gt;if (Selectedvalue === layerInfo.id) {&lt;BR /&gt;const unionGeometry = geometryEngine.union(_geometry);&lt;BR /&gt;try {&lt;BR /&gt;const query = {&lt;BR /&gt;geometry: unionGeometry,&lt;BR /&gt;spatialRelationship: "intersects",&lt;BR /&gt;returnGeometry: true,&lt;BR /&gt;outFields: ["*"],&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;const results = await layer.queryFeatures(query);&lt;/P&gt;&lt;P&gt;let object2 = {&lt;BR /&gt;assetName: layer.title,&lt;BR /&gt;featuresInfo: []&lt;BR /&gt;};&lt;BR /&gt;let featuresInfo2 = [];&lt;BR /&gt;let id;&lt;/P&gt;&lt;P&gt;if (results.features.length &amp;gt; 0) {&lt;BR /&gt;addGraphics(results);&lt;BR /&gt;const findsavedAssetsInfo = savedAssetsInfo.find(item =&amp;gt; item.assetName === layerInfo.id);&lt;BR /&gt;if (!findsavedAssetsInfo) {&lt;BR /&gt;//#region Saved Asset Info&lt;/P&gt;&lt;P&gt;for (let i = 0; i &amp;lt; results.features.length; i++) {&lt;BR /&gt;if (object2.assetName === "Well") {&lt;BR /&gt;id = results.features[i].attributes["URECD.URGIS_Wells.WELL_ID"];&lt;BR /&gt;} else if (object2.assetName === "Segment") {&lt;BR /&gt;id = results.features[i].attributes["URECD.URSegmentTable.SEGMENT_ID"];&lt;BR /&gt;}&lt;BR /&gt;featuresInfo2.push({&lt;BR /&gt;id: id,&lt;BR /&gt;//attributes: results.features[i].attributes,&lt;BR /&gt;isSelected: true&lt;BR /&gt;});&lt;BR /&gt;}&lt;BR /&gt;object2.featuresInfo = featuresInfo2;&lt;BR /&gt;savedAssetsInfo.push(object2);&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;catch (error) {&lt;BR /&gt;console.error("Error querying features:", error);&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;else {&lt;BR /&gt;// Clear the graphics in the layer if it's not selected&lt;BR /&gt;view.graphics.removeAll();&lt;BR /&gt;}&lt;BR /&gt;enableButtons(savedAssetsInfo);&lt;BR /&gt;sendArrayListToCSharp(savedAssetsInfo);&lt;BR /&gt;}&lt;BR /&gt;function sendArrayListToCSharp(arrayList) {&lt;BR /&gt;//view.graphics.removeAll();&lt;BR /&gt;// Convert the ArrayList to a JSON string&lt;BR /&gt;let json = JSON.stringify(arrayList);&lt;BR /&gt;renderMap.dotNetHelper.invokeMethodAsync("SendArrayListToCSharp", json)&lt;BR /&gt;.then(result =&amp;gt; console.log(result))&lt;BR /&gt;.catch(error =&amp;gt; console.error(error));&lt;BR /&gt;}&lt;BR /&gt;function enableButtons(arrayList) {&lt;BR /&gt;if (arrayList.length &amp;gt; 0) {&lt;BR /&gt;//zoomToSelectButton.style.backgroundColor = "white";&lt;BR /&gt;//clearButton.style.backgroundColor = "white";&lt;BR /&gt;zoomToSelectButton.style.opacity = 1;&lt;BR /&gt;clearButton.style.opacity = 1;&lt;BR /&gt;} else {&lt;BR /&gt;zoomToSelectButton.style.opacity = 0.5;&lt;BR /&gt;clearButton.style.opacity = 0.5;&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;function enableButtonsfromComponent(arrayList) {&lt;BR /&gt;if (arrayList.features.length &amp;gt; 0) {&lt;BR /&gt;//zoomToSelectButton.style.backgroundColor = "white";&lt;BR /&gt;//clearButton.style.backgroundColor = "white";&lt;BR /&gt;zoomToSelectButton.style.opacity = 1;&lt;BR /&gt;clearButton.style.opacity = 1;&lt;BR /&gt;} else {&lt;BR /&gt;zoomToSelectButton.style.opacity = 0.5;&lt;BR /&gt;clearButton.style.opacity = 0.5;&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;function setActiveWidget(type) {&lt;BR /&gt;switch (type) {&lt;BR /&gt;case "distance":&lt;BR /&gt;areaMeasurement2D.visible = false;&lt;BR /&gt;distanceMeasurement2D.visible = true;&lt;BR /&gt;distanceMeasurement2D.viewModel.start();&lt;BR /&gt;setActiveButton(document.getElementById("distanceButton"));&lt;BR /&gt;break;&lt;BR /&gt;case "area":&lt;BR /&gt;distanceMeasurement2D.visible = false;&lt;BR /&gt;areaMeasurement2D.visible = true;&lt;BR /&gt;areaMeasurement2D.viewModel.start();&lt;BR /&gt;setActiveButton(document.getElementById("areaButton"));&lt;BR /&gt;break;&lt;BR /&gt;case null:&lt;BR /&gt;areaMeasurement2D.visible = false;&lt;BR /&gt;distanceMeasurement2D.visible = false;&lt;BR /&gt;break;&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;function setActiveButton(selectedButton) {&lt;BR /&gt;// focus the view to activate keyboard shortcuts for sketching&lt;BR /&gt;view.focus();&lt;BR /&gt;let elements = document.getElementsByClassName("active");&lt;BR /&gt;for (let i = 0; i &amp;lt; elements.length; i++) {&lt;BR /&gt;elements[i].classList.remove("active");&lt;BR /&gt;}&lt;BR /&gt;if (selectedButton) {&lt;BR /&gt;selectedButton.classList.add("active");&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// Function to handle zooming in&lt;BR /&gt;function zoomIn() {&lt;BR /&gt;// Increase the zoom level by 1&lt;BR /&gt;let newZoom = view.zoom + 1;&lt;BR /&gt;view.goTo({&lt;BR /&gt;// target: view.center,&lt;BR /&gt;zoom: newZoom&lt;BR /&gt;});&lt;BR /&gt;}&lt;BR /&gt;// Function to handle zooming out&lt;BR /&gt;function zoomOut() {&lt;BR /&gt;// Decrease the zoom level by 1&lt;BR /&gt;let newZoom = view.zoom - 0.5;&lt;BR /&gt;view.goTo({&lt;BR /&gt;// target: view.center,&lt;BR /&gt;zoom: newZoom&lt;BR /&gt;});&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;body,&lt;BR /&gt;#viewDiv {&lt;BR /&gt;padding: 0;&lt;BR /&gt;margin: 0;&lt;BR /&gt;height: 100%;&lt;BR /&gt;width: 100%;&lt;BR /&gt;}&lt;BR /&gt;ul {&lt;BR /&gt;display: flex;&lt;BR /&gt;flex-direction: column;&lt;BR /&gt;gap: 5px;&lt;BR /&gt;}&lt;BR /&gt;&amp;lt;/style&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;script type="module"&amp;gt;&lt;BR /&gt;const [Map, MapView, FeatureLayer,Legend] = await $arcgis.import([&lt;BR /&gt;"@arcgis/core/Map.js",&lt;BR /&gt;"@arcgis/core/views/MapView.js",&lt;BR /&gt;"@arcgis/core/layers/FeatureLayer.js",&lt;BR /&gt;"@arcgis/core/widgets/Legend.js",&lt;BR /&gt;]);&lt;/P&gt;&lt;P&gt;const map = new Map({&lt;BR /&gt;basemap: "hybrid",&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;const view = new MapView({&lt;BR /&gt;container: "viewDiv",&lt;BR /&gt;map: map,&lt;BR /&gt;center:[-73.935242,40.730610],&lt;BR /&gt;zoom:10&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;const featureLayer = new FeatureLayer({&lt;BR /&gt;url: "&lt;A href="https://services.arcgis.com/V6ZHFr6zdgNZuVG0/ArcGIS/rest/services/NY%20Educational%20Attainment/FeatureServer/0" target="_blank" rel="noopener"&gt;https://services.arcgis.com/V6ZHFr6zdgNZuVG0/ArcGIS/rest/services/NY%20Educational%20Attainment/FeatureServer/0&lt;/A&gt;",&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;map.add(featureLayer);&lt;/P&gt;&lt;P&gt;view.when(()=&amp;gt;{&lt;BR /&gt;//#region Default Legend&lt;BR /&gt;featureLayer.when(() =&amp;gt; {&lt;BR /&gt;console.log(featureLayer);&lt;BR /&gt;var divCustomLegend=document.getElementById("divCustomLegend");&lt;BR /&gt;const lebel=document.createElement("label");&lt;BR /&gt;lebel.textContent="NY Educational Attainment";&lt;BR /&gt;divCustomLegend.appendChild(lebel);&lt;/P&gt;&lt;P&gt;const ul=document.createElement("ul");&lt;BR /&gt;ul.style.listStyleType = 'none';&lt;BR /&gt;featureLayer.renderer.uniqueValueInfos.forEach(item=&amp;gt;{&lt;BR /&gt;const li=document.createElement("li");&lt;BR /&gt;&lt;BR /&gt;const canvas = document.createElement("canvas");&lt;BR /&gt;canvas.width=20;&lt;BR /&gt;canvas.height=20;&lt;BR /&gt;canvas.style.backgroundColor=item.symbol.color;&lt;BR /&gt;li.appendChild(canvas);&lt;/P&gt;&lt;P&gt;const lebel2=document.createElement("label");&lt;BR /&gt;lebel2.textContent=item.value;&lt;BR /&gt;li.appendChild(lebel2);&lt;BR /&gt;ul.appendChild(li);&lt;BR /&gt;});&lt;BR /&gt;&lt;BR /&gt;divCustomLegend.appendChild(ul);&lt;BR /&gt;view.ui.add(divCustomLegend, "top-right");&lt;BR /&gt;});&lt;BR /&gt;//#endregion&lt;/P&gt;&lt;P&gt;//#region Default Legend&lt;BR /&gt;const legend = new Legend({&lt;BR /&gt;view: view,&lt;BR /&gt;layerInfos: [&lt;BR /&gt;{&lt;BR /&gt;layer: featureLayer,&lt;BR /&gt;title: "NY Educational Attainment",&lt;BR /&gt;},&lt;BR /&gt;],&lt;BR /&gt;});&lt;BR /&gt;view.ui.add(legend, "bottom-left");&lt;BR /&gt;//#endregion&lt;BR /&gt;});&lt;BR /&gt;&amp;lt;/script&amp;gt;&lt;BR /&gt;&amp;lt;/head&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;body&amp;gt;&lt;BR /&gt;&amp;lt;div id="viewDiv"&amp;gt;&lt;BR /&gt;&amp;lt;div id="divCustomLegend" style="background-color: white;max-height: 250px;max-width: 200px;overflow-y: auto;"&amp;gt;&lt;BR /&gt;&amp;lt;/div&amp;gt;&lt;BR /&gt;&amp;lt;/div&amp;gt;&lt;BR /&gt;&amp;lt;/body&amp;gt;&lt;BR /&gt;&amp;lt;/html&amp;gt;&lt;/P&gt;</description>
    <pubDate>Wed, 11 Feb 2026 07:38:14 GMT</pubDate>
    <dc:creator>banu</dc:creator>
    <dc:date>2026-02-11T07:38:14Z</dc:date>
    <item>
      <title>Featureeffect  issue</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/featureeffect-issue/m-p/1616846#M87187</link>
      <description>&lt;P&gt;&amp;lt;!doctype html&amp;gt;&lt;BR /&gt;&amp;lt;html lang="en"&amp;gt;&lt;BR /&gt;&amp;lt;head&amp;gt;&lt;BR /&gt;&amp;lt;meta charset="utf-8" /&amp;gt;&lt;BR /&gt;&amp;lt;meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" /&amp;gt;&lt;BR /&gt;&amp;lt;title&amp;gt;Intro to FeatureLayer | Sample | ArcGIS Maps SDK for JavaScript 4.33&amp;lt;/title&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;link rel="stylesheet" href="&lt;A href="https://js.arcgis.com/4.33/esri/themes/light/main.css" target="_blank" rel="noopener"&gt;https://js.arcgis.com/4.33/esri/themes/light/main.css&lt;/A&gt;" /&amp;gt;&lt;BR /&gt;&amp;lt;script src="&lt;A href="https://js.arcgis.com/4.33/" target="_blank" rel="noopener"&gt;https://js.arcgis.com/4.33/&lt;/A&gt;"&amp;gt;&amp;lt;/script&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;style&amp;gt;&lt;BR /&gt;html,&lt;/P&gt;&lt;P&gt;let map, view, Programs, Well, Segment, ProgramIds, SegmentIds, WellIds, searchWidget, sketchGeometry, Selectedvalue, results, layer, zoomin, zoomout;&lt;BR /&gt;let sketchRecButton, sketchButton, zoomToSelectButton, clearButton, distanceMeasurement2D, areaMeasurement2D;&lt;BR /&gt;let sketchGeometries = [];&lt;/P&gt;&lt;P&gt;const [MapView, Map, FeatureLayer, ImageryLayer, GroupLayer, GraphicsLayer, Graphic, geometryEngine, Search, Home, Expand, SketchViewModel, geometryEngineAsync, LayerList,&lt;BR /&gt;AreaMeasurement2D, PictureMarkerSymbol, SimpleLineSymbol, Legend, reactiveUtils, AreaMeasurement2DViewModel, DistanceMeasurement2D, BasemapToggle] =&lt;BR /&gt;await $arcgis.import(["@arcgis/core/views/MapView.js", "@arcgis/core/Map.js", "@arcgis/core/layers/FeatureLayer.js", "@arcgis/core/layers/ImageryLayer.js", "@arcgis/core/layers/GroupLayer.js",&lt;BR /&gt;"@arcgis/core/layers/GraphicsLayer.js", "@arcgis/core/Graphic.js", "@arcgis/core/geometry/geometryEngine.js", "@arcgis/core/widgets/Search.js",&lt;BR /&gt;"@arcgis/core/widgets/Home.js", "@arcgis/core/widgets/Expand.js", "@arcgis/core/widgets/Sketch/SketchViewModel", "@arcgis/core/geometry/geometryEngineAsync.js",&lt;BR /&gt;"@arcgis/core/widgets/LayerList.js", "@arcgis/core/widgets/AreaMeasurement2D.js", "@arcgis/core/symbols/PictureMarkerSymbol.js", "@arcgis/core/symbols/SimpleLineSymbol.js",&lt;BR /&gt;"@arcgis/core/widgets/Legend.js", "@arcgis/core/core/reactiveUtils.js", "@arcgis/core/widgets/AreaMeasurement2D.js", "@arcgis/core/widgets/DistanceMeasurement2D.js",&lt;BR /&gt;"@arcgis/core/widgets/BasemapToggle.js"&lt;BR /&gt;]);&lt;/P&gt;&lt;P&gt;import { wellRenderer, segmentRenderer, boundaryRenderer, configLayers, sources, popupWellheads, labelClass } from '/js/renderer.js';&lt;/P&gt;&lt;P&gt;//Well = new FeatureLayer({ url: "&lt;A href="https://ucwgis00001.aramco.com/arcgisserver/rest/services/URGIS/WellsUTM/MapServer/0" target="_blank"&gt;https://ucwgis00001.aramco.com/arcgisserver/rest/services/URGIS/WellsUTM/MapServer/0&lt;/A&gt;", labelingInfo: [labelClass], renderer: wellRenderer });&lt;BR /&gt;//Segment = new FeatureLayer({ url: "&lt;A href="https://ucwgis00001.aramco.com/arcgisserver/rest/services/URGIS/URSegments/MapServer/0" target="_blank"&gt;https://ucwgis00001.aramco.com/arcgisserver/rest/services/URGIS/URSegments/MapServer/0&lt;/A&gt;" });&lt;BR /&gt;let savedAssetsInfo = [];&lt;BR /&gt;const polygonGraphicsLayer = new GraphicsLayer();&lt;/P&gt;&lt;P&gt;export class renderMaps {&lt;BR /&gt;static dotNetHelper;&lt;BR /&gt;static setDotNetHelper(value) {&lt;BR /&gt;renderMap.dotNetHelper = value;&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;export function renderMapValue(value) {&lt;BR /&gt;if (value !== null &amp;amp;&amp;amp; value !== undefined) {&lt;BR /&gt;Selectedvalue = value;&lt;BR /&gt;//console.log(`SelectedValue: ${value}`);&lt;BR /&gt;} else {&lt;BR /&gt;// console.log("No value selected");&lt;BR /&gt;Selectedvalue = "Well";&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;export async function renderMap() {&lt;BR /&gt;&lt;BR /&gt;const mapImage = document.getElementById("map-image");&lt;BR /&gt;const loader = document.getElementById("loader");&lt;BR /&gt;//mapImage.style.display = "block";&lt;BR /&gt;//loader.style.display = "flex";&lt;BR /&gt;if (mapImage) {mapImage.style.display = "block"; }&lt;BR /&gt;if (loader) {loader.style.display = "flex";}&lt;BR /&gt;if (!mapImage || !loader) {console.error("Either map-image or loader element was not found.");}&lt;/P&gt;&lt;P&gt;//satellite&lt;BR /&gt;map = new Map({ basemap: "satellite" });&lt;BR /&gt;view = new MapView({&lt;BR /&gt;map: map,&lt;BR /&gt;center: [35, 26],&lt;BR /&gt;zoom: 6,&lt;BR /&gt;container: "view-div",&lt;BR /&gt;ui: {&lt;BR /&gt;components: ["attribution"] // Only show attribution, hide zoom widget&lt;BR /&gt;}&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;let basemapToggle = new BasemapToggle({&lt;BR /&gt;view: view, // The view that provides access to the map's "streets-vector" basemap&lt;BR /&gt;nextBasemap: "hybrid" // Allows for toggling to the "hybrid" basemap&lt;BR /&gt;});&lt;BR /&gt;// Wait for view to be ready&lt;BR /&gt;await view.when();&lt;BR /&gt;&lt;BR /&gt;// Add feature layers&lt;BR /&gt;if (configLayers) {&lt;BR /&gt;configLayers.forEach((layerInfo) =&amp;gt; {&lt;BR /&gt;let layer;&lt;BR /&gt;switch (layerInfo.id) {&lt;BR /&gt;case "Segment":&lt;BR /&gt;layer = new FeatureLayer({ id: layerInfo.id, url: layerInfo.url, renderer: segmentRenderer });&lt;BR /&gt;Segment = layer;&lt;BR /&gt;break;&lt;BR /&gt;case "Well":&lt;BR /&gt;layer = new FeatureLayer({ id: layerInfo.id, url: layerInfo.url, labelingInfo: [labelClass], renderer: wellRenderer, popupTemplate: popupWellheads });&lt;BR /&gt;Well = layer;&lt;BR /&gt;break;&lt;BR /&gt;case "boundary":&lt;BR /&gt;layer = new FeatureLayer({ id: layerInfo.id, url: layerInfo.url, renderer: boundaryRenderer });&lt;BR /&gt;break;&lt;BR /&gt;default:&lt;BR /&gt;console.error(`Unknown layer ID: ${layerInfo.id}`);&lt;BR /&gt;return;&lt;BR /&gt;}&lt;BR /&gt;map.add(layer);&lt;BR /&gt;});&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// Add polygon graphics layer&lt;BR /&gt;map.add(polygonGraphicsLayer);&lt;/P&gt;&lt;P&gt;// Wait for layers to be loaded&lt;BR /&gt;await Promise.all(configLayers.map((layerInfo) =&amp;gt; map.findLayerById(layerInfo.id).when()));&lt;/P&gt;&lt;P&gt;await view.watch("updating", (updating) =&amp;gt; {&lt;BR /&gt;if (!updating) {&lt;BR /&gt;// This function will execute once the map stops updating (is fully loaded/rendered)&lt;BR /&gt;console.log("Map is fully loaded and stationary.");&lt;BR /&gt;mapImage.style.display = "none"; // Hide the low-opacity image&lt;BR /&gt;loader.style.display = "none";&lt;BR /&gt;const viewDiv = document.getElementById("view-div");&lt;BR /&gt;if (viewDiv) {&lt;BR /&gt;viewDiv.style.opacity = 1;&lt;BR /&gt;const legendLabels = document.querySelectorAll('.esri-legend__layer-cell.esri-legend__layer-cell--info');&lt;BR /&gt;// console.log(legendLabels); // Check if the elements are being found&lt;BR /&gt;legendLabels.forEach((label) =&amp;gt; {&lt;BR /&gt;if (label.textContent === 'Segments') {&lt;BR /&gt;console.log("Segment selected");&lt;BR /&gt;const previousElementSibling = label.previousElementSibling;&lt;BR /&gt;previousElementSibling.style.backgroundColor = "#9028F180";&lt;BR /&gt;previousElementSibling.style.height = '26px';&lt;BR /&gt;previousElementSibling.style.width= '26px';&lt;BR /&gt;previousElementSibling.style.borderTop = '2px solid #9028F1';&lt;BR /&gt;}&lt;BR /&gt;});&lt;BR /&gt;const legendsymbol = document.querySelectorAll('.esri-legend__layer-cell.esri-legend__layer-cell--symbols');&lt;BR /&gt;/*console.log(legendsymbol);*/&lt;BR /&gt;legendsymbol.forEach((symbol) =&amp;gt; {&lt;BR /&gt;//console.log(symbol.lastChild.firstChild.firstChild.ariaLabel);&lt;BR /&gt;if (symbol.lastChild.firstChild.firstChild.ariaLabel == "Preview for Segments") {&lt;BR /&gt;symbol.lastChild.firstChild.style.opacity = 0;&lt;BR /&gt;}&lt;BR /&gt;});&lt;BR /&gt;} else {&lt;BR /&gt;console.error("view-div element was not found.");&lt;BR /&gt;// You can also add additional error handling or fallback behavior here&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;});&lt;BR /&gt;// Add search widget&lt;BR /&gt;const searchWidget = new Search({&lt;BR /&gt;view: view,&lt;BR /&gt;sources: sources,&lt;BR /&gt;includeDefaultSources: false,&lt;BR /&gt;locationEnabled: false,&lt;BR /&gt;allPlaceholder: "Search By ID and Name..."&lt;BR /&gt;});&lt;BR /&gt;const expandSearch = new Expand({ content: searchWidget, view: view, expanded: false, expandIcon: "search" });&lt;BR /&gt;view.ui.add(expandSearch, { position: "top-right" });&lt;/P&gt;&lt;P&gt;//const polygonLayers = configLayers.filter((layerInfo) =&amp;gt; ["Segment", "boundary"].includes(layerInfo.id));&lt;BR /&gt;const polygonLayers = configLayers.filter((layerInfo) =&amp;gt; ["Segment"].includes(layerInfo.id));&lt;BR /&gt;const polygonGroupLayer = new GroupLayer({&lt;BR /&gt;id: "polygons",&lt;BR /&gt;title: "Polygons",&lt;BR /&gt;layers: polygonLayers.map((layerInfo) =&amp;gt; map.findLayerById(layerInfo.id))&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;map.add(polygonGroupLayer,0);&lt;/P&gt;&lt;P&gt;const legend = new Legend({&lt;BR /&gt;view: view,&lt;BR /&gt;layerInfos: configLayers.reduce((acc, layerInfo) =&amp;gt; {&lt;BR /&gt;const layer = map.findLayerById(layerInfo.id);&lt;BR /&gt;if (layerInfo.id === "Well") {&lt;BR /&gt;acc.push({ layer: layer, title: "Legends" });&lt;BR /&gt;} else if (["Segment"].includes(layerInfo.id)) {&lt;BR /&gt;acc.push({ layer: layer, title: "" }); // Hide the layer title&lt;BR /&gt;}&lt;BR /&gt;return acc;&lt;BR /&gt;}, []).concat([&lt;BR /&gt;{ layer: polygonGroupLayer, title: "Polygons" }&lt;BR /&gt;])&lt;BR /&gt;});&lt;BR /&gt;const expandLegend = new Expand({ content: legend, view: view, expanded: false, expandIcon: "information", collapseIcon:"information" });&lt;BR /&gt;view.ui.add(expandLegend, "top-right");&lt;/P&gt;&lt;P&gt;const addedLayerTitles = new Set();&lt;BR /&gt;// Create a new div to hold the layer list&lt;BR /&gt;const layerListDiv = document.createElement("div");&lt;BR /&gt;layerListDiv.id = "layer-list-div";&lt;BR /&gt;layerListDiv.style.width="300px";&lt;BR /&gt;layerListDiv.style.height="max-content";&lt;BR /&gt;layerListDiv.style.paddingLeft = "10px";&lt;/P&gt;&lt;P&gt;// Create a new LayerList&lt;BR /&gt;const layerList = new LayerList({&lt;BR /&gt;view: view,&lt;BR /&gt;visibilityAppearance: "none",&lt;BR /&gt;listItemCreatedFunction: (event) =&amp;gt; {&lt;BR /&gt;const item = event.item;&lt;/P&gt;&lt;P&gt;if (item.layer.type === "basemap") {&lt;BR /&gt;return;&lt;BR /&gt;}&lt;BR /&gt;if (item.layer.title === "URSegments") {&lt;BR /&gt;item.layer.title = "Segment";&lt;BR /&gt;} else if (item.layer.title === "WellsUTM") {&lt;BR /&gt;item.layer.title = "Well";&lt;BR /&gt;}&lt;BR /&gt;else if (item.layer.title === null || item.layer.title === "Polygons") {&lt;BR /&gt;return;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;if (addedLayerTitles.has(item.layer.title)) {&lt;BR /&gt;return;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;addedLayerTitles.add(item.layer.title);&lt;/P&gt;&lt;P&gt;// Create a custom checkbox element&lt;BR /&gt;const checkbox = document.createElement("input");&lt;BR /&gt;checkbox.type = "checkbox";&lt;BR /&gt;checkbox.id = "checkbox-" + item.layer.id;&lt;BR /&gt;checkbox.checked = item.visible; // Set initial state&lt;/P&gt;&lt;P&gt;// Add an event listener to manage layer visibility&lt;BR /&gt;checkbox.addEventListener("change", () =&amp;gt; {&lt;BR /&gt;item.visible = checkbox.checked;&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;// Watch the item's visibility property to keep the checkbox in sync&lt;BR /&gt;// with other potential visibility changes (e.g., zoom level changes)&lt;BR /&gt;reactiveUtils.watch(() =&amp;gt; item.visible, (visible) =&amp;gt; {&lt;BR /&gt;checkbox.checked = visible;&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;// Create a container for the label and checkbox&lt;BR /&gt;const container = document.createElement("div");&lt;BR /&gt;container.style.display = "flex";&lt;BR /&gt;container.style.justifyContent = "space-between";&lt;BR /&gt;container.style.alignItems = "center";&lt;BR /&gt;container.style.marginBottom = "10px";&lt;/P&gt;&lt;P&gt;const label = document.createElement("span");&lt;BR /&gt;label.textContent = item.layer.title;&lt;BR /&gt;container.appendChild(label);&lt;/P&gt;&lt;P&gt;container.appendChild(checkbox);&lt;/P&gt;&lt;P&gt;// Append the container to the layer list div&lt;BR /&gt;layerListDiv.appendChild(container);&lt;/P&gt;&lt;P&gt;// Add CSS rule to change checkbox checked color to green&lt;BR /&gt;const style = document.createElement("style");&lt;BR /&gt;style.innerHTML = `input[type="checkbox"] {&lt;BR /&gt;accent-color: green;&lt;BR /&gt;width: 20px;&lt;BR /&gt;height: 20px;&lt;BR /&gt;}&lt;BR /&gt;input[type="checkbox"]:checked {&lt;BR /&gt;accent-color: green;&lt;BR /&gt;}`;&lt;BR /&gt;document.head.appendChild(style);&lt;BR /&gt;}&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;// Add the layer list div to the view&lt;BR /&gt;view.container.appendChild(layerListDiv);&lt;/P&gt;&lt;P&gt;const expandLayerList = new Expand({&lt;BR /&gt;content: layerListDiv,&lt;BR /&gt;view: view,&lt;BR /&gt;expanded: false,&lt;BR /&gt;expandIcon: "layers"&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;view.ui.add(expandLayerList, { position: "top-right" });&lt;/P&gt;&lt;P&gt;distanceMeasurement2D = new DistanceMeasurement2D({&lt;BR /&gt;view,&lt;BR /&gt;visible: false,&lt;BR /&gt;});&lt;BR /&gt;areaMeasurement2D = new AreaMeasurement2DViewModel({&lt;BR /&gt;view,&lt;BR /&gt;visible: false,&lt;BR /&gt;});&lt;BR /&gt;// Retrieve button elements&lt;BR /&gt;const recButton = document.getElementById("select-by-rectangle");&lt;BR /&gt;const polyButton = document.getElementById("select-by-freehandpolygon");&lt;BR /&gt;zoomToSelectButton = document.getElementById("zoomtoSelect");&lt;BR /&gt;clearButton = document.getElementById("Clear");&lt;BR /&gt;zoomin = document.getElementById("zoomInButton");&lt;BR /&gt;zoomout = document.getElementById("zoomOutButton");&lt;/P&gt;&lt;P&gt;//zoomIn.addEventListener('click', zoomIn);&lt;BR /&gt;//zoomout.addEventListener('click', zoomIn);&lt;BR /&gt;zoomToSelectButton.style.opacity = 0.5;&lt;BR /&gt;clearButton.style.opacity = 0.5;&lt;/P&gt;&lt;P&gt;const areaButton = document.getElementById("areaButton");&lt;BR /&gt;const distanceButton = document.getElementById("distanceButton");&lt;BR /&gt;const measureClearButton = document.getElementById("measureClearButton");&lt;/P&gt;&lt;P&gt;// Add draw tool widget&lt;BR /&gt;const measureToolWidget = document.createElement("div");&lt;BR /&gt;measureToolWidget.classList.add("esri-widget", "draw-tool-widget");&lt;BR /&gt;measureToolWidget.style.display = "flex";&lt;BR /&gt;measureToolWidget.style.flexDirection = "column";&lt;/P&gt;&lt;P&gt;const buttonsmeasure = ["areaButton", "distanceButton","measureClearButton"];&lt;BR /&gt;buttonsmeasure.forEach((id) =&amp;gt; {&lt;BR /&gt;const button = document.getElementById(id);&lt;BR /&gt;if (button) {&lt;BR /&gt;measureToolWidget.appendChild(button);&lt;BR /&gt;button.addEventListener("click", () =&amp;gt; {&lt;BR /&gt;switch (id) {&lt;BR /&gt;case "areaButton":&lt;BR /&gt;break;&lt;BR /&gt;case "distanceButton":&lt;BR /&gt;break;&lt;BR /&gt;case "measureClearButton":&lt;BR /&gt;break;&lt;BR /&gt;}&lt;BR /&gt;});&lt;BR /&gt;}&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;const expandDraw = new Expand({ content: measureToolWidget, view: view, expanded: false, expandIcon: "measure" });&lt;BR /&gt;view.ui.add(expandDraw, { position: "top-right" });&lt;/P&gt;&lt;P&gt;// event listener for distance measurements&lt;BR /&gt;distanceButton.addEventListener("click", function () {&lt;BR /&gt;setActiveWidget(null);&lt;BR /&gt;if (!this.classList.contains("active")) {&lt;BR /&gt;setActiveWidget("distance");&lt;BR /&gt;} else {&lt;BR /&gt;setActiveButton(null);&lt;BR /&gt;}&lt;BR /&gt;});&lt;BR /&gt;// event listener for area measurements&lt;BR /&gt;areaButton.addEventListener("click", function () {&lt;BR /&gt;setActiveWidget(null);&lt;BR /&gt;if (!this.classList.contains("active")) {&lt;BR /&gt;setActiveWidget("area");&lt;BR /&gt;} else {&lt;BR /&gt;setActiveButton(null);&lt;BR /&gt;}&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;measureClearButton.addEventListener("click", function () {&lt;BR /&gt;setActiveWidget(null);&lt;BR /&gt;});&lt;BR /&gt;// Array of buttons for easier management&lt;BR /&gt;const buttons = [recButton, polyButton, zoomToSelectButton, clearButton];&lt;/P&gt;&lt;P&gt;// Add event listeners to buttons&lt;BR /&gt;buttons.forEach((button) =&amp;gt; {&lt;BR /&gt;if (button) {&lt;BR /&gt;button.addEventListener("click", () =&amp;gt; {&lt;BR /&gt;switch (button.id) {&lt;BR /&gt;case "select-by-rectangle":&lt;BR /&gt;// polygonGraphicsLayer.removeAll();&lt;BR /&gt;sketchViewModel.create("rectangle");&lt;BR /&gt;break;&lt;BR /&gt;case "select-by-freehandpolygon":&lt;BR /&gt;//polygonGraphicsLayer.removeAll();&lt;BR /&gt;sketchViewModel.create("polygon");&lt;BR /&gt;break;&lt;BR /&gt;case "zoomtoSelect":&lt;BR /&gt;zoomtoFeature();&lt;BR /&gt;break;&lt;BR /&gt;case "Clear":&lt;BR /&gt;clearSelection();&lt;BR /&gt;break;&lt;BR /&gt;}&lt;BR /&gt;});&lt;BR /&gt;}&lt;BR /&gt;});&lt;BR /&gt;// Add buttons to the view&lt;BR /&gt;buttons.forEach((button) =&amp;gt; {&lt;BR /&gt;view.ui.add(button, { position: "top-right" });&lt;BR /&gt;});&lt;BR /&gt;// Add sketch view model&lt;BR /&gt;const sketchViewModel = new SketchViewModel({&lt;BR /&gt;view: view,&lt;BR /&gt;layer: polygonGraphicsLayer,&lt;BR /&gt;updateOnGraphicClick: false,&lt;BR /&gt;});&lt;BR /&gt;sketchViewModel.on("create", (event) =&amp;gt; {&lt;BR /&gt;if (event.state === "complete") {&lt;BR /&gt;sketchGeometry = event.graphic.geometry;&lt;BR /&gt;sketchGeometries.push(event.graphic.geometry);&lt;BR /&gt;//view.graphics.removeAll();&lt;BR /&gt;//polygonGraphicsLayer.removeAll();&lt;BR /&gt;//savedAssetsInfo = [];&lt;/P&gt;&lt;P&gt;if (configLayers) {&lt;BR /&gt;const selectedLayer = configLayers.find((layerInfo) =&amp;gt; layerInfo.id === Selectedvalue);&lt;BR /&gt;if (selectedLayer) {&lt;BR /&gt;selectFeatures(selectedLayer, sketchGeometries);&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;// Remove empty layers&lt;BR /&gt;layerList.when(() =&amp;gt; {&lt;BR /&gt;layerList.operationalItems.forEach((item) =&amp;gt; {&lt;BR /&gt;if (item.layer.title === null) layerList.view.map.remove(item.layer);&lt;BR /&gt;});&lt;BR /&gt;});&lt;BR /&gt;view.ui.add(zoomin, { position: "top-right" });&lt;BR /&gt;view.ui.add(new Home({ view: view }), { position: "top-right"});&lt;BR /&gt;view.ui.add(zoomout, { position: "top-right" });&lt;BR /&gt;// zoomin.addEventListener()&lt;BR /&gt;zoomin.addEventListener("click", function () { zoomIn(); });&lt;BR /&gt;zoomout.addEventListener("click", function () { zoomOut(); });&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;export async function queryLayers(assetSegmentIds) {&lt;BR /&gt;removeGraphics();&lt;BR /&gt;const wells = assetSegmentIds.filter(item =&amp;gt; item.assetType === "Well");&lt;BR /&gt;const segments = assetSegmentIds.filter(item =&amp;gt; item.assetType === "Segment");&lt;/P&gt;&lt;P&gt;polygonGraphicsLayer.removeAll();&lt;BR /&gt;let programsGraphicsLayer = new GraphicsLayer();&lt;BR /&gt;let wellsGraphicsLayer = new GraphicsLayer();&lt;BR /&gt;let segmentsGraphicsLayer = new GraphicsLayer();&lt;/P&gt;&lt;P&gt;switch (Selectedvalue) {&lt;BR /&gt;case "Segment":&lt;BR /&gt;SegmentIds = segments.map(item =&amp;gt; "'" + item.parentAsset.id + "'");&lt;BR /&gt;queryAndAddGraphics(Segment, segmentsGraphicsLayer, "URECD.URSegmentTable.SEGMENT_ID", SegmentIds);&lt;BR /&gt;break;&lt;BR /&gt;case "Well":&lt;BR /&gt;WellIds = wells.map(item =&amp;gt; "'" + item.parentAsset.id + "'");&lt;BR /&gt;queryAndAddGraphics(Well, wellsGraphicsLayer, "URECD.URGIS_Wells.WELL_ID", WellIds);&lt;BR /&gt;break;&lt;BR /&gt;default:&lt;BR /&gt;// You can add a default case to handle any other values&lt;BR /&gt;console.log("No matching case found");&lt;BR /&gt;break;&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;let addedGraphics = []; // Initialize an empty array to store added graphics&lt;/P&gt;&lt;P&gt;async function queryAndAddGraphics(layer, graphicsLayer, whereClause, ids) {&lt;BR /&gt;if (ids !== "" &amp;amp;&amp;amp; ids.length) {&lt;BR /&gt;const query = {&lt;BR /&gt;where: whereClause + " IN (" + ids + ")",&lt;BR /&gt;returnGeometry: true&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;try {&lt;BR /&gt;const results = await layer.queryFeatures(query);&lt;BR /&gt;if (results) {&lt;BR /&gt;addGraphics(results);&lt;BR /&gt;enableButtonsfromComponent(results);&lt;BR /&gt;}&lt;BR /&gt;} catch (error) {&lt;BR /&gt;console.error(error);&lt;BR /&gt;}&lt;BR /&gt;} else if (savedAssetsInfo.length === 0) {&lt;BR /&gt;// console.log("Map features selected");&lt;BR /&gt;} else if (typeof removeGraphics === 'function') {&lt;BR /&gt;removeGraphics();&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;function addGraphics(results) {&lt;BR /&gt;if (results.features.length &amp;gt; 0) {&lt;BR /&gt;const symbol = getSymbol(results.features[0].geometry.type);&lt;/P&gt;&lt;P&gt;// Check if graphics already exist in the layer&lt;BR /&gt;const existingGraphics = new Set(view.graphics.items.map(graphic =&amp;gt; graphic.geometry));&lt;BR /&gt;const newGraphics = results.features.filter(feature =&amp;gt; {&lt;BR /&gt;return !existingGraphics.has(feature.geometry);&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;if (newGraphics.length &amp;gt; 0) {&lt;BR /&gt;const graphics = newGraphics.map((feature) =&amp;gt; {&lt;BR /&gt;const graphic = new Graphic();&lt;BR /&gt;graphic.geometry = feature.geometry;&lt;BR /&gt;graphic.symbol = symbol;&lt;BR /&gt;return graphic;&lt;BR /&gt;});&lt;BR /&gt;addedGraphics.push(...graphics);&lt;BR /&gt;view.graphics.addMany(graphics);&lt;BR /&gt;}&lt;BR /&gt;} else {&lt;BR /&gt;// Clear the graphics in the layer if the query is empty&lt;BR /&gt;view.graphics.removeAll();&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;function getSymbol(geometryType) {&lt;BR /&gt;switch (geometryType) {&lt;BR /&gt;case "point":&lt;BR /&gt;return {&lt;BR /&gt;type: "simple-marker",&lt;BR /&gt;color: "#17CBE8",&lt;BR /&gt;size: 10,&lt;BR /&gt;};&lt;BR /&gt;case "polygon":&lt;BR /&gt;return {&lt;BR /&gt;type: "simple-fill",&lt;BR /&gt;color: "#8FA6FA",&lt;BR /&gt;opacity: 0.7,&lt;BR /&gt;outline: {&lt;BR /&gt;color: [128, 128, 128, 0.5],&lt;BR /&gt;width: "0.5px"&lt;BR /&gt;}&lt;BR /&gt;};&lt;BR /&gt;default:&lt;BR /&gt;throw new Error(`Unsupported geometry type: ${geometryType}`);&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;function removeGraphics() {&lt;BR /&gt;view.graphics.removeAll();&lt;BR /&gt;clearAddedGraphics();&lt;BR /&gt;}&lt;BR /&gt;function clearAddedGraphics() {&lt;BR /&gt;addedGraphics = [];&lt;BR /&gt;}&lt;BR /&gt;function zoomtoFeature() {&lt;BR /&gt;if (view.graphics.length &amp;gt; 0) {&lt;BR /&gt;view.goTo(view.graphics);&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;function clearSelection() {&lt;BR /&gt;results = { features: [] };&lt;BR /&gt;addGraphics(results);&lt;BR /&gt;polygonGraphicsLayer.removeAll();&lt;BR /&gt;view.graphics.removeAll();&lt;BR /&gt;polygonGraphicsLayer.removeAll();&lt;BR /&gt;removeGraphics();&lt;BR /&gt;savedAssetsInfo = [];&lt;BR /&gt;enableButtons(savedAssetsInfo);&lt;BR /&gt;sendArrayListToCSharp(savedAssetsInfo);&lt;BR /&gt;sketchGeometries = [];&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;async function selectFeatures(layerInfo, _geometry) {&lt;BR /&gt;const savedAssetsInfo = []; // Declare locally&lt;BR /&gt;const layer = map.findLayerById(layerInfo.id);&lt;/P&gt;&lt;P&gt;if (Selectedvalue === layerInfo.id) {&lt;BR /&gt;const unionGeometry = geometryEngine.union(_geometry);&lt;BR /&gt;try {&lt;BR /&gt;const query = {&lt;BR /&gt;geometry: unionGeometry,&lt;BR /&gt;spatialRelationship: "intersects",&lt;BR /&gt;returnGeometry: true,&lt;BR /&gt;outFields: ["*"],&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;const results = await layer.queryFeatures(query);&lt;/P&gt;&lt;P&gt;let object2 = {&lt;BR /&gt;assetName: layer.title,&lt;BR /&gt;featuresInfo: []&lt;BR /&gt;};&lt;BR /&gt;let featuresInfo2 = [];&lt;BR /&gt;let id;&lt;/P&gt;&lt;P&gt;if (results.features.length &amp;gt; 0) {&lt;BR /&gt;addGraphics(results);&lt;BR /&gt;const findsavedAssetsInfo = savedAssetsInfo.find(item =&amp;gt; item.assetName === layerInfo.id);&lt;BR /&gt;if (!findsavedAssetsInfo) {&lt;BR /&gt;//#region Saved Asset Info&lt;/P&gt;&lt;P&gt;for (let i = 0; i &amp;lt; results.features.length; i++) {&lt;BR /&gt;if (object2.assetName === "Well") {&lt;BR /&gt;id = results.features[i].attributes["URECD.URGIS_Wells.WELL_ID"];&lt;BR /&gt;} else if (object2.assetName === "Segment") {&lt;BR /&gt;id = results.features[i].attributes["URECD.URSegmentTable.SEGMENT_ID"];&lt;BR /&gt;}&lt;BR /&gt;featuresInfo2.push({&lt;BR /&gt;id: id,&lt;BR /&gt;//attributes: results.features[i].attributes,&lt;BR /&gt;isSelected: true&lt;BR /&gt;});&lt;BR /&gt;}&lt;BR /&gt;object2.featuresInfo = featuresInfo2;&lt;BR /&gt;savedAssetsInfo.push(object2);&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;catch (error) {&lt;BR /&gt;console.error("Error querying features:", error);&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;else {&lt;BR /&gt;// Clear the graphics in the layer if it's not selected&lt;BR /&gt;view.graphics.removeAll();&lt;BR /&gt;}&lt;BR /&gt;enableButtons(savedAssetsInfo);&lt;BR /&gt;sendArrayListToCSharp(savedAssetsInfo);&lt;BR /&gt;}&lt;BR /&gt;function sendArrayListToCSharp(arrayList) {&lt;BR /&gt;//view.graphics.removeAll();&lt;BR /&gt;// Convert the ArrayList to a JSON string&lt;BR /&gt;let json = JSON.stringify(arrayList);&lt;BR /&gt;renderMap.dotNetHelper.invokeMethodAsync("SendArrayListToCSharp", json)&lt;BR /&gt;.then(result =&amp;gt; console.log(result))&lt;BR /&gt;.catch(error =&amp;gt; console.error(error));&lt;BR /&gt;}&lt;BR /&gt;function enableButtons(arrayList) {&lt;BR /&gt;if (arrayList.length &amp;gt; 0) {&lt;BR /&gt;//zoomToSelectButton.style.backgroundColor = "white";&lt;BR /&gt;//clearButton.style.backgroundColor = "white";&lt;BR /&gt;zoomToSelectButton.style.opacity = 1;&lt;BR /&gt;clearButton.style.opacity = 1;&lt;BR /&gt;} else {&lt;BR /&gt;zoomToSelectButton.style.opacity = 0.5;&lt;BR /&gt;clearButton.style.opacity = 0.5;&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;function enableButtonsfromComponent(arrayList) {&lt;BR /&gt;if (arrayList.features.length &amp;gt; 0) {&lt;BR /&gt;//zoomToSelectButton.style.backgroundColor = "white";&lt;BR /&gt;//clearButton.style.backgroundColor = "white";&lt;BR /&gt;zoomToSelectButton.style.opacity = 1;&lt;BR /&gt;clearButton.style.opacity = 1;&lt;BR /&gt;} else {&lt;BR /&gt;zoomToSelectButton.style.opacity = 0.5;&lt;BR /&gt;clearButton.style.opacity = 0.5;&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;function setActiveWidget(type) {&lt;BR /&gt;switch (type) {&lt;BR /&gt;case "distance":&lt;BR /&gt;areaMeasurement2D.visible = false;&lt;BR /&gt;distanceMeasurement2D.visible = true;&lt;BR /&gt;distanceMeasurement2D.viewModel.start();&lt;BR /&gt;setActiveButton(document.getElementById("distanceButton"));&lt;BR /&gt;break;&lt;BR /&gt;case "area":&lt;BR /&gt;distanceMeasurement2D.visible = false;&lt;BR /&gt;areaMeasurement2D.visible = true;&lt;BR /&gt;areaMeasurement2D.viewModel.start();&lt;BR /&gt;setActiveButton(document.getElementById("areaButton"));&lt;BR /&gt;break;&lt;BR /&gt;case null:&lt;BR /&gt;areaMeasurement2D.visible = false;&lt;BR /&gt;distanceMeasurement2D.visible = false;&lt;BR /&gt;break;&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;function setActiveButton(selectedButton) {&lt;BR /&gt;// focus the view to activate keyboard shortcuts for sketching&lt;BR /&gt;view.focus();&lt;BR /&gt;let elements = document.getElementsByClassName("active");&lt;BR /&gt;for (let i = 0; i &amp;lt; elements.length; i++) {&lt;BR /&gt;elements[i].classList.remove("active");&lt;BR /&gt;}&lt;BR /&gt;if (selectedButton) {&lt;BR /&gt;selectedButton.classList.add("active");&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// Function to handle zooming in&lt;BR /&gt;function zoomIn() {&lt;BR /&gt;// Increase the zoom level by 1&lt;BR /&gt;let newZoom = view.zoom + 1;&lt;BR /&gt;view.goTo({&lt;BR /&gt;// target: view.center,&lt;BR /&gt;zoom: newZoom&lt;BR /&gt;});&lt;BR /&gt;}&lt;BR /&gt;// Function to handle zooming out&lt;BR /&gt;function zoomOut() {&lt;BR /&gt;// Decrease the zoom level by 1&lt;BR /&gt;let newZoom = view.zoom - 0.5;&lt;BR /&gt;view.goTo({&lt;BR /&gt;// target: view.center,&lt;BR /&gt;zoom: newZoom&lt;BR /&gt;});&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;body,&lt;BR /&gt;#viewDiv {&lt;BR /&gt;padding: 0;&lt;BR /&gt;margin: 0;&lt;BR /&gt;height: 100%;&lt;BR /&gt;width: 100%;&lt;BR /&gt;}&lt;BR /&gt;ul {&lt;BR /&gt;display: flex;&lt;BR /&gt;flex-direction: column;&lt;BR /&gt;gap: 5px;&lt;BR /&gt;}&lt;BR /&gt;&amp;lt;/style&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;script type="module"&amp;gt;&lt;BR /&gt;const [Map, MapView, FeatureLayer,Legend] = await $arcgis.import([&lt;BR /&gt;"@arcgis/core/Map.js",&lt;BR /&gt;"@arcgis/core/views/MapView.js",&lt;BR /&gt;"@arcgis/core/layers/FeatureLayer.js",&lt;BR /&gt;"@arcgis/core/widgets/Legend.js",&lt;BR /&gt;]);&lt;/P&gt;&lt;P&gt;const map = new Map({&lt;BR /&gt;basemap: "hybrid",&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;const view = new MapView({&lt;BR /&gt;container: "viewDiv",&lt;BR /&gt;map: map,&lt;BR /&gt;center:[-73.935242,40.730610],&lt;BR /&gt;zoom:10&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;const featureLayer = new FeatureLayer({&lt;BR /&gt;url: "&lt;A href="https://services.arcgis.com/V6ZHFr6zdgNZuVG0/ArcGIS/rest/services/NY%20Educational%20Attainment/FeatureServer/0" target="_blank" rel="noopener"&gt;https://services.arcgis.com/V6ZHFr6zdgNZuVG0/ArcGIS/rest/services/NY%20Educational%20Attainment/FeatureServer/0&lt;/A&gt;",&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;map.add(featureLayer);&lt;/P&gt;&lt;P&gt;view.when(()=&amp;gt;{&lt;BR /&gt;//#region Default Legend&lt;BR /&gt;featureLayer.when(() =&amp;gt; {&lt;BR /&gt;console.log(featureLayer);&lt;BR /&gt;var divCustomLegend=document.getElementById("divCustomLegend");&lt;BR /&gt;const lebel=document.createElement("label");&lt;BR /&gt;lebel.textContent="NY Educational Attainment";&lt;BR /&gt;divCustomLegend.appendChild(lebel);&lt;/P&gt;&lt;P&gt;const ul=document.createElement("ul");&lt;BR /&gt;ul.style.listStyleType = 'none';&lt;BR /&gt;featureLayer.renderer.uniqueValueInfos.forEach(item=&amp;gt;{&lt;BR /&gt;const li=document.createElement("li");&lt;BR /&gt;&lt;BR /&gt;const canvas = document.createElement("canvas");&lt;BR /&gt;canvas.width=20;&lt;BR /&gt;canvas.height=20;&lt;BR /&gt;canvas.style.backgroundColor=item.symbol.color;&lt;BR /&gt;li.appendChild(canvas);&lt;/P&gt;&lt;P&gt;const lebel2=document.createElement("label");&lt;BR /&gt;lebel2.textContent=item.value;&lt;BR /&gt;li.appendChild(lebel2);&lt;BR /&gt;ul.appendChild(li);&lt;BR /&gt;});&lt;BR /&gt;&lt;BR /&gt;divCustomLegend.appendChild(ul);&lt;BR /&gt;view.ui.add(divCustomLegend, "top-right");&lt;BR /&gt;});&lt;BR /&gt;//#endregion&lt;/P&gt;&lt;P&gt;//#region Default Legend&lt;BR /&gt;const legend = new Legend({&lt;BR /&gt;view: view,&lt;BR /&gt;layerInfos: [&lt;BR /&gt;{&lt;BR /&gt;layer: featureLayer,&lt;BR /&gt;title: "NY Educational Attainment",&lt;BR /&gt;},&lt;BR /&gt;],&lt;BR /&gt;});&lt;BR /&gt;view.ui.add(legend, "bottom-left");&lt;BR /&gt;//#endregion&lt;BR /&gt;});&lt;BR /&gt;&amp;lt;/script&amp;gt;&lt;BR /&gt;&amp;lt;/head&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;body&amp;gt;&lt;BR /&gt;&amp;lt;div id="viewDiv"&amp;gt;&lt;BR /&gt;&amp;lt;div id="divCustomLegend" style="background-color: white;max-height: 250px;max-width: 200px;overflow-y: auto;"&amp;gt;&lt;BR /&gt;&amp;lt;/div&amp;gt;&lt;BR /&gt;&amp;lt;/div&amp;gt;&lt;BR /&gt;&amp;lt;/body&amp;gt;&lt;BR /&gt;&amp;lt;/html&amp;gt;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Feb 2026 07:38:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/featureeffect-issue/m-p/1616846#M87187</guid>
      <dc:creator>banu</dc:creator>
      <dc:date>2026-02-11T07:38:14Z</dc:date>
    </item>
  </channel>
</rss>

