Merge pull request #706 from elemoine/user-extensions

Custom control framework
This commit is contained in:
Éric Lemoine
2013-05-10 04:47:39 -07:00
14 changed files with 273 additions and 15 deletions

View File

@@ -123,6 +123,13 @@
* @property {Element|undefined} target Target.
*/
/**
* @typedef {Object} ol.control.ControlOptions
* @property {Element|undefined} element Element.
* @property {ol.Map|undefined} map Map.
* @property {Element|undefined} target Target.
*/
/**
* @typedef {Object} ol.control.DefaultsOptions
* @property {boolean|undefined} attribution Attribution.

View File

@@ -0,0 +1,4 @@
@exportClass ol.control.Control ol.control.ControlOptions
@exportProperty ol.control.Control.prototype.handleMapPostrender
@exportProperty ol.control.Control.prototype.getMap
@exportProperty ol.control.Control.prototype.setMap

View File

@@ -1,5 +1,4 @@
goog.provide('ol.control.Control');
goog.provide('ol.control.ControlOptions');
goog.require('goog.Disposable');
goog.require('goog.array');
@@ -8,14 +7,6 @@ goog.require('goog.events');
goog.require('ol.MapEventType');
/**
* @typedef {{element: (Element|undefined),
* map: (ol.Map|undefined),
* target: (Element|undefined)}}
*/
ol.control.ControlOptions;
/**
* A thing which is painted over the map to provide a means for interaction
@@ -23,6 +14,7 @@ ol.control.ControlOptions;
*
* @constructor
* @extends {goog.Disposable}
* @implements {oli.control.Control}
* @param {ol.control.ControlOptions} options Control options.
*/
ol.control.Control = function(options) {
@@ -79,16 +71,18 @@ ol.control.Control.prototype.getMap = function() {
/**
* Function called on each map render. Executes in a requestAnimationFrame
* callback. Can be implemented in sub-classes to re-render the control's
* UI.
* @param {ol.MapEvent} mapEvent Map event.
*/
ol.control.Control.prototype.handleMapPostrender = goog.nullFunction;
ol.control.Control.prototype.handleMapPostrender = function(mapEvent) {};
/**
* Removes the control from its current map and attaches it to the new map.
* Subtypes might also wish set up event handlers to get notified about changes
* to the map here.
*
* Remove the control from its current map and attach it to the new map.
* Subclasses may set up event handlers to get notified about changes to
* the map here.
* @param {ol.Map} map Map.
*/
ol.control.Control.prototype.setMap = function(map) {
@@ -104,7 +98,8 @@ ol.control.Control.prototype.setMap = function(map) {
var target = goog.isDef(this.target_) ?
this.target_ : map.getOverlayContainer();
goog.dom.appendChild(target, this.element);
if (this.handleMapPostrender !== goog.nullFunction) {
if (this.handleMapPostrender !==
ol.control.Control.prototype.handleMapPostrender) {
this.listenerKeys.push(goog.events.listen(map,
ol.MapEventType.POSTRENDER, this.handleMapPostrender, false, this));
}

1
src/ol/ol.exports Normal file
View File

@@ -0,0 +1 @@
@exportSymbol ol.inherits

14
src/ol/ol.js Normal file
View File

@@ -0,0 +1,14 @@
goog.provide('ol');
/**
* ol.inherits is an alias to the goog.inherits function. It is exported
* for use in non-compiled application code. See ol.exports.
*
* FIXME: We use a new line to fake the linter. Without the new line the
* linter complains with:
*
* "Missing newline between constructor and goog.inherits"
*/
ol.inherits =
goog.inherits;