Defines in a namespace that can be required

For consistency, all defines are in the ol namespace.  If they are to be moved to another namespace, they need to be requireable.
This commit is contained in:
Tim Schaub
2014-04-30 09:14:10 -06:00
parent e4e3b2229a
commit 24498fa9d0
12 changed files with 88 additions and 78 deletions
+2 -9
View File
@@ -11,14 +11,7 @@ goog.require('goog.color');
goog.require('goog.color.names'); goog.require('goog.color.names');
goog.require('goog.math'); goog.require('goog.math');
goog.require('goog.vec.Mat4'); goog.require('goog.vec.Mat4');
goog.require('ol');
/**
* @define {boolean} Enable named colors.
* Enabling named colors adds about 3KB uncompressed / 1.5KB compressed to the
* final build size.
*/
ol.color.ENABLE_NAMED_COLORS = true;
/** /**
@@ -212,7 +205,7 @@ ol.color.fromString = (
ol.color.fromStringInternal_ = function(s) { ol.color.fromStringInternal_ = function(s) {
var isHex = false; var isHex = false;
if (ol.color.ENABLE_NAMED_COLORS && goog.color.names.hasOwnProperty(s)) { if (ol.ENABLE_NAMED_COLORS && goog.color.names.hasOwnProperty(s)) {
// goog.color.names does not have a type declaration, so add a typecast // goog.color.names does not have a type declaration, so add a typecast
s = /** @type {string} */ (goog.color.names[s]); s = /** @type {string} */ (goog.color.names[s]);
isHex = true; isHex = true;
+3 -8
View File
@@ -15,18 +15,13 @@ goog.require('goog.fx.Dragger.EventType');
goog.require('goog.math'); goog.require('goog.math');
goog.require('goog.math.Rect'); goog.require('goog.math.Rect');
goog.require('goog.style'); goog.require('goog.style');
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');
goog.require('ol.easing'); goog.require('ol.easing');
/**
* @define {number} Animation duration.
*/
ol.control.ZOOMSLIDER_ANIMATION_DURATION = 200;
/** /**
* A slider type of control for zooming. * A slider type of control for zooming.
@@ -190,7 +185,7 @@ ol.control.ZoomSlider.prototype.handleContainerClick_ = function(browserEvent) {
goog.asserts.assert(goog.isDef(resolution)); goog.asserts.assert(goog.isDef(resolution));
map.beforeRender(ol.animation.zoom({ map.beforeRender(ol.animation.zoom({
resolution: resolution, resolution: resolution,
duration: ol.control.ZOOMSLIDER_ANIMATION_DURATION, duration: ol.ZOOMSLIDER_ANIMATION_DURATION,
easing: ol.easing.easeOut easing: ol.easing.easeOut
})); }));
resolution = view.constrainResolution(resolution); resolution = view.constrainResolution(resolution);
@@ -295,7 +290,7 @@ ol.control.ZoomSlider.prototype.handleSliderChange_ = function(e) {
goog.asserts.assert(goog.isDef(this.currentResolution_)); goog.asserts.assert(goog.isDef(this.currentResolution_));
map.beforeRender(ol.animation.zoom({ map.beforeRender(ol.animation.zoom({
resolution: this.currentResolution_, resolution: this.currentResolution_,
duration: ol.control.ZOOMSLIDER_ANIMATION_DURATION, duration: ol.ZOOMSLIDER_ANIMATION_DURATION,
easing: ol.easing.easeOut easing: ol.easing.easeOut
})); }));
resolution = view.constrainResolution(this.currentResolution_); resolution = view.constrainResolution(this.currentResolution_);
@@ -5,6 +5,7 @@ goog.provide('ol.interaction.DragRotateAndZoom');
goog.require('goog.asserts'); goog.require('goog.asserts');
goog.require('goog.functions'); goog.require('goog.functions');
goog.require('goog.math.Vec2'); goog.require('goog.math.Vec2');
goog.require('ol');
goog.require('ol.ViewHint'); goog.require('ol.ViewHint');
goog.require('ol.events.ConditionType'); goog.require('ol.events.ConditionType');
goog.require('ol.events.condition'); goog.require('ol.events.condition');
@@ -12,12 +13,6 @@ goog.require('ol.interaction.Interaction');
goog.require('ol.interaction.Pointer'); goog.require('ol.interaction.Pointer');
/**
* @define {number} Animation duration.
*/
ol.interaction.DRAGROTATEANDZOOM_ANIMATION_DURATION = 400;
/** /**
* Allows the user to zoom and rotate the map by clicking and dragging * Allows the user to zoom and rotate the map by clicking and dragging
@@ -125,7 +120,7 @@ ol.interaction.DragRotateAndZoom.prototype.handlePointerUp =
var direction = this.lastScaleDelta_ - 1; var direction = this.lastScaleDelta_ - 1;
ol.interaction.Interaction.rotate(map, view2D, view2DState.rotation); ol.interaction.Interaction.rotate(map, view2D, view2DState.rotation);
ol.interaction.Interaction.zoom(map, view2D, view2DState.resolution, ol.interaction.Interaction.zoom(map, view2D, view2DState.resolution,
undefined, ol.interaction.DRAGROTATEANDZOOM_ANIMATION_DURATION, undefined, ol.DRAGROTATEANDZOOM_ANIMATION_DURATION,
direction); direction);
this.lastScaleDelta_ = 0; this.lastScaleDelta_ = 0;
return false; return false;
+2 -7
View File
@@ -1,6 +1,7 @@
goog.provide('ol.interaction.DragRotate'); goog.provide('ol.interaction.DragRotate');
goog.require('goog.asserts'); goog.require('goog.asserts');
goog.require('ol');
goog.require('ol.ViewHint'); goog.require('ol.ViewHint');
goog.require('ol.events.ConditionType'); goog.require('ol.events.ConditionType');
goog.require('ol.events.condition'); goog.require('ol.events.condition');
@@ -8,12 +9,6 @@ goog.require('ol.interaction.Interaction');
goog.require('ol.interaction.Pointer'); goog.require('ol.interaction.Pointer');
/**
* @define {number} Animation duration.
*/
ol.interaction.DRAGROTATE_ANIMATION_DURATION = 250;
/** /**
* Allows the user to rotate the map by clicking and dragging on the map, * Allows the user to rotate the map by clicking and dragging on the map,
@@ -93,7 +88,7 @@ ol.interaction.DragRotate.prototype.handlePointerUp =
var view2D = view.getView2D(); var view2D = view.getView2D();
var view2DState = view2D.getView2DState(); var view2DState = view2D.getView2DState();
ol.interaction.Interaction.rotate(map, view2D, view2DState.rotation, ol.interaction.Interaction.rotate(map, view2D, view2DState.rotation,
undefined, ol.interaction.DRAGROTATE_ANIMATION_DURATION); undefined, ol.DRAGROTATE_ANIMATION_DURATION);
return false; return false;
}; };
+2 -7
View File
@@ -1,6 +1,7 @@
goog.provide('ol.interaction.DragZoom'); goog.provide('ol.interaction.DragZoom');
goog.require('goog.asserts'); goog.require('goog.asserts');
goog.require('ol');
goog.require('ol.events.condition'); goog.require('ol.events.condition');
goog.require('ol.extent'); goog.require('ol.extent');
goog.require('ol.interaction.DragBox'); goog.require('ol.interaction.DragBox');
@@ -9,12 +10,6 @@ goog.require('ol.style.Stroke');
goog.require('ol.style.Style'); goog.require('ol.style.Style');
/**
* @define {number} Animation duration.
*/
ol.interaction.DRAGZOOM_ANIMATION_DURATION = 200;
/** /**
* Allows the user to zoom the map by clicking and dragging on the map, * Allows the user to zoom the map by clicking and dragging on the map,
@@ -62,5 +57,5 @@ ol.interaction.DragZoom.prototype.onBoxEnd = function() {
var center = ol.extent.getCenter(extent); var center = ol.extent.getCenter(extent);
ol.interaction.Interaction.zoom(map, view, ol.interaction.Interaction.zoom(map, view,
view.getResolutionForExtent(extent, map.getSize()), view.getResolutionForExtent(extent, map.getSize()),
center, ol.interaction.DRAGZOOM_ANIMATION_DURATION); center, ol.DRAGZOOM_ANIMATION_DURATION);
}; };
+2 -7
View File
@@ -6,6 +6,7 @@ goog.require('goog.asserts');
goog.require('goog.events.KeyCodes'); goog.require('goog.events.KeyCodes');
goog.require('goog.events.KeyHandler.EventType'); goog.require('goog.events.KeyHandler.EventType');
goog.require('goog.functions'); goog.require('goog.functions');
goog.require('ol');
goog.require('ol.View2D'); goog.require('ol.View2D');
goog.require('ol.coordinate'); goog.require('ol.coordinate');
goog.require('ol.events.ConditionType'); goog.require('ol.events.ConditionType');
@@ -13,12 +14,6 @@ goog.require('ol.events.condition');
goog.require('ol.interaction.Interaction'); goog.require('ol.interaction.Interaction');
/**
* @define {number} Pan duration.
*/
ol.interaction.KEYBOARD_PAN_DURATION = 100;
/** /**
* Allows the user to pan the map using keyboard arrows. * Allows the user to pan the map using keyboard arrows.
@@ -93,7 +88,7 @@ ol.interaction.KeyboardPan.prototype.handleMapBrowserEvent =
var delta = [deltaX, deltaY]; var delta = [deltaX, deltaY];
ol.coordinate.rotate(delta, view2DState.rotation); ol.coordinate.rotate(delta, view2DState.rotation);
ol.interaction.Interaction.pan( ol.interaction.Interaction.pan(
map, view, delta, ol.interaction.KEYBOARD_PAN_DURATION); map, view, delta, ol.KEYBOARD_PAN_DURATION);
mapBrowserEvent.preventDefault(); mapBrowserEvent.preventDefault();
stopEvent = true; stopEvent = true;
} }
@@ -6,22 +6,11 @@ goog.require('goog.asserts');
goog.require('goog.events.MouseWheelEvent'); goog.require('goog.events.MouseWheelEvent');
goog.require('goog.events.MouseWheelHandler.EventType'); goog.require('goog.events.MouseWheelHandler.EventType');
goog.require('goog.math'); goog.require('goog.math');
goog.require('ol');
goog.require('ol.Coordinate'); goog.require('ol.Coordinate');
goog.require('ol.interaction.Interaction'); goog.require('ol.interaction.Interaction');
/**
* @define {number} Maximum delta.
*/
ol.interaction.MOUSEWHEELZOOM_MAXDELTA = 1;
/**
* @define {number} Timeout duration.
*/
ol.interaction.MOUSEWHEELZOOM_TIMEOUT_DURATION = 80;
/** /**
* Allows the user to zoom the map by scrolling the mouse wheel. * Allows the user to zoom the map by scrolling the mouse wheel.
@@ -89,7 +78,7 @@ ol.interaction.MouseWheelZoom.prototype.handleMapBrowserEvent =
this.startTime_ = goog.now(); this.startTime_ = goog.now();
} }
var duration = ol.interaction.MOUSEWHEELZOOM_TIMEOUT_DURATION; var duration = ol.MOUSEWHEELZOOM_TIMEOUT_DURATION;
var timeLeft = Math.max(duration - (goog.now() - this.startTime_), 0); var timeLeft = Math.max(duration - (goog.now() - this.startTime_), 0);
goog.global.clearTimeout(this.timeoutId_); goog.global.clearTimeout(this.timeoutId_);
@@ -108,7 +97,7 @@ ol.interaction.MouseWheelZoom.prototype.handleMapBrowserEvent =
* @param {ol.Map} map Map. * @param {ol.Map} map Map.
*/ */
ol.interaction.MouseWheelZoom.prototype.doZoom_ = function(map) { ol.interaction.MouseWheelZoom.prototype.doZoom_ = function(map) {
var maxDelta = ol.interaction.MOUSEWHEELZOOM_MAXDELTA; var maxDelta = ol.MOUSEWHEELZOOM_MAXDELTA;
var delta = goog.math.clamp(this.delta_, -maxDelta, maxDelta); var delta = goog.math.clamp(this.delta_, -maxDelta, maxDelta);
// FIXME works for View2D only // FIXME works for View2D only
+2 -7
View File
@@ -4,18 +4,13 @@ goog.provide('ol.interaction.PinchRotate');
goog.require('goog.asserts'); goog.require('goog.asserts');
goog.require('goog.style'); goog.require('goog.style');
goog.require('ol');
goog.require('ol.Coordinate'); goog.require('ol.Coordinate');
goog.require('ol.ViewHint'); goog.require('ol.ViewHint');
goog.require('ol.interaction.Interaction'); goog.require('ol.interaction.Interaction');
goog.require('ol.interaction.Pointer'); goog.require('ol.interaction.Pointer');
/**
* @define {number} Animation duration.
*/
ol.interaction.ROTATE_ANIMATION_DURATION = 250;
/** /**
* Allows the user to rotate the map by twisting with two fingers * Allows the user to rotate the map by twisting with two fingers
@@ -131,7 +126,7 @@ ol.interaction.PinchRotate.prototype.handlePointerUp =
var view2DState = view2D.getView2DState(); var view2DState = view2D.getView2DState();
ol.interaction.Interaction.rotate( ol.interaction.Interaction.rotate(
map, view2D, view2DState.rotation, this.anchor_, map, view2D, view2DState.rotation, this.anchor_,
ol.interaction.ROTATE_ANIMATION_DURATION); ol.ROTATE_ANIMATION_DURATION);
} }
return false; return false;
} else { } else {
+62
View File
@@ -33,6 +33,30 @@ ol.DEFAULT_TILE_CACHE_HIGH_WATER_MARK = 2048;
ol.DEFAULT_TILE_SIZE = 256; ol.DEFAULT_TILE_SIZE = 256;
/**
* @define {string} Default WMS version.
*/
ol.DEFAULT_WMS_VERSION = '1.3.0';
/**
* @define {number} Drag-rotate-zoom animation duration.
*/
ol.DRAGROTATEANDZOOM_ANIMATION_DURATION = 400;
/**
* @define {number} Drag-rotate animation duration.
*/
ol.DRAGROTATE_ANIMATION_DURATION = 250;
/**
* @define {number} Drag-zoom animation duration.
*/
ol.DRAGZOOM_ANIMATION_DURATION = 200;
/** /**
* @define {number} Hysterisis pixels. * @define {number} Hysterisis pixels.
*/ */
@@ -57,6 +81,14 @@ ol.ENABLE_DOM = true;
ol.ENABLE_IMAGE = true; ol.ENABLE_IMAGE = true;
/**
* @define {boolean} Enable named colors.
* Enabling named colors adds about 3KB uncompressed / 1.5KB compressed to the
* final build size.
*/
ol.ENABLE_NAMED_COLORS = true;
/** /**
* @define {boolean} Enable Proj4js. * @define {boolean} Enable Proj4js.
*/ */
@@ -104,12 +136,42 @@ ol.IS_LEGACY_IE = goog.userAgent.IE &&
!goog.userAgent.isVersionOrHigher('9.0') && goog.userAgent.VERSION !== ''; !goog.userAgent.isVersionOrHigher('9.0') && goog.userAgent.VERSION !== '';
/**
* @define {number} Keyboard pan duration.
*/
ol.KEYBOARD_PAN_DURATION = 100;
/**
* @define {number} Maximum mouse wheel delta.
*/
ol.MOUSEWHEELZOOM_MAXDELTA = 1;
/**
* @define {number} Mouse wheel timeout duration.
*/
ol.MOUSEWHEELZOOM_TIMEOUT_DURATION = 80;
/**
* @define {number} Rotate animation duration.
*/
ol.ROTATE_ANIMATION_DURATION = 250;
/** /**
* @define {number} Texture cache high water mark. * @define {number} Texture cache high water mark.
*/ */
ol.WEBGL_TEXTURE_CACHE_HIGH_WATER_MARK = 1024; ol.WEBGL_TEXTURE_CACHE_HIGH_WATER_MARK = 1024;
/**
* @define {number} Zoom slider animation duration.
*/
ol.ZOOMSLIDER_ANIMATION_DURATION = 200;
/** /**
* ol.inherits is an alias to the goog.inherits function. It is exported * ol.inherits is an alias to the goog.inherits function. It is exported
* for use in non-compiled application code. * for use in non-compiled application code.
+4 -3
View File
@@ -6,6 +6,7 @@ goog.require('goog.asserts');
goog.require('goog.object'); goog.require('goog.object');
goog.require('goog.string'); goog.require('goog.string');
goog.require('goog.uri.utils'); goog.require('goog.uri.utils');
goog.require('ol');
goog.require('ol.Image'); goog.require('ol.Image');
goog.require('ol.extent'); goog.require('ol.extent');
goog.require('ol.proj'); goog.require('ol.proj');
@@ -150,7 +151,7 @@ ol.source.ImageWMS.prototype.getGetFeatureInfoUrl =
var baseParams = { var baseParams = {
'SERVICE': 'WMS', 'SERVICE': 'WMS',
'VERSION': ol.source.wms.DEFAULT_VERSION, 'VERSION': ol.DEFAULT_WMS_VERSION,
'REQUEST': 'GetFeatureInfo', 'REQUEST': 'GetFeatureInfo',
'FORMAT': 'image/png', 'FORMAT': 'image/png',
'TRANSPARENT': true, 'TRANSPARENT': true,
@@ -208,7 +209,7 @@ ol.source.ImageWMS.prototype.getImage =
var params = { var params = {
'SERVICE': 'WMS', 'SERVICE': 'WMS',
'VERSION': ol.source.wms.DEFAULT_VERSION, 'VERSION': ol.DEFAULT_WMS_VERSION,
'REQUEST': 'GetMap', 'REQUEST': 'GetMap',
'FORMAT': 'image/png', 'FORMAT': 'image/png',
'TRANSPARENT': true 'TRANSPARENT': true
@@ -355,6 +356,6 @@ ol.source.ImageWMS.prototype.updateParams = function(params) {
*/ */
ol.source.ImageWMS.prototype.updateV13_ = function() { ol.source.ImageWMS.prototype.updateV13_ = function() {
var version = var version =
goog.object.get(this.params_, 'VERSION', ol.source.wms.DEFAULT_VERSION); goog.object.get(this.params_, 'VERSION', ol.DEFAULT_WMS_VERSION);
this.v13_ = goog.string.compareVersions(version, '1.3') >= 0; this.v13_ = goog.string.compareVersions(version, '1.3') >= 0;
}; };
+4 -3
View File
@@ -10,6 +10,7 @@ goog.require('goog.math');
goog.require('goog.object'); goog.require('goog.object');
goog.require('goog.string'); goog.require('goog.string');
goog.require('goog.uri.utils'); goog.require('goog.uri.utils');
goog.require('ol');
goog.require('ol.TileCoord'); goog.require('ol.TileCoord');
goog.require('ol.TileUrlFunction'); goog.require('ol.TileUrlFunction');
goog.require('ol.extent'); goog.require('ol.extent');
@@ -165,7 +166,7 @@ ol.source.TileWMS.prototype.getGetFeatureInfoUrl =
var baseParams = { var baseParams = {
'SERVICE': 'WMS', 'SERVICE': 'WMS',
'VERSION': ol.source.wms.DEFAULT_VERSION, 'VERSION': ol.DEFAULT_WMS_VERSION,
'REQUEST': 'GetFeatureInfo', 'REQUEST': 'GetFeatureInfo',
'FORMAT': 'image/png', 'FORMAT': 'image/png',
'TRANSPARENT': true, 'TRANSPARENT': true,
@@ -373,7 +374,7 @@ ol.source.TileWMS.prototype.tileUrlFunction_ =
var baseParams = { var baseParams = {
'SERVICE': 'WMS', 'SERVICE': 'WMS',
'VERSION': ol.source.wms.DEFAULT_VERSION, 'VERSION': ol.DEFAULT_WMS_VERSION,
'REQUEST': 'GetMap', 'REQUEST': 'GetMap',
'FORMAT': 'image/png', 'FORMAT': 'image/png',
'TRANSPARENT': true 'TRANSPARENT': true
@@ -405,6 +406,6 @@ ol.source.TileWMS.prototype.updateParams = function(params) {
*/ */
ol.source.TileWMS.prototype.updateV13_ = function() { ol.source.TileWMS.prototype.updateV13_ = function() {
var version = var version =
goog.object.get(this.params_, 'VERSION', ol.source.wms.DEFAULT_VERSION); goog.object.get(this.params_, 'VERSION', ol.DEFAULT_WMS_VERSION);
this.v13_ = goog.string.compareVersions(version, '1.3') >= 0; this.v13_ = goog.string.compareVersions(version, '1.3') >= 0;
}; };
-6
View File
@@ -2,12 +2,6 @@ goog.provide('ol.source.wms');
goog.provide('ol.source.wms.ServerType'); goog.provide('ol.source.wms.ServerType');
/**
* @define {string} WMS default version.
*/
ol.source.wms.DEFAULT_VERSION = '1.3.0';
/** /**
* @enum {string} * @enum {string}
*/ */