<?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: on &amp;quot;basemap-change&amp;quot; not firing and getBasemap not working as expected in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/on-amp-amp-quot-basemap-change-amp-amp-quot-not/m-p/637500#M59565</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;If you are working with the basemap gallery, then you will have to monitor it's change events and use it's methods to get the current selected basemap.&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
basemapGallery.on('selection-change', function(){
&amp;nbsp; alert(basemapGallery.getSelected().title);
});
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;You'll probably want to return the id instead of the title, since that's what the basemapGallery.select() requires.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Yea that's what I ended up doing, but since that returns the label or the id as "basemap_0" or whatever number the id has, I had to use a sort of lookup table to map the id/title to it's well-known name so that I can call map.setBasemap("gray") (or whatever the basemap name is) on the other map objects that are synced with the main one. Was kind of hoping I could call map.getBasemap() but it seems this is not tied to the basemap gallery so once you change basemaps, map.getBasemap() returns the incorrect name or use one of the aforementioned events which is supposed to return the well-known name but I can't get those to fire&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 03:05:56 GMT</pubDate>
    <dc:creator>RobertWinterbottom</dc:creator>
    <dc:date>2021-12-12T03:05:56Z</dc:date>
    <item>
      <title>on &amp;amp;quot;basemap-change&amp;amp;quot; not firing and getBasemap not working as expected</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/on-amp-amp-quot-basemap-change-amp-amp-quot-not/m-p/637498#M59563</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; I am having some troubles with these two event listeners(onBasemapChange() and it's on equivalent "basemap-change") for the map as well as the map.getBasemap() function.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have tried this in my own code and then also went to the basemap gallery sample and added these events/function to the sandbox to test there as well.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The sample I used is here: &lt;/SPAN&gt;&lt;A href="http://developers.arcgis.com/en/javascript/sandbox/sandbox.html?sample=widget_basemap" rel="nofollow noopener noreferrer" target="_blank"&gt;http://developers.arcgis.com/en/javascript/sandbox/sandbox.html?sample=widget_basemap&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I then added the following code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
map.on("load",function(){
&amp;nbsp; map.on("basemap-change",function(){
&amp;nbsp;&amp;nbsp;&amp;nbsp; alert("Fired Basemap-change");
&amp;nbsp; });
});
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
basemapGallery.on("selection-change",function(){
&amp;nbsp; alert(map.getBasemap());
});&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The "Fired Basemap-change" alert never fires even when I tried this&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
dojo.connect(map,"onBasemapChange",function(){
&amp;nbsp; alert("Fired Basemap-change")
})&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The second alert will fire as it is inside the basemapGallery.on("selection-change") but the map.getBasemap() returns the same string every time, whatever I set the default basemap inside the map constructor to is the value this function always returns, I thought it was supposed to return the well-known name of the current basemap, is this normal for this function?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In the end I am building a custom dojo widget to sync 4 map objects together and am trying to add in a basemap syncing option as well so that when the user changes the basemap on the main map, it changes the other maps basemaps as well.&amp;nbsp; My thought was to get the well-known name of the current basemap from the main map and then loop through my array of other maps and just simply call map.setBasemap.&amp;nbsp; Is there another way to get this well-known basemap name?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:05:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/on-amp-amp-quot-basemap-change-amp-amp-quot-not/m-p/637498#M59563</guid>
      <dc:creator>RobertWinterbottom</dc:creator>
      <dc:date>2021-12-12T03:05:51Z</dc:date>
    </item>
    <item>
      <title>Re: on "basemap-change" not firing and getBasemap not working as expected</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/on-amp-amp-quot-basemap-change-amp-amp-quot-not/m-p/637499#M59564</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If you are working with the basemap gallery, then you will have to monitor it's change events and use it's methods to get the current selected basemap.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
basemapGallery.on('selection-change', function(){
&amp;nbsp; alert(basemapGallery.getSelected().title);
});
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You'll probably want to return the id instead of the title, since that's what the basemapGallery.select() requires.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:05:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/on-amp-amp-quot-basemap-change-amp-amp-quot-not/m-p/637499#M59564</guid>
      <dc:creator>MattLane</dc:creator>
      <dc:date>2021-12-12T03:05:53Z</dc:date>
    </item>
    <item>
      <title>Re: on "basemap-change" not firing and getBasemap not working as expected</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/on-amp-amp-quot-basemap-change-amp-amp-quot-not/m-p/637500#M59565</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;If you are working with the basemap gallery, then you will have to monitor it's change events and use it's methods to get the current selected basemap.&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
basemapGallery.on('selection-change', function(){
&amp;nbsp; alert(basemapGallery.getSelected().title);
});
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;You'll probably want to return the id instead of the title, since that's what the basemapGallery.select() requires.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Yea that's what I ended up doing, but since that returns the label or the id as "basemap_0" or whatever number the id has, I had to use a sort of lookup table to map the id/title to it's well-known name so that I can call map.setBasemap("gray") (or whatever the basemap name is) on the other map objects that are synced with the main one. Was kind of hoping I could call map.getBasemap() but it seems this is not tied to the basemap gallery so once you change basemaps, map.getBasemap() returns the incorrect name or use one of the aforementioned events which is supposed to return the well-known name but I can't get those to fire&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:05:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/on-amp-amp-quot-basemap-change-amp-amp-quot-not/m-p/637500#M59565</guid>
      <dc:creator>RobertWinterbottom</dc:creator>
      <dc:date>2021-12-12T03:05:56Z</dc:date>
    </item>
  </channel>
</rss>

