diff --git a/src/objectliterals.exports b/src/objectliterals.exports index aa6bd4376e..abaa190619 100644 --- a/src/objectliterals.exports +++ b/src/objectliterals.exports @@ -10,6 +10,8 @@ @exportObjectLiteralProperty ol.MapOptions.mouseWheelZoomDelta number|undefined @exportObjectLiteralProperty ol.MapOptions.renderer ol.RendererHint|undefined @exportObjectLiteralProperty ol.MapOptions.renderers Array.|undefined +@exportObjectLiteralProperty ol.MapOptions.scaleLineControl boolean|undefined +@exportObjectLiteralProperty ol.MapOptions.scaleLineUnits ol.control.ScaleLineUnits|undefined @exportObjectLiteralProperty ol.MapOptions.shiftDragZoom boolean|undefined @exportObjectLiteralProperty ol.MapOptions.target Element|string @exportObjectLiteralProperty ol.MapOptions.touchPan boolean|undefined diff --git a/src/ol/map.js b/src/ol/map.js index 7978e829d4..b0600bcdeb 100644 --- a/src/ol/map.js +++ b/src/ol/map.js @@ -45,6 +45,7 @@ goog.require('ol.View'); goog.require('ol.View2D'); goog.require('ol.control.Attribution'); goog.require('ol.control.Control'); +goog.require('ol.control.ScaleLine'); goog.require('ol.control.Zoom'); goog.require('ol.interaction.DblClickZoom'); goog.require('ol.interaction.DragPan'); @@ -925,6 +926,16 @@ ol.Map.createControls_ = function(mapOptions) { controls.push(new ol.control.Attribution({})); } + var scaleLineControl = goog.isDef(mapOptions.scaleLineControl) ? + mapOptions.scaleLineControl : false; + if (scaleLineControl) { + var scaleLineUnits = goog.isDef(mapOptions.scaleLineUnits) ? + mapOptions.scaleLineUnits : undefined; + controls.push(new ol.control.ScaleLine({ + units: scaleLineUnits + })); + } + var zoomControl = goog.isDef(mapOptions.zoomControl) ? mapOptions.zoomControl : true; if (zoomControl) {