Select to view content in your preferred language

BasemapGallery does not do the map switch

804
3
06-25-2014 06:35 AM
YinghongLi
Frequent Contributor
Hello,

I modified one of the basemap sample and put my own services in.  Then I found out that only first basemap service displayed.  I have two services in.  no matter what the 2nd one in the list never shows.  there is not much in the code. both services have same coordinate system.  only difference I can tell is that one is a jpeg picture another (image) in png.  Please let me know any possible thing which may cause this.  thanks.

<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <!--The viewport meta tag is used to improve the presentation and behavior of the samples
    on iOS devices-->
  <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
  <title>Display Multiple ArcGIS Online Services</title>
  <link rel="stylesheet" href="http://js.arcgis.com/3.9/js/dojo/dijit/themes/claro/claro.css">
  <link rel="stylesheet" href="http://js.arcgis.com/3.9/js/esri/css/esri.css">
  <style>
    html, body {
      height: 97%;
      width: 98%;
      margin: 1%;
    }

    #map {
      border: solid 1px #B5BCC7;
      padding: 0;
    }

    #paneHeader {
      background: url(images/header.png) repeat-x;
      color: white;
      border-bottom: solid 1px #B5BCC7;
      text-align: center;
      height: 30px;
      margin: 0;
      overflow: hidden;
      font-size: 16px;
      padding: 8px 5px;
    }

    #rightPane {
      width: 150px;
      margin: 0;
      padding: 0;
    }
  </style>

  <script>var dojoConfig = { parseOnLoad: true };</script>
  <script src="http://js.arcgis.com/3.9/"></script>

  <script>
      dojo.require("esri.map");
      dojo.require("dijit.form.Button");
      dojo.require("dijit.layout.BorderContainer");
      dojo.require("dijit.layout.ContentPane");
      dojo.require("esri.dijit.BasemapGallery");
      dojo.require("esri.arcgis.utils");

      var map;

      function init() {
          map = new esri.Map("map");
          createBasemapGallery();
      }

      function createBasemapGallery() {
          //manually create basemaps to add to basemap gallery
          var basemaps = [];
       

          var publicSafetyLayer = new esri.dijit.BasemapLayer({
              url: "http://coaagssomtst.coacd.org/ArcGIS/rest/services/MapTiled/AerialImagery/MapServer"  //png
          });
          var publicSafetyBasemap = new esri.dijit.Basemap({
              layers: [publicSafetyLayer],
              title: "Public Safety",
              thumbnailUrl: "images/safetyThumb.png"
          });
          basemaps.push(publicSafetyBasemap);

          var waterTemplateLayer = new esri.dijit.BasemapLayer({
              url: "http://coaagssomtst.coacd.org/ArcGIS/rest/services/MapTiled/COAViewer_dev/MapServer"   //jpeg
          });
          var waterBasemap = new esri.dijit.Basemap({
              layers: [waterTemplateLayer],
              title: "Water Template",
              thumbnailUrl: "images/waterThumb.png"
          });
          basemaps.push(waterBasemap);

          var basemapGallery = new esri.dijit.BasemapGallery({
              showArcGISBasemaps: false,
              basemaps: basemaps,
              map: map
          }, "basemapGallery");
          basemapGallery.startup();

          dojo.connect(basemapGallery, "onError", function (error) {
              console.log(error)
          });
      }

      dojo.ready(init);
  </script>

</head>
<body class="claro">
<!--[if IE 7]>
<style>
  html, body {
    margin: 0;
  }
</style>
<![endif]-->
<div data-dojo-type="dijit.layout.BorderContainer"
     data-dojo-props="design:'headline', gutters:true"
     style="width:100%;height:100%;">

  <div id="map"
       data-dojo-type="dijit.layout.ContentPane"
       data-dojo-props="region:'center'">
  </div>

  <div data-dojo-type="dijit.layout.ContentPane"
       data-dojo-props="region:'right'" id="rightPane">

    <div data-dojo-type="dijit.layout.BorderContainer"
         data-dojo-props="design:'headline', gutters:false"
         style="width:100%;height:100%;">
      <div id="paneHeader"
           data-dojo-type="dijit.layout.ContentPane"
           data-dojo-props="region:'top'">
        <span>Select Basemap</span>
      </div>
      <div data-dojo-type="dijit.layout.ContentPane"
           data-dojo-props="region:'center'">

        <div id="basemapGallery"></div>

      </div>
    </div>
  </div>
</div>
</body>
</html>
0 Kudos
3 Replies
KonstantinLapine
Emerging Contributor
At the moment, coaagssomtst.coacd.org doesn't seem responding to outside requests.
0 Kudos
YinghongLi
Frequent Contributor
sorry I forgot to mention the services I used here are internal versions.  I will switch to external ones and post the code again.

Thanks
0 Kudos
YinghongLi
Frequent Contributor
I COAViewer_dev to another basemap layer and it works.  Now I can switch from street view to image view.

Thanks klapine.
0 Kudos