<?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: BasemapGallery doesn't respond to event &amp;quot;selection-change&amp;quot; in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/basemapgallery-doesn-t-respond-to-event-quot/m-p/1211743#M78679</link>
    <description>&lt;P&gt;Thanks a lot!&lt;/P&gt;</description>
    <pubDate>Mon, 12 Sep 2022 18:28:24 GMT</pubDate>
    <dc:creator>DimaY</dc:creator>
    <dc:date>2022-09-12T18:28:24Z</dc:date>
    <item>
      <title>BasemapGallery doesn't respond to event "selection-change"</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/basemapgallery-doesn-t-respond-to-event-quot/m-p/1211496#M78667</link>
      <description>&lt;P&gt;Very strange! Everything works, but even the alert does not pop up on the event. And no errors either in the code, or in the debug, or in the console&lt;/P&gt;&lt;P&gt;What's wrong?&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Example Code:&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;const map = new Map({&lt;BR /&gt;basemap: "satellite"&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;const view = new SceneView({&lt;BR /&gt;container: "viewDiv",&lt;BR /&gt;map: map&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;const basemapGallery = new BasemapGallery({&lt;BR /&gt;view: view,&lt;BR /&gt;container: document.createElement("div")&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;basemapGallery.on("selection-change", function (event) {&lt;BR /&gt;alert("basemapGallery selection change");&lt;BR /&gt;console.log("event ", event);&lt;BR /&gt;});&lt;/P&gt;</description>
      <pubDate>Mon, 12 Sep 2022 07:34:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/basemapgallery-doesn-t-respond-to-event-quot/m-p/1211496#M78667</guid>
      <dc:creator>DimaY</dc:creator>
      <dc:date>2022-09-12T07:34:33Z</dc:date>
    </item>
    <item>
      <title>Re: BasemapGallery doesn't respond to event "selection-change"</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/basemapgallery-doesn-t-respond-to-event-quot/m-p/1211519#M78671</link>
      <description>&lt;P&gt;According to the doc, there is no "selection-change" event on the BasemapGallery widget:&lt;BR /&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery.html" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery.html&lt;/A&gt;&lt;BR /&gt;Did you find a reference to this event somewhere?&lt;/P&gt;&lt;P&gt;---&lt;/P&gt;&lt;P&gt;You could instead watch the basemap like this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;map.watch("basemap", (newBasemap, oldBasemap) =&amp;gt; {
  console.log("new", newBasemap);
  console.log("old", oldBasemap);
});&lt;/LI-CODE&gt;&lt;DIV&gt;which will allow you to react to arbitrary changes of the basemap, e.g. when changed via BasemapGallery widget.&lt;BR /&gt;Does this help your case?&lt;/DIV&gt;</description>
      <pubDate>Mon, 12 Sep 2022 10:11:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/basemapgallery-doesn-t-respond-to-event-quot/m-p/1211519#M78671</guid>
      <dc:creator>AndreasUlmer</dc:creator>
      <dc:date>2022-09-12T10:11:10Z</dc:date>
    </item>
    <item>
      <title>Re: BasemapGallery doesn't respond to event "selection-change"</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/basemapgallery-doesn-t-respond-to-event-quot/m-p/1211688#M78675</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I don't understand, if I created an object "const basemapGallery = new BasemapGallery", why can't I catch events just at least by choice or just by click?&amp;nbsp;&amp;nbsp;Just to see that I clicked on the select, I have to describe all the possible basemaps? newBasemap, oldBasemap, 3, 4,5,6,7,8 ....&amp;nbsp; &amp;nbsp;If there are many?&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":thinking_face:"&gt;🤔&lt;/span&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;"Did you find a reference to this event somewhere?"&amp;nbsp;&amp;nbsp;Here is the link.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/javascript/3/jsapi/basemapgallery.html#event-selection-change" target="_blank"&gt;https://developers.arcgis.com/javascript/3/jsapi/basemapgallery.html#event-selection-change&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But this is obvious from another opera, as they say...&amp;nbsp;&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Obviously, it is necessary to insert and add a bunch of all sorts of troubles in order to earn an elementary event for selecting an element from the list.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":face_with_rolling_eyes:"&gt;🙄&lt;/span&gt;&lt;BR /&gt;Thanks/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Sep 2022 17:10:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/basemapgallery-doesn-t-respond-to-event-quot/m-p/1211688#M78675</guid>
      <dc:creator>DimaY</dc:creator>
      <dc:date>2022-09-12T17:10:23Z</dc:date>
    </item>
    <item>
      <title>Re: BasemapGallery doesn't respond to event "selection-change"</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/basemapgallery-doesn-t-respond-to-event-quot/m-p/1211693#M78676</link>
      <description>&lt;P&gt;And sorry again. I apparently really did not understand the description of the parameters. But I'm interested in the event on click on the basemapgallery event before changing the map. And not on map watch,&amp;nbsp;which takes place after.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Sep 2022 17:21:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/basemapgallery-doesn-t-respond-to-event-quot/m-p/1211693#M78676</guid>
      <dc:creator>DimaY</dc:creator>
      <dc:date>2022-09-12T17:21:22Z</dc:date>
    </item>
    <item>
      <title>Re: BasemapGallery doesn't respond to event "selection-change"</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/basemapgallery-doesn-t-respond-to-event-quot/m-p/1211723#M78678</link>
      <description>&lt;P&gt;The code you have indicates you're using version 4.x of the API, but the documentation you referred to is for 3.x, which doesn't correspond.&amp;nbsp; The 4.x &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery.html" target="_self"&gt;BasemapGallery&lt;/A&gt; does not support the kind of event you're looking for, at least according to the documentation anyways, but you shouldn't let that stop you.&amp;nbsp; With a glance at the source code for the BasemapGallery widget, it can be seen that the following hack will do what you're asking:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const basemapGallery = new BasemapGallery({
	view: view,
	container: document.createElement("div")
});

