AnsweredAssumed Answered

Adding scalebar to a template

Question asked by mbijou63 on Nov 28, 2014
Latest reply on Nov 28, 2014 by mbijou63

Hello!

I'm new to GeoNet, and I've done a bit of research on the web to try and solve this problem before asking here.

 

I've created a basic template using the application boilerplate, which works much as I expected with existing webmaps I've created to test with. When trying to add a scalebar, however, I can't get the scalebar to appear. The Chrome debugger notes that it is "unable to find the 'map' property in parameters". My script is pretty basic, as I'm not very experienced with the Javascript API, and it's probably this lack of experience that's causing me not to understand the issue.

 

The script in question:

 

var map;

require(["esri/map", "esri/dijit/Scalebar",

   "dojo/parser", "esri/arcgis/utils",

   "dijit/layout/BorderContainer", "dijit/layout/ContentPane",  

   "dojo/domReady!"

   ], function (Map, Scalebar, parser, arcgisUtils) {

      parser.parse();

      arcgisUtils.createMap("fa653f9345a44e7280d379419af73a3e", "mapDiv").then(function (response) {

      map = response.map;

      });

 

   var scalebar = new Scalebar({

  map: map,

   // "dual" displays both miles and kilmometers

   // "english" is the default, which displays miles

   // use "metric" for kilometers

  scalebarUnit: "dual"

   });

});

 

I know this method works with new maps, but it's imperative for this that I use existing webmaps. I'm not sure if a different approach has to be taken because of this. What am I doing wrong?

Outcomes