<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Basemap Gallery on Node Dangles</title>
    <link>https://maprantala.com/tags/basemap-gallery/</link>
    <description>Recent content in Basemap Gallery on Node Dangles</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <lastBuildDate>Mon, 10 Apr 2017 20:08:37 -0500</lastBuildDate>
    <atom:link href="https://maprantala.com/tags/basemap-gallery/index.xml" rel="self" type="application/rss+xml" />
    
    <item>
      <title>Esri Web AppBuilder 2.4 Empty Basemap Gallery</title>
      <link>https://maprantala.com/2017/04/10/esri-web-appbuilder-2.4-empty-basemap-gallery/</link>
      <pubDate>Mon, 10 Apr 2017 20:08:37 -0500</pubDate>
      <guid>https://maprantala.com/2017/04/10/esri-web-appbuilder-2.4-empty-basemap-gallery/</guid>
      <description>&lt;p&gt;I recently downloaded Web AppBuilder 2.4, Developer&amp;rsquo;s Edition and built a quick &amp;amp; dirty app. For some reason, it worked fine in Web AppBuilder but once I deployed it, no basemaps would show in the &lt;a href=&#34;http://doc.arcgis.com/en/web-appbuilder/create-apps/widget-basemap.htm&#34;&gt;Basemap Gallery widget&lt;/a&gt;, it would just spin, spin, spin.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://maprantala.com/images/2017/04/BasemapGallery.png&#34; alt=&#34;Basemap Gallery&#34;&gt;&lt;/p&gt;
