function ScaleIndicator(map, options) {
  options = options || {};
  this._map = map;

  var domElement = document.getElementById(options.domId);
  if (!domElement) {
    domElement = document.createElement('div');
    if (options.domId) {
      domElement.id = options.domId;
    }
    map.domNode.appendChild(domElement);
  }
  domElement.classList.add("scaleIndicator");
  this._scaleIndicatorNode = domElement;

  this._distanceUnit = options.distanceUnit || DistanceUnit.METRE;

  this._textNode = document.createElement("div");
  this._textNode.classList.add("scaleIndicatorText");
  this._scaleIndicatorNode.appendChild(this._textNode);

  this._backgroundNode = document.createElement("div");
  this._backgroundNode.classList.add("scaleIndicatorBackground");
  this._scaleIndicatorNode.appendChild(this._backgroundNode);

  var numberOfForegroundTicks = options.foregroundTicks || DEFAULT_NUMBER_FOREGROUND_TICKS;
  this._foregroundNodes = [];
  for (var i = 0; i < numberOfForegroundTicks; i++) {
    var foregroundNode = document.createElement("div");
    foregroundNode.classList.add("scaleIndicatorForeground");
    var leftPercentage = i * (100 / numberOfForegroundTicks);
    foregroundNode.style.left = leftPercentage + (leftPercentage > 0 ? "%" : "");
    foregroundNode.style.width = (100 / (numberOfForegroundTicks * 2)) + "%";
    this._backgroundNode.appendChild(foregroundNode);
    this._foregroundNodes.push(foregroundNode);
  }

  this._onMapChangeHandle = this._map.on("MapChange", this._onScaleChange.bind(this));
}
/**
 * Creates a scale indicator for the given map.
 * See ScaleIndicator.css for styling options.
 * The scale indicator is essentially a div with the following structure:
 *  -.scaleIndicator
 *    -.scaleIndicatorText //the node containing the scale text
 *    -.scaleIndicatorBackground //a single node containing the background color (default white)
 *      - .scaleIndicatorForeground //a number (options.foregroundTicks) of nodes containing the foreground color (default black)
 * @param map The map to create the scale indicator for.
 * @param options An options literal. The following options are supported:
 *        <ul>
 *          <li><b>options.domId</b> The dom ID of the DIV that is the scale indicator.
 *             When omitted, this div will be created for you inside the map's DOM node.
 *             When specified and an element with that ID exists, that element will be used.
 *             When specified and no element with that ID exists, that ID will be assigned to the
 *              DOM node that was created for you inside the map's DOM node.</li>
 *           <li><b>options.distanceUnit</b> The distance unit that is used by the scale indicator. Defaults to DistanceUnit.METRE.</li>
 *           <li><b>options.foregroundTicks</b> The number of foreground ticks (black bars) that is shown on the scale indicator. Defaults to 2.</li>
 *        </ul>
 *
 * @constructor
 */
Creates a scale indicator for the given map.
See ScaleIndicator.css for styling options.

@constructor
Creates a scale indicator for the given map . See ScaleIndicator . css for styling options . @constructor
function ScaleIndicator(map, options) {
  options = options || {};
  this._map = map;
  var domElement = document.getElementById(options.domId);
  if (!domElement) {
    domElement = document.createElement('div');
    if (options.domId) {
      domElement.id = options.domId;
    }
    map.domNode.appendChild(domElement);
  }
  domElement.classList.add("scaleIndicator");
  this._scaleIndicatorNode = domElement;
  this._distanceUnit = options.distanceUnit || DistanceUnit.METRE;
  this._textNode = document.createElement("div");
  this._textNode.classList.add("scaleIndicatorText");
  this._scaleIndicatorNode.appendChild(this._textNode);
  this._backgroundNode = document.createElement("div");
  this._backgroundNode.classList.add("scaleIndicatorBackground");
  this._scaleIndicatorNode.appendChild(this._backgroundNode);
  var numberOfForegroundTicks = options.foregroundTicks || DEFAULT_NUMBER_FOREGROUND_TICKS;
  this._foregroundNodes = [];
  for (var i = 0; i < numberOfForegroundTicks; i++) {
    var foregroundNode = document.createElement("div");
    foregroundNode.classList.add("scaleIndicatorForeground");
    var leftPercentage = i * (100 / numberOfForegroundTicks);
    foregroundNode.style.left = leftPercentage + (leftPercentage > 0 ? "%" : "");
    foregroundNode.style.width = (100 / (numberOfForegroundTicks * 2)) + "%";
    this._backgroundNode.appendChild(foregroundNode);
    this._foregroundNodes.push(foregroundNode);
  }
  this._onMapChangeHandle = this._map.on("MapChange", this._onScaleChange.bind(this));
}
function ScaleIndicator ( map , options ) { options = options || { } ; this . _map = map ; var domElement = document . getElementById ( options . domId ) ; if ( ! domElement ) { domElement = document . createElement ( 'div' ) ; if ( options . domId ) { domElement . id = options . domId ; } map . domNode . appendChild ( domElement ) ; } domElement . classList . add ( "scaleIndicator" ) ; this . _scaleIndicatorNode = domElement ; this . _distanceUnit = options . distanceUnit || DistanceUnit . METRE ; this . _textNode = document . createElement ( "div" ) ; this . _textNode . classList . add ( "scaleIndicatorText" ) ; this . _scaleIndicatorNode . appendChild ( this . _textNode ) ; this . _backgroundNode = document . createElement ( "div" ) ; this . _backgroundNode . classList . add ( "scaleIndicatorBackground" ) ; this . _scaleIndicatorNode . appendChild ( this . _backgroundNode ) ; var numberOfForegroundTicks = options . foregroundTicks || DEFAULT_NUMBER_FOREGROUND_TICKS ; this . _foregroundNodes = [ ] ; for ( var i = 0 ; i < numberOfForegroundTicks ; i ++ ) { var foregroundNode = document . createElement ( "div" ) ; foregroundNode . classList . add ( "scaleIndicatorForeground" ) ; var leftPercentage = i * ( 100 / numberOfForegroundTicks ) ; foregroundNode . style . left = leftPercentage + ( leftPercentage > 0 ? "%" : "" ) ; foregroundNode . style . width = ( 100 / ( numberOfForegroundTicks * 2 ) ) + "%" ; this . _backgroundNode . appendChild ( foregroundNode ) ; this . _foregroundNodes . push ( foregroundNode ) ; } this . _onMapChangeHandle = this . _map . on ( "MapChange" , this . _onScaleChange . bind ( this ) ) ; }
Creates a scale indicator for the given map.
Creates a scale indicator for the given map .