change basemapLayer in overviewMapDijit

2314
1
10-19-2015 07:59 AM
VincentChoffrut
New Contributor

hello everyone,

I'm trying to change the basemaplayer in a overviewmapDijit...

does anyone has a clue why the following code fragment doesn't work ? 

THANX A LOT in advance!

var BM_OM = new ArcGISDynamicMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",{

useMapImage: true

});

BM_OM.on("load", function(evt){

console.log('BM loaded');

var overviewMapDijit = new OverviewMap({

map: map,

baseLayer: 'BM_OM'

}, "overviewMapDiv");

overviewMapDijit.startup();   

});

Tags (1)
0 Kudos
1 Reply
JakeSkinner
Esri Esteemed Contributor

Hi Vincent,

You are specifying the baseLayer as a string rather than the variable you defined previously.  You will also need to add the 'visible' option and set this to true.  Ex:

<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>Overview Map</title>
    <link rel="stylesheet" href="http://js.arcgis.com/3.14/dijit/themes/claro/claro.css">
    <link rel="stylesheet" href="http://js.arcgis.com/3.14/esri/css/esri.css">
    <style>
      html, body { height: 100%; width: 100%; margin: 0; padding: 0; }
    </style>


    <script src="http://js.arcgis.com/3.14/"></script>
    <script>
      var map;


      require([
        "esri/map", "esri/dijit/OverviewMap", "esri/layers/ArcGISDynamicMapServiceLayer",
        "dojo/parser", 


        "dijit/layout/BorderContainer", "dijit/layout/ContentPane", "dojo/domReady!"
      ], function (
        Map, OverviewMap, ArcGISDynamicMapServiceLayer,
        parser
      ) {
        parser.parse(); 


        map = new Map("map", {
          basemap: "streets",
          center: [-122.445, 37.752],
          zoom: 14
        });
        
        var BM_OM = new ArcGISDynamicMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",{
            useMapImage: true
        });
        
        BM_OM.on("load", function(evt){           
            var overviewMapDijit = new OverviewMap({
              map: map,
              baseLayer: BM_OM,
              visible: true
            });
            
            overviewMapDijit.startup();           
        });
        
      });
    </script>
  </head>
  
  <body class="claro">
    <div data-dojo-type="dijit/layout/BorderContainer" 
         data-dojo-props="design:'headline', gutters:false" 
         style="width: 100%; height: 100%; margin:0;">


      <div id="map" 
           data-dojo-type="dijit/layout/ContentPane" 
           data-dojo-props="region:'center'" 
           style="padding:0">
      </div>
    </div>
  </body>
</html>