basemapGallery._originalHandleClick = basemapGallery._handleClick;
basemapGallery._handleClick = function(evt) {
	var basemapGalleryItem = evt.currentTarget["data-item"];

	alert("You selected the basemap with title = [" + basemapGalleryItem.get("basemap.title") + "] and id = [" + basemapGalleryItem.get("basemap.id") + "]");

	this._originalHandleClick(evt);
};&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;See also the reference for &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BasemapGallery-support-BasemapGalleryItem.html" target="_self"&gt;BasemapGalleryItem&lt;/A&gt; for further information.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Sep 2022 18:02:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/basemapgallery-doesn-t-respond-to-event-quot/m-p/1211723#M78678</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2022-09-12T18:02:54Z</dc:date>
    </item>
    <item>
      <title>Re: BasemapGallery doesn't respond to event "selection-change"</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/basemapgallery-doesn-t-respond-to-event-quot/m-p/1211743#M78679</link>
      <description>&lt;P&gt;Thanks a lot!&lt;/P&gt;</description>
      <pubDate>Mon, 12 Sep 2022 18:28:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/basemapgallery-doesn-t-respond-to-event-quot/m-p/1211743#M78679</guid>
      <dc:creator>DimaY</dc:creator>
      <dc:date>2022-09-12T18:28:24Z</dc:date>
    </item>
    <item>
      <title>Re: BasemapGallery doesn't respond to event "selection-change"</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/basemapgallery-doesn-t-respond-to-event-quot/m-p/1211895#M78684</link>
      <description>&lt;P&gt;But properties&amp;nbsp;_originalHandleClick,&amp;nbsp;_handleClick ...&amp;nbsp; does not exist on type&amp;nbsp;BasemapGallery.&amp;nbsp; Code doesn't work.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Sep 2022 05:36:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/basemapgallery-doesn-t-respond-to-event-quot/m-p/1211895#M78684</guid>
      <dc:creator>DimaY</dc:creator>
      <dc:date>2022-09-13T05:36:53Z</dc:date>
    </item>
    <item>
      <title>Re: BasemapGallery doesn't respond to event "selection-change"</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/basemapgallery-doesn-t-respond-to-event-quot/m-p/1212027#M78692</link>
      <description>&lt;P&gt;The code works as it should.&amp;nbsp; To verify, replace lines 43-45 of &lt;A href="https://developers.arcgis.com/javascript/latest/sample-code/sandbox/?sample=widgets-basemapgallery" target="_self"&gt;this sample&lt;/A&gt; with the code above, then click the Refresh item at the top right of the page.&amp;nbsp; Afterwards, clicking an item in the gallery will then produce an alert as expected, and also change the basemap.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Sep 2022 16:06:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/basemapgallery-doesn-t-respond-to-event-quot/m-p/1212027#M78692</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2022-09-13T16:06:37Z</dc:date>
    </item>
    <item>
      <title>Re: BasemapGallery doesn't respond to event "selection-change"</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/basemapgallery-doesn-t-respond-to-event-quot/m-p/1212321#M78706</link>
      <description>&lt;P&gt;But in the angular that I use, exactly the same code does not know this event and these properties at all. And it doesn't work.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Sep 2022 09:14:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/basemapgallery-doesn-t-respond-to-event-quot/m-p/1212321#M78706</guid>
      <dc:creator>DimaY</dc:creator>
      <dc:date>2022-09-14T09:14:19Z</dc:date>
    </item>
  </channel>
</rss>

