Add scale line control options to map options

This commit is contained in:
Tom Payne
2013-03-03 20:51:52 +01:00
parent 8c2b01948b
commit b663fd69f1
2 changed files with 13 additions and 0 deletions

View File

@@ -10,6 +10,8 @@
@exportObjectLiteralProperty ol.MapOptions.mouseWheelZoomDelta number|undefined
@exportObjectLiteralProperty ol.MapOptions.renderer ol.RendererHint|undefined
@exportObjectLiteralProperty ol.MapOptions.renderers Array.<ol.RendererHint>|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

View File

@@ -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) {