<?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: Shop popup on hover and unselect selected feature in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/shop-popup-on-hover-and-unselect-selected-feature/m-p/1390144#M83837</link>
    <description>&lt;P&gt;Thank you very much, this is exactly what i wanted 3&amp;gt;&lt;/P&gt;</description>
    <pubDate>Mon, 04 Mar 2024 06:08:55 GMT</pubDate>
    <dc:creator>Vakhtang_Zubiashvili</dc:creator>
    <dc:date>2024-03-04T06:08:55Z</dc:date>
    <item>
      <title>Shop popup on hover and unselect selected feature</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/shop-popup-on-hover-and-unselect-selected-feature/m-p/1388756#M83799</link>
      <description>&lt;P&gt;Hello Guyz,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have changed &lt;STRONG&gt;click&lt;/STRONG&gt; event to &lt;STRONG&gt;mouseover&amp;nbsp;&lt;/STRONG&gt;in this &lt;A title="Select Feature on hover" href="https://codepen.io/Vakhtang_zuba/pen/VwNwbvK?appcue=-MA2c6MyhNoeYWwK8ZXY" target="_blank" rel="noopener"&gt;sample&lt;/A&gt;, here on mouse hover view goes to feature. Two thing i want to do are:&lt;/P&gt;&lt;P&gt;1) Open popup for selected feature, i tried &lt;STRONG&gt;view.openPopup({}), &lt;/STRONG&gt;but i think i have missing something.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2)&amp;nbsp; Deselect selected feature after mouse out on button.&lt;/P&gt;&lt;P&gt;this two thing, i think it will help others too in the future.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Feb 2024 13:17:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/shop-popup-on-hover-and-unselect-selected-feature/m-p/1388756#M83799</guid>
      <dc:creator>Vakhtang_Zubiashvili</dc:creator>
      <dc:date>2024-02-29T13:17:34Z</dc:date>
    </item>
    <item>
      <title>Re: Shop popup on hover and unselect selected feature</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/shop-popup-on-hover-and-unselect-selected-feature/m-p/1388981#M83806</link>
      <description>&lt;P&gt;This probably has what you need to accomplish what you're trying to do, or at least get you closer to it anyways:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;html lang="en"&amp;gt;
  &amp;lt;head&amp;gt;
    &amp;lt;meta charset="utf-8" /&amp;gt;
    &amp;lt;meta
      name="viewport"
      content="initial-scale=1,maximum-scale=1,user-scalable=no"
    /&amp;gt;
    &amp;lt;title&amp;gt;
      Highlight point features | Sample | ArcGIS Maps SDK for JavaScript 4.29
    &amp;lt;/title&amp;gt;

    &amp;lt;link rel="stylesheet" href="https://js.arcgis.com/4.29/esri/themes/light/main.css" /&amp;gt;
    &amp;lt;script src="https://js.arcgis.com/4.29/"&amp;gt;&amp;lt;/script&amp;gt;
    &amp;lt;style&amp;gt;
      html,
      body,
      #viewDiv {
        padding: 0;
        margin: 0;
        height: 100%;
        width: 100%;
      }

      #paneDiv {
        position: absolute;
        bottom: 40px;
        width: 100%;
        text-align: center;
        background-color: transparent;
        color: white;
      }

      .esri-button-overwrite {
        width:auto;
        display: table-cell;
        margin: 4px;
        background-color: white;
        color: #0079c1;
      }
    &amp;lt;/style&amp;gt;
    &amp;lt;script&amp;gt;
      require(["esri/Map", "esri/WebScene", "esri/views/SceneView"], (
        Map,
        WebScene,
        SceneView
      ) =&amp;gt; {
        // load webscene from portal item
        const webScene = new WebScene({
          portalItem: {
            // autocasts as new PortalItem()
            id: "475a7161ed194460b5b52654e29581a2"
          }
        });

        const view = new SceneView({
          map: webScene,
          container: "viewDiv",
          // set highlightOptions like color and fillOpacity
          highlightOptions: {
            color: [255, 241, 58],
            fillOpacity: 0.4
          }
        });

        // these two highlight handlers are used for selection and hovering over features
        let highlightSelect;

        webScene.when(() =&amp;gt; {
          // get layer from webScene
          const stationLayer = webScene.layers.getItemAt(1);

          // highlight is set on the layerView, so we need to detect when the layerView is ready
          view.whenLayerView(stationLayer).then((layerView) =&amp;gt; {
            // creates the query that will be used to obtain the features needed for the highlight
            const queryStations = stationLayer.createQuery();
            // features that are passed in the highlight function need to have an `objectID`
            // if the query is built using `new Query()` then `queryStations.outFields = ["objectID"]` should be set

            const buttons = document.querySelectorAll("button");
            for (let i = 0, button = null; (button = buttons[i]); i++) {
              button.addEventListener("mouseover", onClick);
              button.addEventListener("mouseout", onMouseOut);
            }

            function onClick(event) {
              queryStations.where = `nom='${event.target.innerText}'`;
              stationLayer.queryFeatures(queryStations).then((result) =&amp;gt; {
                if (typeof view.popup?.clear == "function") {
                  view.popup.close();
                  view.popup.clear();
                }

                // if a feature is already highlighted, then remove the highlight
                if (highlightSelect) {
                  highlightSelect.remove();
                  highlightSelect = null;
                }

                // the feature to be highlighted
                const feature = result.features[0];

                view.openPopup({ features: [feature] });

                // use the objectID to highlight the feature
                highlightSelect = layerView.highlight(
                  feature.attributes["OBJECTID"]
                );
/*
                      // center the feature
                      view
                        .goTo(
                          {
                            target: feature.geometry,
                            tilt: 70,
                            zoom: 16
                          },
                          {
                            duration: 2000,
                            easing: "in-out-expo"
                          }
                        )
                        .catch((error) =&amp;gt; {
                          if (error.name != "AbortError") {
                            console.error(error);
                          }
                        });
*/
              });
            }

            function onMouseOut(evt) {
              if (typeof view.popup?.clear == "function") {
                view.popup.close();
                view.popup.clear();
              }

              if (highlightSelect) {
                highlightSelect.remove();
                highlightSelect = null;
              }
            }
          });
        });
      });
    &amp;lt;/script&amp;gt;
  &amp;lt;/head&amp;gt;

  &amp;lt;body&amp;gt;
    &amp;lt;div id="viewDiv"&amp;gt;&amp;lt;/div&amp;gt;
    &amp;lt;div id="paneDiv" class="esri-widget"&amp;gt;
      &amp;lt;h3&amp;gt;Subway stations&amp;lt;/h3&amp;gt;
      &amp;lt;button class="esri-button esri-button-overwrite"&amp;gt;Valmy&amp;lt;/button&amp;gt;
      &amp;lt;button class="esri-button esri-button-overwrite"&amp;gt;
        St-Jean Vieux Lyon
      &amp;lt;/button&amp;gt;
      &amp;lt;button class="esri-button esri-button-overwrite"&amp;gt;Charpennes&amp;lt;/button&amp;gt;
      &amp;lt;button class="esri-button esri-button-overwrite"&amp;gt;Sans souci&amp;lt;/button&amp;gt;
      &amp;lt;button class="esri-button esri-button-overwrite"&amp;gt;Hôtel de Ville&amp;lt;/button&amp;gt;
      &amp;lt;button class="esri-button esri-button-overwrite"&amp;gt;Garibaldi&amp;lt;/button&amp;gt;
    &amp;lt;/div&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note that adding and removing a highlight is redundant because the popup adds its own highlight as well.&amp;nbsp; Therefore, in order to get rid of the popup's highlight, I added code to close the popup as well.&amp;nbsp; I also commented out the part where the view zooms to the selected feature...otherwise, the popup would always appear over top of the feature, effectively hiding it.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Feb 2024 17:53:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/shop-popup-on-hover-and-unselect-selected-feature/m-p/1388981#M83806</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2024-02-29T17:53:50Z</dc:date>
    </item>
    <item>
      <title>Re: Shop popup on hover and unselect selected feature</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/shop-popup-on-hover-and-unselect-selected-feature/m-p/1390144#M83837</link>
      <description>&lt;P&gt;Thank you very much, this is exactly what i wanted 3&amp;gt;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2024 06:08:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/shop-popup-on-hover-and-unselect-selected-feature/m-p/1390144#M83837</guid>
      <dc:creator>Vakhtang_Zubiashvili</dc:creator>
      <dc:date>2024-03-04T06:08:55Z</dc:date>
    </item>
  </channel>
</rss>

