Merge remote-tracking branch 'openlayers/master' into vector-api

This commit is contained in:
Tom Payne
2013-11-27 13:10:20 +01:00
55 changed files with 2496 additions and 200 deletions

View File

@@ -40,8 +40,8 @@ ol.control.MousePositionProperty = {
* @todo stability experimental
* @todo observable projection {ol.proj.Projection} the projection to report
* mouse position in
* @todo observable coordinateFormat {string} the format to render the current
* position in
* @todo observable coordinateFormat {ol.CoordinateFormatType} the format to
* render the current position in
*/
ol.control.MousePosition = function(opt_options) {

View File

@@ -1,6 +1,5 @@
// FIXME works for View2D only
// FIXME should possibly show tooltip when dragging?
// FIXME should possibly be adjustable by clicking on container
goog.provide('ol.control.ZoomSlider');
@@ -9,6 +8,7 @@ goog.require('goog.asserts');
goog.require('goog.dom');
goog.require('goog.dom.TagName');
goog.require('goog.events');
goog.require('goog.events.Event');
goog.require('goog.events.EventType');
goog.require('goog.fx.Dragger');
goog.require('goog.fx.Dragger.EventType');
@@ -68,29 +68,32 @@ ol.control.ZoomSlider = function(opt_options) {
*/
this.sliderInitialized_ = false;
/**
* @private
* @type {Array.<?number>}
*/
this.draggerListenerKeys_ = null;
var className = goog.isDef(options.className) ?
options.className : 'ol-zoomslider';
var sliderCssCls = className + ' ' + ol.css.CLASS_UNSELECTABLE;
var thumbCssCls = className + '-thumb' + ' ' + ol.css.CLASS_UNSELECTABLE;
var element = goog.dom.createDom(goog.dom.TagName.DIV, sliderCssCls,
goog.dom.createDom(goog.dom.TagName.DIV, thumbCssCls));
var thumbElement = goog.dom.createDom(goog.dom.TagName.DIV,
[className + '-thumb', ol.css.CLASS_UNSELECTABLE]);
var sliderElement = goog.dom.createDom(goog.dom.TagName.DIV,
[className, ol.css.CLASS_UNSELECTABLE], thumbElement);
this.dragger_ = this.createDraggable_(element);
/**
* @type {goog.fx.Dragger}
* @private
*/
this.dragger_ = new goog.fx.Dragger(thumbElement);
this.registerDisposable(this.dragger_);
// FIXME currently only a do nothing function is bound.
goog.events.listen(element, [
goog.events.EventType.TOUCHEND,
goog.events.EventType.CLICK
], this.handleContainerClick_, false, this);
goog.events.listen(this.dragger_, [
goog.fx.Dragger.EventType.DRAG,
goog.fx.Dragger.EventType.END
], this.handleSliderChange_, undefined, this);
goog.events.listen(sliderElement, goog.events.EventType.CLICK,
this.handleContainerClick_, false, this);
goog.events.listen(thumbElement, goog.events.EventType.CLICK,
goog.events.Event.stopPropagation);
goog.base(this, {
element: element
element: sliderElement
});
};
goog.inherits(ol.control.ZoomSlider, ol.control.Control);
@@ -178,7 +181,20 @@ ol.control.ZoomSlider.prototype.handleMapPostrender = function(mapEvent) {
* @private
*/
ol.control.ZoomSlider.prototype.handleContainerClick_ = function(browserEvent) {
// TODO implement proper resolution calculation according to browserEvent
var map = this.getMap();
var view = map.getView().getView2D();
var resolution;
var amountDragged = this.amountDragged_(browserEvent.offsetX,
browserEvent.offsetY);
resolution = this.resolutionForAmount_(amountDragged);
goog.asserts.assert(goog.isDef(resolution));
map.beforeRender(ol.animation.zoom({
resolution: resolution,
duration: ol.control.ZOOMSLIDER_ANIMATION_DURATION,
easing: ol.easing.easeOut
}));
resolution = view.constrainResolution(resolution);
view.setResolution(resolution);
};
@@ -207,17 +223,18 @@ ol.control.ZoomSlider.prototype.positionThumbForResolution_ = function(res) {
* Calculates the amount the thumb has been dragged to allow for calculation
* of the corresponding resolution.
*
* @param {goog.fx.DragDropEvent} e The dragdropevent.
* @param {number} x Pixel position relative to the left of the slider.
* @param {number} y Pixel position relative to the top of the slider.
* @return {number} The amount the thumb has been dragged.
* @private
*/
ol.control.ZoomSlider.prototype.amountDragged_ = function(e) {
ol.control.ZoomSlider.prototype.amountDragged_ = function(x, y) {
var draggerLimits = this.dragger_.limits,
amount = 0;
if (this.direction_ === ol.control.ZoomSlider.direction.HORIZONTAL) {
amount = (e.left - draggerLimits.left) / draggerLimits.width;
amount = (x - draggerLimits.left) / draggerLimits.width;
} else {
amount = (e.top - draggerLimits.top) / draggerLimits.height;
amount = (y - draggerLimits.top) / draggerLimits.height;
}
return amount;
};
@@ -268,7 +285,7 @@ ol.control.ZoomSlider.prototype.handleSliderChange_ = function(e) {
var view = map.getView().getView2D();
var resolution;
if (e.type === goog.fx.Dragger.EventType.DRAG) {
var amountDragged = this.amountDragged_(e);
var amountDragged = this.amountDragged_(e.left, e.top);
resolution = this.resolutionForAmount_(amountDragged);
if (resolution !== this.currentResolution_) {
this.currentResolution_ = resolution;
@@ -285,27 +302,3 @@ ol.control.ZoomSlider.prototype.handleSliderChange_ = function(e) {
view.setResolution(resolution);
}
};
/**
* Actually enable draggable behaviour for the thumb of the zoomslider and bind
* relvant event listeners.
*
* @param {Element} elem The element for the slider.
* @return {goog.fx.Dragger} The actual goog.fx.Dragger instance.
* @private
*/
ol.control.ZoomSlider.prototype.createDraggable_ = function(elem) {
if (!goog.isNull(this.draggerListenerKeys_)) {
goog.array.forEach(this.draggerListenerKeys_, goog.events.unlistenByKey);
this.draggerListenerKeys_ = null;
}
var dragger = new goog.fx.Dragger(elem.childNodes[0]);
this.draggerListenerKeys_ = [
goog.events.listen(dragger, [
goog.fx.Dragger.EventType.DRAG,
goog.fx.Dragger.EventType.END
], this.handleSliderChange_, undefined, this)
];
return dragger;
};

View File

@@ -1,4 +1,5 @@
@exportSymbol ol.extent.boundingExtent
@exportSymbol ol.extent.buffer
@exportSymbol ol.extent.containsCoordinate
@exportSymbol ol.extent.containsExtent
@exportSymbol ol.extent.createEmpty

View File

@@ -62,8 +62,9 @@ ol.GeolocationProperty = {
* @todo observable speed {number} readonly the instantaneous speed of the
* device in meters per second
* @todo observable tracking {number} track the device's position.
* @todo observable trackingOptions {number} PositionOptions as defined by the
* HTML5 Geolocation spec at http://dev.w3.org/geo/api/spec-source.html
* @todo observable trackingOptions {GeolocationPositionOptions} PositionOptions
* as defined by the HTML5 Geolocation spec at
* http://dev.w3.org/geo/api/spec-source.html
*/
ol.Geolocation = function(opt_options) {

View File

@@ -245,11 +245,8 @@ ol.Map = function(options) {
goog.events.EventType.CLICK,
goog.events.EventType.DBLCLICK,
goog.events.EventType.MOUSEDOWN,
goog.events.EventType.MOUSEUP,
goog.events.EventType.TOUCHSTART,
goog.events.EventType.TOUCHEND,
goog.events.EventType.MSPOINTERDOWN,
goog.events.EventType.MSPOINTERUP
goog.events.EventType.MSPOINTERDOWN
], goog.events.Event.stopPropagation);
goog.dom.appendChild(this.viewport_, this.overlayContainerStopEvent_);

View File

@@ -142,7 +142,7 @@ ol.Object.getAccessors = function(obj) {
/**
* @param {string} key Key.
* @param {string} key Key name.
* @return {string} Change name.
*/
ol.Object.getChangeEventType = function(key) {
@@ -207,7 +207,7 @@ ol.Object.getSetterName = function(key) {
* }
* );
*
* @param {string} key Key.
* @param {string} key Key name.
* @param {ol.Object} target Target.
* @param {string=} opt_targetKey Target key.
* @return {ol.ObjectAccessor}
@@ -231,7 +231,7 @@ ol.Object.prototype.bindTo = function(key, target, opt_targetKey) {
/**
* Gets a value.
* @param {string} key Key.
* @param {string} key Key name.
* @return {*} Value.
* @todo stability experimental
*/
@@ -291,7 +291,7 @@ ol.Object.prototype.getKeys = function() {
* Notify all observers of a change on this property. This notifies both
* objects that are bound to the object's property as well as the object
* that it is bound to.
* @param {string} key Key.
* @param {string} key Key name.
* @todo stability experimental
*/
ol.Object.prototype.notify = function(key) {
@@ -308,7 +308,7 @@ ol.Object.prototype.notify = function(key) {
/**
* @param {string} key Key.
* @param {string} key Key name.
* @private
*/
ol.Object.prototype.notifyInternal_ = function(key) {
@@ -348,7 +348,7 @@ ol.Object.prototype.once = function(type, listener, opt_scope) {
/**
* Sets a value.
* @param {string} key Key.
* @param {string} key Key name.
* @param {*} value Value.
* @todo stability experimental
*/
@@ -394,7 +394,7 @@ ol.Object.prototype.setValues = function(values) {
/**
* Removes a binding. Unbinding will set the unbound property to the current
* value. The object will not be notified, as the value has not changed.
* @param {string} key Key.
* @param {string} key Key name.
* @todo stability experimental
*/
ol.Object.prototype.unbind = function(key) {

View File

@@ -192,8 +192,8 @@ ol.View2D.prototype.constrainCenter = function(center) {
/**
* Get the constrained the resolution of this view.
* @param {number|undefined} resolution Resolution.
* @param {number=} opt_delta Delta.
* @param {number=} opt_direction Direction.
* @param {number=} opt_delta Delta. Default is `0`.
* @param {number=} opt_direction Direction. Default is `0`.
* @return {number|undefined} Constrained resolution.
* @todo stability experimental
*/
@@ -208,7 +208,7 @@ ol.View2D.prototype.constrainResolution = function(
/**
* Get the constrained rotation of this view.
* @param {number|undefined} rotation Rotation.
* @param {number=} opt_delta Delta.
* @param {number=} opt_delta Delta. Default is `0`.
* @return {number|undefined} Constrained rotation.
* @todo stability experimental
*/