How to change the scale bar unit correctly while printing map?

4460
4
01-28-2015 08:53 PM
StephenLam
New Contributor III

Please find the attached image as below, although I have changed the scalebarUnit to "Meter", it really just changes the unit from "km" to "m".

Here is the code

// create a print template for each choice
templates = arrayUtils.map(templateNames, function (ch) {
  var plate = new PrintTemplate();
  //plate.preserveScale = true;   // Default = false
  plate.layout = plate.label = ch;
  plate.format = "JPG";
  plate.layoutOptions = {
  "legendLayers": legendLayers,
  "scalebarUnit": "Meters"
  };
  plate.preserveScale = false;
  return plate;
});


// create the print dijit


var printer = new Print({
  "map": map,
  "templates": templates,
  url: xxx
}, dojo.byId("printButton"));
printer.startup();

Please advice, thanks.

Km:

km.jpg

Meter:

m.jpg

0 Kudos
4 Replies
StephenLam
New Contributor III

Any idea?

0 Kudos
ChrisSergent
Regular Contributor III

I tried changing to kilometers and meters here: JS Bin - Collaborative JavaScript Debugging

and the scalebar output changes. Have you ran your app in debug mode perhaps in the Dev tools in Google Chrome?

MikeKillion
New Contributor II

Any solution to this yet?

On my own site (jsapi 3.7), changing scalebarUnit from Miles to Feet only changes the unit text- what was 0.5 miles now reads 0.5 feet. What I'd like to do is display in feet when zoomed in and miles when zoomed out by passing a variable to scalebarUnit.

Thanks.

StephenLam
New Contributor III

Not yet. The problem is still exist. For work around (seems stupid), I told my client that there are some bugs in ArcGIS Javascript API, this issue may be fixed in the future......

0 Kudos