Remove goog.isDef from controls (-278 B)
This commit is contained in:
@@ -1291,7 +1291,7 @@ olx.control.ScaleLineOptions.prototype.units;
|
|||||||
/**
|
/**
|
||||||
* @typedef {{duration: (number|undefined),
|
* @typedef {{duration: (number|undefined),
|
||||||
* className: (string|undefined),
|
* className: (string|undefined),
|
||||||
* label: (string|Node|undefined),
|
* label: (string|Element|undefined),
|
||||||
* tipLabel: (string|undefined),
|
* tipLabel: (string|undefined),
|
||||||
* target: (Element|undefined),
|
* target: (Element|undefined),
|
||||||
* render: (function(ol.MapEvent)|undefined),
|
* render: (function(ol.MapEvent)|undefined),
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ ol.control.Control = function(options) {
|
|||||||
* @protected
|
* @protected
|
||||||
* @type {Element}
|
* @type {Element}
|
||||||
*/
|
*/
|
||||||
this.element = goog.isDef(options.element) ? options.element : null;
|
this.element = options.element ? options.element : null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -68,9 +68,9 @@ ol.control.Control = function(options) {
|
|||||||
/**
|
/**
|
||||||
* @type {function(ol.MapEvent)}
|
* @type {function(ol.MapEvent)}
|
||||||
*/
|
*/
|
||||||
this.render = goog.isDef(options.render) ? options.render : goog.nullFunction;
|
this.render = options.render ? options.render : goog.nullFunction;
|
||||||
|
|
||||||
if (goog.isDef(options.target)) {
|
if (options.target) {
|
||||||
this.setTarget(options.target);
|
this.setTarget(options.target);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
goog.provide('ol.control');
|
goog.provide('ol.control');
|
||||||
|
|
||||||
|
goog.require('ol');
|
||||||
goog.require('ol.Collection');
|
goog.require('ol.Collection');
|
||||||
goog.require('ol.control.Attribution');
|
goog.require('ol.control.Attribution');
|
||||||
goog.require('ol.control.Rotate');
|
goog.require('ol.control.Rotate');
|
||||||
@@ -20,23 +21,23 @@ goog.require('ol.control.Zoom');
|
|||||||
*/
|
*/
|
||||||
ol.control.defaults = function(opt_options) {
|
ol.control.defaults = function(opt_options) {
|
||||||
|
|
||||||
var options = goog.isDef(opt_options) ? opt_options : {};
|
var options = opt_options ? opt_options : {};
|
||||||
|
|
||||||
var controls = new ol.Collection();
|
var controls = new ol.Collection();
|
||||||
|
|
||||||
var zoomControl = goog.isDef(options.zoom) ?
|
var zoomControl = ol.isDef(options.zoom) ?
|
||||||
options.zoom : true;
|
options.zoom : true;
|
||||||
if (zoomControl) {
|
if (zoomControl) {
|
||||||
controls.push(new ol.control.Zoom(options.zoomOptions));
|
controls.push(new ol.control.Zoom(options.zoomOptions));
|
||||||
}
|
}
|
||||||
|
|
||||||
var rotateControl = goog.isDef(options.rotate) ?
|
var rotateControl = ol.isDef(options.rotate) ?
|
||||||
options.rotate : true;
|
options.rotate : true;
|
||||||
if (rotateControl) {
|
if (rotateControl) {
|
||||||
controls.push(new ol.control.Rotate(options.rotateOptions));
|
controls.push(new ol.control.Rotate(options.rotateOptions));
|
||||||
}
|
}
|
||||||
|
|
||||||
var attributionControl = goog.isDef(options.attribution) ?
|
var attributionControl = ol.isDef(options.attribution) ?
|
||||||
options.attribution : true;
|
options.attribution : true;
|
||||||
if (attributionControl) {
|
if (attributionControl) {
|
||||||
controls.push(new ol.control.Attribution(options.attributionOptions));
|
controls.push(new ol.control.Attribution(options.attributionOptions));
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ goog.require('goog.dom.fullscreen');
|
|||||||
goog.require('goog.dom.fullscreen.EventType');
|
goog.require('goog.dom.fullscreen.EventType');
|
||||||
goog.require('goog.events');
|
goog.require('goog.events');
|
||||||
goog.require('goog.events.EventType');
|
goog.require('goog.events.EventType');
|
||||||
|
goog.require('ol');
|
||||||
goog.require('ol.control.Control');
|
goog.require('ol.control.Control');
|
||||||
goog.require('ol.css');
|
goog.require('ol.css');
|
||||||
|
|
||||||
@@ -28,16 +29,15 @@ goog.require('ol.css');
|
|||||||
*/
|
*/
|
||||||
ol.control.FullScreen = function(opt_options) {
|
ol.control.FullScreen = function(opt_options) {
|
||||||
|
|
||||||
var options = goog.isDef(opt_options) ? opt_options : {};
|
var options = opt_options ? opt_options : {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
this.cssClassName_ = goog.isDef(options.className) ?
|
this.cssClassName_ = options.className ? options.className : 'ol-full-screen';
|
||||||
options.className : 'ol-full-screen';
|
|
||||||
|
|
||||||
var label = goog.isDef(options.label) ? options.label : '\u2194';
|
var label = options.label ? options.label : '\u2194';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -46,8 +46,7 @@ ol.control.FullScreen = function(opt_options) {
|
|||||||
this.labelNode_ = /** @type {Node} */ (goog.isString(label) ?
|
this.labelNode_ = /** @type {Node} */ (goog.isString(label) ?
|
||||||
goog.dom.createTextNode(label) : label);
|
goog.dom.createTextNode(label) : label);
|
||||||
|
|
||||||
var labelActive = goog.isDef(options.labelActive) ?
|
var labelActive = options.labelActive ? options.labelActive : '\u00d7';
|
||||||
options.labelActive : '\u00d7';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -56,8 +55,7 @@ ol.control.FullScreen = function(opt_options) {
|
|||||||
this.labelActiveNode_ = /** @type {Node} */ (goog.isString(labelActive) ?
|
this.labelActiveNode_ = /** @type {Node} */ (goog.isString(labelActive) ?
|
||||||
goog.dom.createTextNode(labelActive) : labelActive);
|
goog.dom.createTextNode(labelActive) : labelActive);
|
||||||
|
|
||||||
var tipLabel = goog.isDef(options.tipLabel) ?
|
var tipLabel = options.tipLabel ? options.tipLabel : 'Toggle full-screen';
|
||||||
options.tipLabel : 'Toggle full-screen';
|
|
||||||
var button = goog.dom.createDom(goog.dom.TagName.BUTTON, {
|
var button = goog.dom.createDom(goog.dom.TagName.BUTTON, {
|
||||||
'class': this.cssClassName_ + '-' + goog.dom.fullscreen.isFullScreen(),
|
'class': this.cssClassName_ + '-' + goog.dom.fullscreen.isFullScreen(),
|
||||||
'type': 'button',
|
'type': 'button',
|
||||||
@@ -85,7 +83,8 @@ ol.control.FullScreen = function(opt_options) {
|
|||||||
* @private
|
* @private
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
this.keys_ = goog.isDef(options.keys) ? options.keys : false;
|
this.keys_ = ol.isDef(options.keys) ?
|
||||||
|
/** @type {boolean} */ (options.keys) : false;
|
||||||
|
|
||||||
};
|
};
|
||||||
goog.inherits(ol.control.FullScreen, ol.control.Control);
|
goog.inherits(ol.control.FullScreen, ol.control.Control);
|
||||||
|
|||||||
@@ -40,14 +40,13 @@ ol.control.MousePositionProperty = {
|
|||||||
*/
|
*/
|
||||||
ol.control.MousePosition = function(opt_options) {
|
ol.control.MousePosition = function(opt_options) {
|
||||||
|
|
||||||
var options = goog.isDef(opt_options) ? opt_options : {};
|
var options = opt_options ? opt_options : {};
|
||||||
|
|
||||||
var className = goog.isDef(options.className) ?
|
var className = options.className ? options.className : 'ol-mouse-position';
|
||||||
options.className : 'ol-mouse-position';
|
|
||||||
|
|
||||||
var element = goog.dom.createDom(goog.dom.TagName.DIV, className);
|
var element = goog.dom.createDom(goog.dom.TagName.DIV, className);
|
||||||
|
|
||||||
var render = goog.isDef(options.render) ?
|
var render = options.render ?
|
||||||
options.render : ol.control.MousePosition.render;
|
options.render : ol.control.MousePosition.render;
|
||||||
|
|
||||||
goog.base(this, {
|
goog.base(this, {
|
||||||
@@ -60,10 +59,10 @@ ol.control.MousePosition = function(opt_options) {
|
|||||||
ol.Object.getChangeEventType(ol.control.MousePositionProperty.PROJECTION),
|
ol.Object.getChangeEventType(ol.control.MousePositionProperty.PROJECTION),
|
||||||
this.handleProjectionChanged_, false, this);
|
this.handleProjectionChanged_, false, this);
|
||||||
|
|
||||||
if (goog.isDef(options.coordinateFormat)) {
|
if (options.coordinateFormat) {
|
||||||
this.setCoordinateFormat(options.coordinateFormat);
|
this.setCoordinateFormat(options.coordinateFormat);
|
||||||
}
|
}
|
||||||
if (goog.isDef(options.projection)) {
|
if (options.projection) {
|
||||||
this.setProjection(ol.proj.get(options.projection));
|
this.setProjection(ol.proj.get(options.projection));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,8 +70,7 @@ ol.control.MousePosition = function(opt_options) {
|
|||||||
* @private
|
* @private
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
this.undefinedHTML_ = goog.isDef(options.undefinedHTML) ?
|
this.undefinedHTML_ = options.undefinedHTML ? options.undefinedHTML : '';
|
||||||
options.undefinedHTML : '';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -229,7 +227,7 @@ ol.control.MousePosition.prototype.updateHTML_ = function(pixel) {
|
|||||||
if (!goog.isNull(pixel) && !goog.isNull(this.mapProjection_)) {
|
if (!goog.isNull(pixel) && !goog.isNull(this.mapProjection_)) {
|
||||||
if (goog.isNull(this.transform_)) {
|
if (goog.isNull(this.transform_)) {
|
||||||
var projection = this.getProjection();
|
var projection = this.getProjection();
|
||||||
if (goog.isDef(projection)) {
|
if (projection) {
|
||||||
this.transform_ = ol.proj.getTransformFromProjections(
|
this.transform_ = ol.proj.getTransformFromProjections(
|
||||||
this.mapProjection_, projection);
|
this.mapProjection_, projection);
|
||||||
} else {
|
} else {
|
||||||
@@ -241,14 +239,14 @@ ol.control.MousePosition.prototype.updateHTML_ = function(pixel) {
|
|||||||
if (!goog.isNull(coordinate)) {
|
if (!goog.isNull(coordinate)) {
|
||||||
this.transform_(coordinate, coordinate);
|
this.transform_(coordinate, coordinate);
|
||||||
var coordinateFormat = this.getCoordinateFormat();
|
var coordinateFormat = this.getCoordinateFormat();
|
||||||
if (goog.isDef(coordinateFormat)) {
|
if (coordinateFormat) {
|
||||||
html = coordinateFormat(coordinate);
|
html = coordinateFormat(coordinate);
|
||||||
} else {
|
} else {
|
||||||
html = coordinate.toString();
|
html = coordinate.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!goog.isDef(this.renderedHTML_) || html != this.renderedHTML_) {
|
if (!this.renderedHTML_ || html != this.renderedHTML_) {
|
||||||
this.element.innerHTML = html;
|
this.element.innerHTML = html;
|
||||||
this.renderedHTML_ = html;
|
this.renderedHTML_ = html;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ goog.require('goog.events');
|
|||||||
goog.require('goog.events.EventType');
|
goog.require('goog.events.EventType');
|
||||||
goog.require('goog.math.Size');
|
goog.require('goog.math.Size');
|
||||||
goog.require('goog.style');
|
goog.require('goog.style');
|
||||||
|
goog.require('ol');
|
||||||
goog.require('ol.Collection');
|
goog.require('ol.Collection');
|
||||||
goog.require('ol.Map');
|
goog.require('ol.Map');
|
||||||
goog.require('ol.MapEventType');
|
goog.require('ol.MapEventType');
|
||||||
@@ -34,33 +35,31 @@ goog.require('ol.extent');
|
|||||||
*/
|
*/
|
||||||
ol.control.OverviewMap = function(opt_options) {
|
ol.control.OverviewMap = function(opt_options) {
|
||||||
|
|
||||||
var options = goog.isDef(opt_options) ? opt_options : {};
|
var options = opt_options ? opt_options : {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.collapsed_ = goog.isDef(options.collapsed) ? options.collapsed : true;
|
this.collapsed_ = ol.isDef(options.collapsed) ?
|
||||||
|
/** @type {boolean} */ (options.collapsed) : true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
this.collapsible_ = goog.isDef(options.collapsible) ?
|
this.collapsible_ = ol.isDef(options.collapsible) ?
|
||||||
options.collapsible : true;
|
/** @type {boolean} */ (options.collapsible) : true;
|
||||||
|
|
||||||
if (!this.collapsible_) {
|
if (!this.collapsible_) {
|
||||||
this.collapsed_ = false;
|
this.collapsed_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var className = goog.isDef(options.className) ?
|
var className = options.className ? options.className : 'ol-overviewmap';
|
||||||
options.className : 'ol-overviewmap';
|
|
||||||
|
|
||||||
var tipLabel = goog.isDef(options.tipLabel) ?
|
var tipLabel = options.tipLabel ? options.tipLabel : 'Overview map';
|
||||||
options.tipLabel : 'Overview map';
|
|
||||||
|
|
||||||
var collapseLabel = goog.isDef(options.collapseLabel) ?
|
var collapseLabel = options.collapseLabel ? options.collapseLabel : '\u00AB';
|
||||||
options.collapseLabel : '\u00AB';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -70,7 +69,7 @@ ol.control.OverviewMap = function(opt_options) {
|
|||||||
goog.dom.createDom(goog.dom.TagName.SPAN, {}, collapseLabel) :
|
goog.dom.createDom(goog.dom.TagName.SPAN, {}, collapseLabel) :
|
||||||
collapseLabel);
|
collapseLabel);
|
||||||
|
|
||||||
var label = goog.isDef(options.label) ? options.label : '\u00BB';
|
var label = options.label ? options.label : '\u00BB';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -103,7 +102,7 @@ ol.control.OverviewMap = function(opt_options) {
|
|||||||
});
|
});
|
||||||
var ovmap = this.ovmap_;
|
var ovmap = this.ovmap_;
|
||||||
|
|
||||||
if (goog.isDef(options.layers)) {
|
if (options.layers) {
|
||||||
options.layers.forEach(
|
options.layers.forEach(
|
||||||
/**
|
/**
|
||||||
* @param {ol.layer.Layer} layer Layer.
|
* @param {ol.layer.Layer} layer Layer.
|
||||||
@@ -133,8 +132,7 @@ ol.control.OverviewMap = function(opt_options) {
|
|||||||
var element = goog.dom.createDom(goog.dom.TagName.DIV,
|
var element = goog.dom.createDom(goog.dom.TagName.DIV,
|
||||||
cssClasses, ovmapDiv, button);
|
cssClasses, ovmapDiv, button);
|
||||||
|
|
||||||
var render = goog.isDef(options.render) ?
|
var render = options.render ? options.render : ol.control.OverviewMap.render;
|
||||||
options.render : ol.control.OverviewMap.render;
|
|
||||||
|
|
||||||
goog.base(this, {
|
goog.base(this, {
|
||||||
element: element,
|
element: element,
|
||||||
@@ -271,14 +269,14 @@ ol.control.OverviewMap.prototype.validateExtent_ = function() {
|
|||||||
goog.asserts.assertArray(mapSize, 'mapSize should be an array');
|
goog.asserts.assertArray(mapSize, 'mapSize should be an array');
|
||||||
|
|
||||||
var view = map.getView();
|
var view = map.getView();
|
||||||
goog.asserts.assert(goog.isDef(view), 'view should be defined');
|
goog.asserts.assert(view, 'view should be defined');
|
||||||
var extent = view.calculateExtent(mapSize);
|
var extent = view.calculateExtent(mapSize);
|
||||||
|
|
||||||
var ovmapSize = ovmap.getSize();
|
var ovmapSize = ovmap.getSize();
|
||||||
goog.asserts.assertArray(ovmapSize, 'ovmapSize should be an array');
|
goog.asserts.assertArray(ovmapSize, 'ovmapSize should be an array');
|
||||||
|
|
||||||
var ovview = ovmap.getView();
|
var ovview = ovmap.getView();
|
||||||
goog.asserts.assert(goog.isDef(ovview), 'ovview should be defined');
|
goog.asserts.assert(ovview, 'ovview should be defined');
|
||||||
var ovextent = ovview.calculateExtent(ovmapSize);
|
var ovextent = ovview.calculateExtent(ovmapSize);
|
||||||
|
|
||||||
var topLeftPixel =
|
var topLeftPixel =
|
||||||
@@ -320,14 +318,14 @@ ol.control.OverviewMap.prototype.resetExtent_ = function() {
|
|||||||
goog.asserts.assertArray(mapSize, 'mapSize should be an array');
|
goog.asserts.assertArray(mapSize, 'mapSize should be an array');
|
||||||
|
|
||||||
var view = map.getView();
|
var view = map.getView();
|
||||||
goog.asserts.assert(goog.isDef(view), 'view should be defined');
|
goog.asserts.assert(view, 'view should be defined');
|
||||||
var extent = view.calculateExtent(mapSize);
|
var extent = view.calculateExtent(mapSize);
|
||||||
|
|
||||||
var ovmapSize = ovmap.getSize();
|
var ovmapSize = ovmap.getSize();
|
||||||
goog.asserts.assertArray(ovmapSize, 'ovmapSize should be an array');
|
goog.asserts.assertArray(ovmapSize, 'ovmapSize should be an array');
|
||||||
|
|
||||||
var ovview = ovmap.getView();
|
var ovview = ovmap.getView();
|
||||||
goog.asserts.assert(goog.isDef(ovview), 'ovview should be defined');
|
goog.asserts.assert(ovview, 'ovview should be defined');
|
||||||
|
|
||||||
// get how many times the current map overview could hold different
|
// get how many times the current map overview could hold different
|
||||||
// box sizes using the min and max ratio, pick the step in the middle used
|
// box sizes using the min and max ratio, pick the step in the middle used
|
||||||
@@ -350,10 +348,10 @@ ol.control.OverviewMap.prototype.recenter_ = function() {
|
|||||||
var ovmap = this.ovmap_;
|
var ovmap = this.ovmap_;
|
||||||
|
|
||||||
var view = map.getView();
|
var view = map.getView();
|
||||||
goog.asserts.assert(goog.isDef(view), 'view should be defined');
|
goog.asserts.assert(view, 'view should be defined');
|
||||||
|
|
||||||
var ovview = ovmap.getView();
|
var ovview = ovmap.getView();
|
||||||
goog.asserts.assert(goog.isDef(ovview), 'ovview should be defined');
|
goog.asserts.assert(ovview, 'ovview should be defined');
|
||||||
|
|
||||||
ovview.setCenter(view.getCenter());
|
ovview.setCenter(view.getCenter());
|
||||||
};
|
};
|
||||||
@@ -375,16 +373,16 @@ ol.control.OverviewMap.prototype.updateBox_ = function() {
|
|||||||
goog.asserts.assertArray(mapSize, 'mapSize should be an array');
|
goog.asserts.assertArray(mapSize, 'mapSize should be an array');
|
||||||
|
|
||||||
var view = map.getView();
|
var view = map.getView();
|
||||||
goog.asserts.assert(goog.isDef(view), 'view should be defined');
|
goog.asserts.assert(view, 'view should be defined');
|
||||||
|
|
||||||
var ovview = ovmap.getView();
|
var ovview = ovmap.getView();
|
||||||
goog.asserts.assert(goog.isDef(ovview), 'ovview should be defined');
|
goog.asserts.assert(ovview, 'ovview should be defined');
|
||||||
|
|
||||||
var ovmapSize = ovmap.getSize();
|
var ovmapSize = ovmap.getSize();
|
||||||
goog.asserts.assertArray(ovmapSize, 'ovmapSize should be an array');
|
goog.asserts.assertArray(ovmapSize, 'ovmapSize should be an array');
|
||||||
|
|
||||||
var rotation = view.getRotation();
|
var rotation = view.getRotation();
|
||||||
goog.asserts.assert(goog.isDef(rotation), 'rotation should be defined');
|
goog.asserts.assert(ol.isDef(rotation), 'rotation should be defined');
|
||||||
|
|
||||||
var overlay = this.boxOverlay_;
|
var overlay = this.boxOverlay_;
|
||||||
var box = this.boxOverlay_.getElement();
|
var box = this.boxOverlay_.getElement();
|
||||||
@@ -419,11 +417,11 @@ ol.control.OverviewMap.prototype.calculateCoordinateRotate_ = function(
|
|||||||
|
|
||||||
var map = this.getMap();
|
var map = this.getMap();
|
||||||
var view = map.getView();
|
var view = map.getView();
|
||||||
goog.asserts.assert(goog.isDef(view), 'view should be defined');
|
goog.asserts.assert(view, 'view should be defined');
|
||||||
|
|
||||||
var currentCenter = view.getCenter();
|
var currentCenter = view.getCenter();
|
||||||
|
|
||||||
if (goog.isDef(currentCenter)) {
|
if (currentCenter) {
|
||||||
coordinateRotate = [
|
coordinateRotate = [
|
||||||
coordinate[0] - currentCenter[0],
|
coordinate[0] - currentCenter[0],
|
||||||
coordinate[1] - currentCenter[1]
|
coordinate[1] - currentCenter[1]
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ goog.require('goog.dom.classlist');
|
|||||||
goog.require('goog.events');
|
goog.require('goog.events');
|
||||||
goog.require('goog.events.EventType');
|
goog.require('goog.events.EventType');
|
||||||
goog.require('goog.math');
|
goog.require('goog.math');
|
||||||
|
goog.require('ol');
|
||||||
goog.require('ol.animation');
|
goog.require('ol.animation');
|
||||||
goog.require('ol.control.Control');
|
goog.require('ol.control.Control');
|
||||||
goog.require('ol.css');
|
goog.require('ol.css');
|
||||||
@@ -26,16 +27,15 @@ goog.require('ol.easing');
|
|||||||
*/
|
*/
|
||||||
ol.control.Rotate = function(opt_options) {
|
ol.control.Rotate = function(opt_options) {
|
||||||
|
|
||||||
var options = goog.isDef(opt_options) ? opt_options : {};
|
var options = opt_options ? opt_options : {};
|
||||||
|
|
||||||
var className = goog.isDef(options.className) ?
|
var className = options.className ?
|
||||||
options.className : 'ol-rotate';
|
options.className : 'ol-rotate';
|
||||||
|
|
||||||
var label = goog.isDef(options.label) ?
|
var label = options.label ? options.label : '\u21E7';
|
||||||
options.label : '\u21E7';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {Node}
|
* @type {Element}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.label_ = null;
|
this.label_ = null;
|
||||||
@@ -48,8 +48,7 @@ ol.control.Rotate = function(opt_options) {
|
|||||||
goog.dom.classlist.add(this.label_, 'ol-compass');
|
goog.dom.classlist.add(this.label_, 'ol-compass');
|
||||||
}
|
}
|
||||||
|
|
||||||
var tipLabel = goog.isDef(options.tipLabel) ?
|
var tipLabel = options.tipLabel ? options.tipLabel : 'Reset rotation';
|
||||||
options.tipLabel : 'Reset rotation';
|
|
||||||
|
|
||||||
var button = goog.dom.createDom(goog.dom.TagName.BUTTON, {
|
var button = goog.dom.createDom(goog.dom.TagName.BUTTON, {
|
||||||
'class': className + '-reset',
|
'class': className + '-reset',
|
||||||
@@ -64,8 +63,7 @@ ol.control.Rotate = function(opt_options) {
|
|||||||
ol.css.CLASS_CONTROL;
|
ol.css.CLASS_CONTROL;
|
||||||
var element = goog.dom.createDom(goog.dom.TagName.DIV, cssClasses, button);
|
var element = goog.dom.createDom(goog.dom.TagName.DIV, cssClasses, button);
|
||||||
|
|
||||||
var render = goog.isDef(options.render) ?
|
var render = options.render ? options.render : ol.control.Rotate.render;
|
||||||
options.render : ol.control.Rotate.render;
|
|
||||||
|
|
||||||
goog.base(this, {
|
goog.base(this, {
|
||||||
element: element,
|
element: element,
|
||||||
@@ -77,13 +75,14 @@ ol.control.Rotate = function(opt_options) {
|
|||||||
* @type {number}
|
* @type {number}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.duration_ = goog.isDef(options.duration) ? options.duration : 250;
|
this.duration_ = options.duration ? options.duration : 250;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.autoHide_ = goog.isDef(options.autoHide) ? options.autoHide : true;
|
this.autoHide_ = ol.isDef(options.autoHide) ?
|
||||||
|
/** @type {boolean} */ (options.autoHide) : true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -127,7 +126,7 @@ ol.control.Rotate.prototype.resetNorth_ = function() {
|
|||||||
while (currentRotation > Math.PI) {
|
while (currentRotation > Math.PI) {
|
||||||
currentRotation -= 2 * Math.PI;
|
currentRotation -= 2 * Math.PI;
|
||||||
}
|
}
|
||||||
if (goog.isDef(currentRotation)) {
|
if (ol.isDef(currentRotation)) {
|
||||||
if (this.duration_ > 0) {
|
if (this.duration_ > 0) {
|
||||||
map.beforeRender(ol.animation.rotate({
|
map.beforeRender(ol.animation.rotate({
|
||||||
rotation: currentRotation,
|
rotation: currentRotation,
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ goog.require('goog.dom.TagName');
|
|||||||
goog.require('goog.events');
|
goog.require('goog.events');
|
||||||
goog.require('goog.math');
|
goog.require('goog.math');
|
||||||
goog.require('goog.style');
|
goog.require('goog.style');
|
||||||
|
goog.require('ol');
|
||||||
goog.require('ol.Object');
|
goog.require('ol.Object');
|
||||||
goog.require('ol.TransformFunction');
|
goog.require('ol.TransformFunction');
|
||||||
goog.require('ol.control.Control');
|
goog.require('ol.control.Control');
|
||||||
@@ -58,10 +59,9 @@ ol.control.ScaleLineUnits = {
|
|||||||
*/
|
*/
|
||||||
ol.control.ScaleLine = function(opt_options) {
|
ol.control.ScaleLine = function(opt_options) {
|
||||||
|
|
||||||
var options = goog.isDef(opt_options) ? opt_options : {};
|
var options = opt_options ? opt_options : {};
|
||||||
|
|
||||||
var className = goog.isDef(options.className) ?
|
var className = options.className ? options.className : 'ol-scale-line';
|
||||||
options.className : 'ol-scale-line';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -87,7 +87,8 @@ ol.control.ScaleLine = function(opt_options) {
|
|||||||
* @private
|
* @private
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
this.minWidth_ = goog.isDef(options.minWidth) ? options.minWidth : 64;
|
this.minWidth_ = ol.isDef(options.minWidth) ?
|
||||||
|
/** @type {number} */ (options.minWidth) : 64;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -113,8 +114,7 @@ ol.control.ScaleLine = function(opt_options) {
|
|||||||
*/
|
*/
|
||||||
this.toEPSG4326_ = null;
|
this.toEPSG4326_ = null;
|
||||||
|
|
||||||
var render = goog.isDef(options.render) ?
|
var render = options.render ? options.render : ol.control.ScaleLine.render;
|
||||||
options.render : ol.control.ScaleLine.render;
|
|
||||||
|
|
||||||
goog.base(this, {
|
goog.base(this, {
|
||||||
element: this.element_,
|
element: this.element_,
|
||||||
@@ -233,7 +233,7 @@ ol.control.ScaleLine.prototype.updateElement_ = function() {
|
|||||||
}
|
}
|
||||||
cosLatitude = Math.cos(goog.math.toRadians(this.toEPSG4326_(center)[1]));
|
cosLatitude = Math.cos(goog.math.toRadians(this.toEPSG4326_(center)[1]));
|
||||||
var radius = ol.sphere.NORMAL.radius;
|
var radius = ol.sphere.NORMAL.radius;
|
||||||
goog.asserts.assert(goog.isDef(ol.proj.METERS_PER_UNIT[projectionUnits]),
|
goog.asserts.assert(ol.proj.METERS_PER_UNIT[projectionUnits],
|
||||||
'Meters per unit should be defined for the projection unit');
|
'Meters per unit should be defined for the projection unit');
|
||||||
radius /= ol.proj.METERS_PER_UNIT[projectionUnits];
|
radius /= ol.proj.METERS_PER_UNIT[projectionUnits];
|
||||||
pointResolution *= 180 / (Math.PI * cosLatitude * radius);
|
pointResolution *= 180 / (Math.PI * cosLatitude * radius);
|
||||||
|
|||||||
@@ -24,20 +24,18 @@ goog.require('ol.easing');
|
|||||||
*/
|
*/
|
||||||
ol.control.Zoom = function(opt_options) {
|
ol.control.Zoom = function(opt_options) {
|
||||||
|
|
||||||
var options = goog.isDef(opt_options) ? opt_options : {};
|
var options = opt_options ? opt_options : {};
|
||||||
|
|
||||||
var className = goog.isDef(options.className) ? options.className : 'ol-zoom';
|
var className = options.className ? options.className : 'ol-zoom';
|
||||||
|
|
||||||
var delta = goog.isDef(options.delta) ? options.delta : 1;
|
var delta = options.delta ? options.delta : 1;
|
||||||
|
|
||||||
var zoomInLabel = goog.isDef(options.zoomInLabel) ?
|
var zoomInLabel = options.zoomInLabel ? options.zoomInLabel : '+';
|
||||||
options.zoomInLabel : '+';
|
var zoomOutLabel = options.zoomOutLabel ? options.zoomOutLabel : '\u2212';
|
||||||
var zoomOutLabel = goog.isDef(options.zoomOutLabel) ?
|
|
||||||
options.zoomOutLabel : '\u2212';
|
|
||||||
|
|
||||||
var zoomInTipLabel = goog.isDef(options.zoomInTipLabel) ?
|
var zoomInTipLabel = options.zoomInTipLabel ?
|
||||||
options.zoomInTipLabel : 'Zoom in';
|
options.zoomInTipLabel : 'Zoom in';
|
||||||
var zoomOutTipLabel = goog.isDef(options.zoomOutTipLabel) ?
|
var zoomOutTipLabel = options.zoomOutTipLabel ?
|
||||||
options.zoomOutTipLabel : 'Zoom out';
|
options.zoomOutTipLabel : 'Zoom out';
|
||||||
|
|
||||||
var inElement = goog.dom.createDom(goog.dom.TagName.BUTTON, {
|
var inElement = goog.dom.createDom(goog.dom.TagName.BUTTON, {
|
||||||
@@ -81,7 +79,7 @@ ol.control.Zoom = function(opt_options) {
|
|||||||
* @type {number}
|
* @type {number}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.duration_ = goog.isDef(options.duration) ? options.duration : 250;
|
this.duration_ = options.duration ? options.duration : 250;
|
||||||
|
|
||||||
};
|
};
|
||||||
goog.inherits(ol.control.Zoom, ol.control.Control);
|
goog.inherits(ol.control.Zoom, ol.control.Control);
|
||||||
@@ -111,7 +109,7 @@ ol.control.Zoom.prototype.zoomByDelta_ = function(delta) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var currentResolution = view.getResolution();
|
var currentResolution = view.getResolution();
|
||||||
if (goog.isDef(currentResolution)) {
|
if (currentResolution) {
|
||||||
if (this.duration_ > 0) {
|
if (this.duration_ > 0) {
|
||||||
map.beforeRender(ol.animation.zoom({
|
map.beforeRender(ol.animation.zoom({
|
||||||
resolution: currentResolution,
|
resolution: currentResolution,
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ goog.require('ol.easing');
|
|||||||
*/
|
*/
|
||||||
ol.control.ZoomSlider = function(opt_options) {
|
ol.control.ZoomSlider = function(opt_options) {
|
||||||
|
|
||||||
var options = goog.isDef(opt_options) ? opt_options : {};
|
var options = opt_options ? opt_options : {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Will hold the current resolution of the view.
|
* Will hold the current resolution of the view.
|
||||||
@@ -76,10 +76,9 @@ ol.control.ZoomSlider = function(opt_options) {
|
|||||||
* @private
|
* @private
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
this.duration_ = goog.isDef(options.duration) ? options.duration : 200;
|
this.duration_ = options.duration ? options.duration : 200;
|
||||||
|
|
||||||
var className = goog.isDef(options.className) ?
|
var className = options.className ? options.className : 'ol-zoomslider';
|
||||||
options.className : 'ol-zoomslider';
|
|
||||||
var thumbElement = goog.dom.createDom(goog.dom.TagName.DIV,
|
var thumbElement = goog.dom.createDom(goog.dom.TagName.DIV,
|
||||||
[className + '-thumb', ol.css.CLASS_UNSELECTABLE]);
|
[className + '-thumb', ol.css.CLASS_UNSELECTABLE]);
|
||||||
var containerElement = goog.dom.createDom(goog.dom.TagName.DIV,
|
var containerElement = goog.dom.createDom(goog.dom.TagName.DIV,
|
||||||
@@ -105,8 +104,7 @@ ol.control.ZoomSlider = function(opt_options) {
|
|||||||
goog.events.listen(thumbElement, goog.events.EventType.CLICK,
|
goog.events.listen(thumbElement, goog.events.EventType.CLICK,
|
||||||
goog.events.Event.stopPropagation);
|
goog.events.Event.stopPropagation);
|
||||||
|
|
||||||
var render = goog.isDef(options.render) ?
|
var render = options.render ? options.render : ol.control.ZoomSlider.render;
|
||||||
options.render : ol.control.ZoomSlider.render;
|
|
||||||
|
|
||||||
goog.base(this, {
|
goog.base(this, {
|
||||||
element: containerElement,
|
element: containerElement,
|
||||||
@@ -205,7 +203,7 @@ ol.control.ZoomSlider.prototype.handleContainerClick_ = function(browserEvent) {
|
|||||||
var map = this.getMap();
|
var map = this.getMap();
|
||||||
var view = map.getView();
|
var view = map.getView();
|
||||||
var currentResolution = view.getResolution();
|
var currentResolution = view.getResolution();
|
||||||
goog.asserts.assert(goog.isDef(currentResolution),
|
goog.asserts.assert(currentResolution,
|
||||||
'currentResolution should be defined');
|
'currentResolution should be defined');
|
||||||
map.beforeRender(ol.animation.zoom({
|
map.beforeRender(ol.animation.zoom({
|
||||||
resolution: currentResolution,
|
resolution: currentResolution,
|
||||||
@@ -252,7 +250,7 @@ ol.control.ZoomSlider.prototype.handleDraggerEnd_ = function(event) {
|
|||||||
var map = this.getMap();
|
var map = this.getMap();
|
||||||
var view = map.getView();
|
var view = map.getView();
|
||||||
view.setHint(ol.ViewHint.INTERACTING, -1);
|
view.setHint(ol.ViewHint.INTERACTING, -1);
|
||||||
goog.asserts.assert(goog.isDef(this.currentResolution_),
|
goog.asserts.assert(this.currentResolution_,
|
||||||
'this.currentResolution_ should be defined');
|
'this.currentResolution_ should be defined');
|
||||||
map.beforeRender(ol.animation.zoom({
|
map.beforeRender(ol.animation.zoom({
|
||||||
resolution: this.currentResolution_,
|
resolution: this.currentResolution_,
|
||||||
|
|||||||
@@ -21,19 +21,19 @@ goog.require('ol.css');
|
|||||||
* @api stable
|
* @api stable
|
||||||
*/
|
*/
|
||||||
ol.control.ZoomToExtent = function(opt_options) {
|
ol.control.ZoomToExtent = function(opt_options) {
|
||||||
var options = goog.isDef(opt_options) ? opt_options : {};
|
var options = opt_options ? opt_options : {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {ol.Extent}
|
* @type {ol.Extent}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.extent_ = goog.isDef(options.extent) ? options.extent : null;
|
this.extent_ = options.extent ? options.extent : null;
|
||||||
|
|
||||||
var className = goog.isDef(options.className) ? options.className :
|
var className = options.className ? options.className :
|
||||||
'ol-zoom-extent';
|
'ol-zoom-extent';
|
||||||
|
|
||||||
var label = goog.isDef(options.label) ? options.label : 'E';
|
var label = options.label ? options.label : 'E';
|
||||||
var tipLabel = goog.isDef(options.tipLabel) ?
|
var tipLabel = options.tipLabel ?
|
||||||
options.tipLabel : 'Fit to extent';
|
options.tipLabel : 'Fit to extent';
|
||||||
var button = goog.dom.createDom(goog.dom.TagName.BUTTON, {
|
var button = goog.dom.createDom(goog.dom.TagName.BUTTON, {
|
||||||
'type': 'button',
|
'type': 'button',
|
||||||
@@ -74,6 +74,6 @@ ol.control.ZoomToExtent.prototype.handleZoomToExtent_ = function() {
|
|||||||
var extent = goog.isNull(this.extent_) ?
|
var extent = goog.isNull(this.extent_) ?
|
||||||
view.getProjection().getExtent() : this.extent_;
|
view.getProjection().getExtent() : this.extent_;
|
||||||
var size = map.getSize();
|
var size = map.getSize();
|
||||||
goog.asserts.assert(goog.isDef(size), 'size should be defined');
|
goog.asserts.assert(size, 'size should be defined');
|
||||||
view.fit(extent, size);
|
view.fit(extent, size);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user