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:
@@ -11,14 +11,7 @@ goog.require('goog.color');
|
||||
goog.require('goog.color.names');
|
||||
goog.require('goog.math');
|
||||
goog.require('goog.vec.Mat4');
|
||||
|
||||
|
||||
/**
|
||||
* @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;
|
||||
goog.require('ol');
|
||||
|
||||
|
||||
/**
|
||||
@@ -212,7 +205,7 @@ ol.color.fromString = (
|
||||
ol.color.fromStringInternal_ = function(s) {
|
||||
|
||||
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
|
||||
s = /** @type {string} */ (goog.color.names[s]);
|
||||
isHex = true;
|
||||
|
||||
@@ -15,18 +15,13 @@ goog.require('goog.fx.Dragger.EventType');
|
||||
goog.require('goog.math');
|
||||
goog.require('goog.math.Rect');
|
||||
goog.require('goog.style');
|
||||
goog.require('ol');
|
||||
goog.require('ol.animation');
|
||||
goog.require('ol.control.Control');
|
||||
goog.require('ol.css');
|
||||
goog.require('ol.easing');
|
||||
|
||||
|
||||
/**
|
||||
* @define {number} Animation duration.
|
||||
*/
|
||||
ol.control.ZOOMSLIDER_ANIMATION_DURATION = 200;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* A slider type of control for zooming.
|
||||
@@ -190,7 +185,7 @@ ol.control.ZoomSlider.prototype.handleContainerClick_ = function(browserEvent) {
|
||||
goog.asserts.assert(goog.isDef(resolution));
|
||||
map.beforeRender(ol.animation.zoom({
|
||||
resolution: resolution,
|
||||
duration: ol.control.ZOOMSLIDER_ANIMATION_DURATION,
|
||||
duration: ol.ZOOMSLIDER_ANIMATION_DURATION,
|
||||
easing: ol.easing.easeOut
|
||||
}));
|
||||
resolution = view.constrainResolution(resolution);
|
||||
@@ -295,7 +290,7 @@ ol.control.ZoomSlider.prototype.handleSliderChange_ = function(e) {
|
||||
goog.asserts.assert(goog.isDef(this.currentResolution_));
|
||||
map.beforeRender(ol.animation.zoom({
|
||||
resolution: this.currentResolution_,
|
||||
duration: ol.control.ZOOMSLIDER_ANIMATION_DURATION,
|
||||
duration: ol.ZOOMSLIDER_ANIMATION_DURATION,
|
||||
easing: ol.easing.easeOut
|
||||
}));
|
||||
resolution = view.constrainResolution(this.currentResolution_);
|
||||
|
||||
@@ -5,6 +5,7 @@ goog.provide('ol.interaction.DragRotateAndZoom');
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.functions');
|
||||
goog.require('goog.math.Vec2');
|
||||
goog.require('ol');
|
||||
goog.require('ol.ViewHint');
|
||||
goog.require('ol.events.ConditionType');
|
||||
goog.require('ol.events.condition');
|
||||
@@ -12,12 +13,6 @@ goog.require('ol.interaction.Interaction');
|
||||
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
|
||||
@@ -125,7 +120,7 @@ ol.interaction.DragRotateAndZoom.prototype.handlePointerUp =
|
||||
var direction = this.lastScaleDelta_ - 1;
|
||||
ol.interaction.Interaction.rotate(map, view2D, view2DState.rotation);
|
||||
ol.interaction.Interaction.zoom(map, view2D, view2DState.resolution,
|
||||
undefined, ol.interaction.DRAGROTATEANDZOOM_ANIMATION_DURATION,
|
||||
undefined, ol.DRAGROTATEANDZOOM_ANIMATION_DURATION,
|
||||
direction);
|
||||
this.lastScaleDelta_ = 0;
|
||||
return false;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
goog.provide('ol.interaction.DragRotate');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol');
|
||||
goog.require('ol.ViewHint');
|
||||
goog.require('ol.events.ConditionType');
|
||||
goog.require('ol.events.condition');
|
||||
@@ -8,12 +9,6 @@ goog.require('ol.interaction.Interaction');
|
||||
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,
|
||||
@@ -93,7 +88,7 @@ ol.interaction.DragRotate.prototype.handlePointerUp =
|
||||
var view2D = view.getView2D();
|
||||
var view2DState = view2D.getView2DState();
|
||||
ol.interaction.Interaction.rotate(map, view2D, view2DState.rotation,
|
||||
undefined, ol.interaction.DRAGROTATE_ANIMATION_DURATION);
|
||||
undefined, ol.DRAGROTATE_ANIMATION_DURATION);
|
||||
return false;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
goog.provide('ol.interaction.DragZoom');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol');
|
||||
goog.require('ol.events.condition');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.interaction.DragBox');
|
||||
@@ -9,12 +10,6 @@ goog.require('ol.style.Stroke');
|
||||
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,
|
||||
@@ -62,5 +57,5 @@ ol.interaction.DragZoom.prototype.onBoxEnd = function() {
|
||||
var center = ol.extent.getCenter(extent);
|
||||
ol.interaction.Interaction.zoom(map, view,
|
||||
view.getResolutionForExtent(extent, map.getSize()),
|
||||
center, ol.interaction.DRAGZOOM_ANIMATION_DURATION);
|
||||
center, ol.DRAGZOOM_ANIMATION_DURATION);
|
||||
};
|
||||
|
||||
@@ -6,6 +6,7 @@ goog.require('goog.asserts');
|
||||
goog.require('goog.events.KeyCodes');
|
||||
goog.require('goog.events.KeyHandler.EventType');
|
||||
goog.require('goog.functions');
|
||||
goog.require('ol');
|
||||
goog.require('ol.View2D');
|
||||
goog.require('ol.coordinate');
|
||||
goog.require('ol.events.ConditionType');
|
||||
@@ -13,12 +14,6 @@ goog.require('ol.events.condition');
|
||||
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.
|
||||
@@ -93,7 +88,7 @@ ol.interaction.KeyboardPan.prototype.handleMapBrowserEvent =
|
||||
var delta = [deltaX, deltaY];
|
||||
ol.coordinate.rotate(delta, view2DState.rotation);
|
||||
ol.interaction.Interaction.pan(
|
||||
map, view, delta, ol.interaction.KEYBOARD_PAN_DURATION);
|
||||
map, view, delta, ol.KEYBOARD_PAN_DURATION);
|
||||
mapBrowserEvent.preventDefault();
|
||||
stopEvent = true;
|
||||
}
|
||||
|
||||
@@ -6,22 +6,11 @@ goog.require('goog.asserts');
|
||||
goog.require('goog.events.MouseWheelEvent');
|
||||
goog.require('goog.events.MouseWheelHandler.EventType');
|
||||
goog.require('goog.math');
|
||||
goog.require('ol');
|
||||
goog.require('ol.Coordinate');
|
||||
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.
|
||||
@@ -89,7 +78,7 @@ ol.interaction.MouseWheelZoom.prototype.handleMapBrowserEvent =
|
||||
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);
|
||||
|
||||
goog.global.clearTimeout(this.timeoutId_);
|
||||
@@ -108,7 +97,7 @@ ol.interaction.MouseWheelZoom.prototype.handleMapBrowserEvent =
|
||||
* @param {ol.Map} map 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);
|
||||
|
||||
// FIXME works for View2D only
|
||||
|
||||
@@ -4,18 +4,13 @@ goog.provide('ol.interaction.PinchRotate');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('goog.style');
|
||||
goog.require('ol');
|
||||
goog.require('ol.Coordinate');
|
||||
goog.require('ol.ViewHint');
|
||||
goog.require('ol.interaction.Interaction');
|
||||
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
|
||||
@@ -131,7 +126,7 @@ ol.interaction.PinchRotate.prototype.handlePointerUp =
|
||||
var view2DState = view2D.getView2DState();
|
||||
ol.interaction.Interaction.rotate(
|
||||
map, view2D, view2DState.rotation, this.anchor_,
|
||||
ol.interaction.ROTATE_ANIMATION_DURATION);
|
||||
ol.ROTATE_ANIMATION_DURATION);
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
|
||||
62
src/ol/ol.js
62
src/ol/ol.js
@@ -33,6 +33,30 @@ ol.DEFAULT_TILE_CACHE_HIGH_WATER_MARK = 2048;
|
||||
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.
|
||||
*/
|
||||
@@ -57,6 +81,14 @@ ol.ENABLE_DOM = 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.
|
||||
*/
|
||||
@@ -104,12 +136,42 @@ ol.IS_LEGACY_IE = goog.userAgent.IE &&
|
||||
!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.
|
||||
*/
|
||||
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
|
||||
* for use in non-compiled application code.
|
||||
|
||||
@@ -6,6 +6,7 @@ goog.require('goog.asserts');
|
||||
goog.require('goog.object');
|
||||
goog.require('goog.string');
|
||||
goog.require('goog.uri.utils');
|
||||
goog.require('ol');
|
||||
goog.require('ol.Image');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.proj');
|
||||
@@ -150,7 +151,7 @@ ol.source.ImageWMS.prototype.getGetFeatureInfoUrl =
|
||||
|
||||
var baseParams = {
|
||||
'SERVICE': 'WMS',
|
||||
'VERSION': ol.source.wms.DEFAULT_VERSION,
|
||||
'VERSION': ol.DEFAULT_WMS_VERSION,
|
||||
'REQUEST': 'GetFeatureInfo',
|
||||
'FORMAT': 'image/png',
|
||||
'TRANSPARENT': true,
|
||||
@@ -208,7 +209,7 @@ ol.source.ImageWMS.prototype.getImage =
|
||||
|
||||
var params = {
|
||||
'SERVICE': 'WMS',
|
||||
'VERSION': ol.source.wms.DEFAULT_VERSION,
|
||||
'VERSION': ol.DEFAULT_WMS_VERSION,
|
||||
'REQUEST': 'GetMap',
|
||||
'FORMAT': 'image/png',
|
||||
'TRANSPARENT': true
|
||||
@@ -355,6 +356,6 @@ ol.source.ImageWMS.prototype.updateParams = function(params) {
|
||||
*/
|
||||
ol.source.ImageWMS.prototype.updateV13_ = function() {
|
||||
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;
|
||||
};
|
||||
|
||||
@@ -10,6 +10,7 @@ goog.require('goog.math');
|
||||
goog.require('goog.object');
|
||||
goog.require('goog.string');
|
||||
goog.require('goog.uri.utils');
|
||||
goog.require('ol');
|
||||
goog.require('ol.TileCoord');
|
||||
goog.require('ol.TileUrlFunction');
|
||||
goog.require('ol.extent');
|
||||
@@ -165,7 +166,7 @@ ol.source.TileWMS.prototype.getGetFeatureInfoUrl =
|
||||
|
||||
var baseParams = {
|
||||
'SERVICE': 'WMS',
|
||||
'VERSION': ol.source.wms.DEFAULT_VERSION,
|
||||
'VERSION': ol.DEFAULT_WMS_VERSION,
|
||||
'REQUEST': 'GetFeatureInfo',
|
||||
'FORMAT': 'image/png',
|
||||
'TRANSPARENT': true,
|
||||
@@ -373,7 +374,7 @@ ol.source.TileWMS.prototype.tileUrlFunction_ =
|
||||
|
||||
var baseParams = {
|
||||
'SERVICE': 'WMS',
|
||||
'VERSION': ol.source.wms.DEFAULT_VERSION,
|
||||
'VERSION': ol.DEFAULT_WMS_VERSION,
|
||||
'REQUEST': 'GetMap',
|
||||
'FORMAT': 'image/png',
|
||||
'TRANSPARENT': true
|
||||
@@ -405,6 +406,6 @@ ol.source.TileWMS.prototype.updateParams = function(params) {
|
||||
*/
|
||||
ol.source.TileWMS.prototype.updateV13_ = function() {
|
||||
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;
|
||||
};
|
||||
|
||||
@@ -2,12 +2,6 @@ goog.provide('ol.source.wms');
|
||||
goog.provide('ol.source.wms.ServerType');
|
||||
|
||||
|
||||
/**
|
||||
* @define {string} WMS default version.
|
||||
*/
|
||||
ol.source.wms.DEFAULT_VERSION = '1.3.0';
|
||||
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user