&lt;p&gt;Digging around, I found some &lt;a href=&#34;https://geonet.esri.com/thread/118906&#34;&gt;old posts&lt;/a&gt; where users were experiencing similar problems but none of the solution resulted in a great solution. I was able to get it to work by listing the basemaps individually in the config_BasemapGallery.json file but I that was more of a work-around. Notice in the thumbnailUrl, I have to put the full path to the thumbnails. Note that for brevity&amp;rsquo;s sake, I&amp;rsquo;m only showing one of the basemaps in this sample.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-javascript&#34; data-lang=&#34;javascript&#34;&gt;{
  &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;basemapGallery&amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; {
    &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;showArcGISBasemaps&amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;true&lt;/span&gt;,
    &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;basemaps&amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; [{
      &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;layers&amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; [{&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;url&amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;http://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer&amp;#34;&lt;/span&gt;}],
      &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;title&amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Imagery&amp;#34;&lt;/span&gt;,
      &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;thumbnailUrl&amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;http://&amp;lt;org&amp;gt;.maps.arcgis.com/sharing/rest/content/items/&amp;lt;id&amp;gt;/info/thumbnail/tempimagery.jpg&amp;#34;&lt;/span&gt;,
      &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;spatialReference&amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; {
         &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;wkid&amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;102100&amp;#34;&lt;/span&gt;
      }
     }]
   }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Eventually, I started comparing the requests generated by the version in the development version and the one in production and tracked the problem down to this POST request in production, which was returning a 400 Bad Request error:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-javascript&#34; data-lang=&#34;javascript&#34;&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;http&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;//&amp;lt;server&amp;gt;/proxy/proxy.ashx?https://&amp;lt;org&amp;gt;.maps.arcgis.com/sharing/rest/search&amp;amp;wab_dv=2.4
&lt;/span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To this one in dev:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-javascript&#34; data-lang=&#34;javascript&#34;&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;https&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;//&amp;lt;org&amp;gt;.maps.arcgis.com/sharing/rest/search
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I stripped off the &amp;lsquo;&amp;amp;wab_dv=2.4&amp;rsquo; parameter from the production request and Boom! it worked. So I now knew what was causing the problem. Just had to figure out why it was occurring. I had actually already seen part of the answer while digging around in &lt;strong&gt;env.js&lt;/strong&gt; while looking for a way to test my changes without having to clear my cache or remember to use an Incognito session. On line 81 of &lt;strong&gt;env.js&lt;/strong&gt;, there is this variable, &lt;strong&gt;deployVersion&lt;/strong&gt; which is set to 2.4.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://maprantala.com/images//2017/04/deployVersion.png&#34; alt=&#34;Options&#34;&gt;&lt;/p&gt;
&lt;p&gt;I had recently worked on a solution that involved appending a time stamp onto scripts we were loading so I was familiar with what is going on–the code was appending a version onto the call so that if you change the &lt;strong&gt;deployVersion&lt;/strong&gt;, the browser would load a new version of the code. The &lt;strong&gt;appendDeployVersion&lt;/strong&gt; function on line 307 of &lt;strong&gt;env.js&lt;/strong&gt; was doing the append. Notice the &lt;strong&gt;if&lt;/strong&gt; statement on line 312, it checks for &amp;lsquo;?&amp;rsquo; in the url. If it finds one, it appends &amp;lsquo;**&amp;amp;&lt;strong&gt;wab_dv=&amp;rsquo; and the version, otherwise it appends &amp;lsquo;&lt;/strong&gt;?**wab_dv=&amp;rsquo; and the version–the difference being the &amp;lsquo;&amp;amp;&amp;rsquo; vs &amp;lsquo;?&amp;rsquo;. A question mark is used before the first parameter in an URL, each additional parameter is separated by a ampersand (&amp;amp;) so that logic makes sense.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://maprantala.com/images/2017/04/IfStatement.png&#34; alt=&#34;Options&#34;&gt;&lt;/p&gt;
&lt;p&gt;However, the monkey wrench is that I&amp;rsquo;m using a proxy, so my URL has a question mark related to the proxy:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-javascript&#34; data-lang=&#34;javascript&#34;&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;http&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;//&amp;lt;server&amp;gt;/proxy/proxy.ashx&amp;lt;strong&amp;gt;?&amp;lt;/strong&amp;gt;https://&amp;lt;org&amp;gt;.maps.arcgis.com/sharing/rest/search&amp;amp;wab_dv=2.4
&lt;/span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;So the code was dutifully appending an ampersand and the version parameter &amp;lsquo;&amp;amp;wab_dv=2.4&amp;rsquo; to my URL so the proxy would be requesting:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-javascript&#34; data-lang=&#34;javascript&#34;&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;https&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;//&amp;lt;org&amp;gt;.maps.arcgis.com/sharing/rest/search&amp;amp;wab_dv=2.4
&lt;/span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;when it should have been requesting:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-javascript&#34; data-lang=&#34;javascript&#34;&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;https&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;:&lt;/span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;//&amp;lt;org&amp;gt;.maps.arcgis.com/sharing/rest/search?wab_dv=2.4
&lt;/span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Once I had determined the problem (99% of the battle), I was able to quickly put in a patch that works for my instance. This patch isn&amp;rsquo;t a great one that Esri should use but it solves it in my case. I just added logic so that it would ignore proxy-related question marks:&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://maprantala.com/images/2017/04/solution.png&#34; alt=&#34;Options&#34;&gt;&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-javascript&#34; data-lang=&#34;javascript&#34;&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;appendDeployVersion&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;url&lt;/span&gt;){
    &lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;/^http(s)?:\/\//&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;test&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;url&lt;/span&gt;) &lt;span style=&#34;color:#f92672&#34;&gt;||&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;/^\/proxy\.js/&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;test&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;url&lt;/span&gt;) &lt;span style=&#34;color:#f92672&#34;&gt;||&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;/^\/\//&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;test&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;url&lt;/span&gt;)){
      &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;url&lt;/span&gt;;
    }

	&lt;span style=&#34;color:#66d9ef&#34;&gt;var&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;proxyURL&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;url&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;toLowerCase&lt;/span&gt;().&lt;span style=&#34;color:#a6e22e&#34;&gt;replace&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;.ashx?&amp;#34;&lt;/span&gt;,&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;);
    &lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;proxyURL&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;indexOf&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;?&amp;#39;&lt;/span&gt;) &lt;span style=&#34;color:#f92672&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;-&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;){
      &lt;span style=&#34;color:#a6e22e&#34;&gt;url&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;url&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;&amp;amp;wab_dv=&amp;#39;&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;deployVersion&lt;/span&gt;;
    }&lt;span style=&#34;color:#66d9ef&#34;&gt;else&lt;/span&gt;{
      &lt;span style=&#34;color:#a6e22e&#34;&gt;url&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;url&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;?wab_dv=&amp;#39;&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;deployVersion&lt;/span&gt;;
    }
    &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;url&lt;/span&gt;;
  }

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And voila! my Web AppBuilder now had all the basemaps options a mapineer could hope for:&lt;br&gt;
&lt;img src=&#34;https://maprantala.com/images/2017/04/BaemapsAplenty.png&#34; alt=&#34;Options&#34;&gt;&lt;/p&gt;
</description>
    </item>
    
  </channel>
</rss>
