Add a "render" control option
This commit is contained in:
@@ -802,6 +802,7 @@ olx.control;
|
|||||||
* tipLabel: (string|undefined),
|
* tipLabel: (string|undefined),
|
||||||
* label: (string|undefined),
|
* label: (string|undefined),
|
||||||
* collapseLabel: (string|undefined),
|
* collapseLabel: (string|undefined),
|
||||||
|
* render: (function(ol.MapEvent)|undefined),
|
||||||
* target: (Element|undefined)}}
|
* target: (Element|undefined)}}
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
@@ -865,8 +866,19 @@ olx.control.AttributionOptions.prototype.label;
|
|||||||
*/
|
*/
|
||||||
olx.control.AttributionOptions.prototype.collapseLabel;
|
olx.control.AttributionOptions.prototype.collapseLabel;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function called when the control should be re-rendered. This is called
|
||||||
|
* in a requestAnimationFrame callback.
|
||||||
|
* @type {function(ol.MapEvent)|undefined}
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
olx.control.AttributionOptions.prototype.render;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {{element: (Element|undefined),
|
* @typedef {{element: (Element|undefined),
|
||||||
|
* render: (function(ol.MapEvent)|undefined),
|
||||||
* target: (Element|string|undefined)}}
|
* target: (Element|string|undefined)}}
|
||||||
* @api stable
|
* @api stable
|
||||||
*/
|
*/
|
||||||
@@ -882,6 +894,15 @@ olx.control.ControlOptions;
|
|||||||
olx.control.ControlOptions.prototype.element;
|
olx.control.ControlOptions.prototype.element;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function called when the control should be re-rendered. This is called
|
||||||
|
* in a requestAnimationFrame callback.
|
||||||
|
* @type {function(ol.MapEvent)|undefined}
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
olx.control.ControlOptions.prototype.render;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specify a target if you want the control to be rendered outside of the map's
|
* Specify a target if you want the control to be rendered outside of the map's
|
||||||
* viewport.
|
* viewport.
|
||||||
@@ -997,6 +1018,7 @@ olx.control.FullScreenOptions.prototype.target;
|
|||||||
* @typedef {{className: (string|undefined),
|
* @typedef {{className: (string|undefined),
|
||||||
* coordinateFormat: (ol.CoordinateFormatType|undefined),
|
* coordinateFormat: (ol.CoordinateFormatType|undefined),
|
||||||
* projection: ol.proj.ProjectionLike,
|
* projection: ol.proj.ProjectionLike,
|
||||||
|
* render: (function(ol.MapEvent)|undefined),
|
||||||
* target: (Element|undefined),
|
* target: (Element|undefined),
|
||||||
* undefinedHTML: (string|undefined)}}
|
* undefinedHTML: (string|undefined)}}
|
||||||
* @api stable
|
* @api stable
|
||||||
@@ -1028,6 +1050,15 @@ olx.control.MousePositionOptions.prototype.coordinateFormat;
|
|||||||
olx.control.MousePositionOptions.prototype.projection;
|
olx.control.MousePositionOptions.prototype.projection;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function called when the control should be re-rendered. This is called
|
||||||
|
* in a requestAnimationFrame callback.
|
||||||
|
* @type {function(ol.MapEvent)|undefined}
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
olx.control.MousePositionOptions.prototype.render;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Target.
|
* Target.
|
||||||
* @type {Element|undefined}
|
* @type {Element|undefined}
|
||||||
@@ -1050,6 +1081,7 @@ olx.control.MousePositionOptions.prototype.undefinedHTML;
|
|||||||
* collapsible: (boolean|undefined),
|
* collapsible: (boolean|undefined),
|
||||||
* label: (string|undefined),
|
* label: (string|undefined),
|
||||||
* layers: (Array.<ol.layer.Layer>|ol.Collection|undefined),
|
* layers: (Array.<ol.layer.Layer>|ol.Collection|undefined),
|
||||||
|
* render: (function(ol.MapEvent)|undefined),
|
||||||
* target: (Element|undefined),
|
* target: (Element|undefined),
|
||||||
* tipLabel: (string|undefined)}}
|
* tipLabel: (string|undefined)}}
|
||||||
* @api
|
* @api
|
||||||
@@ -1099,6 +1131,15 @@ olx.control.OverviewMapOptions.prototype.label;
|
|||||||
olx.control.OverviewMapOptions.prototype.layers;
|
olx.control.OverviewMapOptions.prototype.layers;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function called when the control should be re-rendered. This is called
|
||||||
|
* in a requestAnimationFrame callback.
|
||||||
|
* @type {function(ol.MapEvent)|undefined}
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
olx.control.OverviewMapOptions.prototype.render;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specify a target if you want the control to be rendered outside of the map's
|
* Specify a target if you want the control to be rendered outside of the map's
|
||||||
* viewport.
|
* viewport.
|
||||||
@@ -1119,6 +1160,7 @@ olx.control.OverviewMapOptions.prototype.tipLabel;
|
|||||||
/**
|
/**
|
||||||
* @typedef {{className: (string|undefined),
|
* @typedef {{className: (string|undefined),
|
||||||
* minWidth: (number|undefined),
|
* minWidth: (number|undefined),
|
||||||
|
* render: (function(ol.MapEvent)|undefined),
|
||||||
* target: (Element|undefined),
|
* target: (Element|undefined),
|
||||||
* units: (ol.control.ScaleLineUnits|string|undefined)}}
|
* units: (ol.control.ScaleLineUnits|string|undefined)}}
|
||||||
* @api stable
|
* @api stable
|
||||||
@@ -1142,6 +1184,15 @@ olx.control.ScaleLineOptions.prototype.className;
|
|||||||
olx.control.ScaleLineOptions.prototype.minWidth;
|
olx.control.ScaleLineOptions.prototype.minWidth;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function called when the control should be re-rendered. This is called
|
||||||
|
* in a requestAnimationFrame callback.
|
||||||
|
* @type {function(ol.MapEvent)|undefined}
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
olx.control.ScaleLineOptions.prototype.render;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Target.
|
* Target.
|
||||||
* @type {Element|undefined}
|
* @type {Element|undefined}
|
||||||
@@ -1164,6 +1215,7 @@ olx.control.ScaleLineOptions.prototype.units;
|
|||||||
* label: (string|undefined),
|
* label: (string|undefined),
|
||||||
* tipLabel: (string|undefined),
|
* tipLabel: (string|undefined),
|
||||||
* target: (Element|undefined),
|
* target: (Element|undefined),
|
||||||
|
* render: (function(ol.MapEvent)|undefined),
|
||||||
* autoHide: (boolean|undefined)}}
|
* autoHide: (boolean|undefined)}}
|
||||||
* @api stable
|
* @api stable
|
||||||
*/
|
*/
|
||||||
@@ -1210,6 +1262,15 @@ olx.control.RotateOptions.prototype.duration;
|
|||||||
olx.control.RotateOptions.prototype.autoHide;
|
olx.control.RotateOptions.prototype.autoHide;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function called when the control should be re-rendered. This is called
|
||||||
|
* in a requestAnimationFrame callback.
|
||||||
|
* @type {function(ol.MapEvent)|undefined}
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
olx.control.RotateOptions.prototype.render;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Target.
|
* Target.
|
||||||
* @type {Element|undefined}
|
* @type {Element|undefined}
|
||||||
@@ -1299,8 +1360,9 @@ olx.control.ZoomOptions.prototype.target;
|
|||||||
/**
|
/**
|
||||||
* @typedef {{className: (string|undefined),
|
* @typedef {{className: (string|undefined),
|
||||||
* maxResolution: (number|undefined),
|
* maxResolution: (number|undefined),
|
||||||
* minResolution: (number|undefined)}}
|
* minResolution: (number|undefined),
|
||||||
* @api stable
|
* render: (function(ol.MapEvent)|undefined)}}
|
||||||
|
* @api
|
||||||
*/
|
*/
|
||||||
olx.control.ZoomSliderOptions;
|
olx.control.ZoomSliderOptions;
|
||||||
|
|
||||||
@@ -1329,6 +1391,15 @@ olx.control.ZoomSliderOptions.prototype.maxResolution;
|
|||||||
olx.control.ZoomSliderOptions.prototype.minResolution;
|
olx.control.ZoomSliderOptions.prototype.minResolution;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function called when the control should be re-rendered. This is called
|
||||||
|
* in a requestAnimationFrame callback.
|
||||||
|
* @type {function(ol.MapEvent)|undefined}
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
|
olx.control.ZoomSliderOptions.prototype.render;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {{className: (string|undefined),
|
* @typedef {{className: (string|undefined),
|
||||||
* target: (Element|undefined),
|
* target: (Element|undefined),
|
||||||
|
|||||||
@@ -113,8 +113,12 @@ ol.control.Attribution = function(opt_options) {
|
|||||||
var element = goog.dom.createDom(goog.dom.TagName.DIV,
|
var element = goog.dom.createDom(goog.dom.TagName.DIV,
|
||||||
cssClasses, this.ulElement_, button);
|
cssClasses, this.ulElement_, button);
|
||||||
|
|
||||||
|
var render = goog.isDef(options.render) ?
|
||||||
|
options.render : ol.control.Attribution.render;
|
||||||
|
|
||||||
goog.base(this, {
|
goog.base(this, {
|
||||||
element: element,
|
element: element,
|
||||||
|
render: render,
|
||||||
target: options.target
|
target: options.target
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -192,9 +196,11 @@ ol.control.Attribution.prototype.getSourceAttributions = function(frameState) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @param {ol.MapEvent} mapEvent Map event.
|
||||||
|
* @this {ol.control.Attribution}
|
||||||
|
* @api
|
||||||
*/
|
*/
|
||||||
ol.control.Attribution.prototype.handleMapPostrender = function(mapEvent) {
|
ol.control.Attribution.render = function(mapEvent) {
|
||||||
this.updateElement_(mapEvent.frameState);
|
this.updateElement_(mapEvent.frameState);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -66,6 +66,11 @@ ol.control.Control = function(options) {
|
|||||||
*/
|
*/
|
||||||
this.listenerKeys = [];
|
this.listenerKeys = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {function(ol.MapEvent)}
|
||||||
|
*/
|
||||||
|
this.render = goog.isDef(options.render) ? options.render : goog.nullFunction;
|
||||||
|
|
||||||
};
|
};
|
||||||
goog.inherits(ol.control.Control, ol.Object);
|
goog.inherits(ol.control.Control, ol.Object);
|
||||||
|
|
||||||
@@ -89,15 +94,6 @@ 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;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove the control from its current map and attach it to the new map.
|
* 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
|
* Subclasses may set up event handlers to get notified about changes to
|
||||||
@@ -118,9 +114,9 @@ ol.control.Control.prototype.setMap = function(map) {
|
|||||||
var target = !goog.isNull(this.target_) ?
|
var target = !goog.isNull(this.target_) ?
|
||||||
this.target_ : map.getOverlayContainerStopEvent();
|
this.target_ : map.getOverlayContainerStopEvent();
|
||||||
goog.dom.appendChild(target, this.element);
|
goog.dom.appendChild(target, this.element);
|
||||||
if (this.handleMapPostrender !== goog.nullFunction) {
|
if (this.render !== goog.nullFunction) {
|
||||||
this.listenerKeys.push(goog.events.listen(map,
|
this.listenerKeys.push(goog.events.listen(map,
|
||||||
ol.MapEventType.POSTRENDER, this.handleMapPostrender, false, this));
|
ol.MapEventType.POSTRENDER, this.render, false, this));
|
||||||
}
|
}
|
||||||
map.render();
|
map.render();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,8 +47,12 @@ ol.control.MousePosition = function(opt_options) {
|
|||||||
|
|
||||||
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) ?
|
||||||
|
options.render : ol.control.MousePosition.render;
|
||||||
|
|
||||||
goog.base(this, {
|
goog.base(this, {
|
||||||
element: element,
|
element: element,
|
||||||
|
render: render,
|
||||||
target: options.target
|
target: options.target
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -99,9 +103,11 @@ goog.inherits(ol.control.MousePosition, ol.control.Control);
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @param {ol.MapEvent} mapEvent Map event.
|
||||||
|
* @this {ol.control.MousePosition}
|
||||||
|
* @api
|
||||||
*/
|
*/
|
||||||
ol.control.MousePosition.prototype.handleMapPostrender = function(mapEvent) {
|
ol.control.MousePosition.render = function(mapEvent) {
|
||||||
var frameState = mapEvent.frameState;
|
var frameState = mapEvent.frameState;
|
||||||
if (goog.isNull(frameState)) {
|
if (goog.isNull(frameState)) {
|
||||||
this.mapProjection_ = null;
|
this.mapProjection_ = null;
|
||||||
|
|||||||
@@ -136,8 +136,12 @@ 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) ?
|
||||||
|
options.render : ol.control.OverviewMap.render;
|
||||||
|
|
||||||
goog.base(this, {
|
goog.base(this, {
|
||||||
element: element,
|
element: element,
|
||||||
|
render: render,
|
||||||
target: options.target
|
target: options.target
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -201,12 +205,11 @@ ol.control.OverviewMap.prototype.bindView_ = function() {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function called on each map render. Executes in a requestAnimationFrame
|
* @param {ol.MapEvent} mapEvent Map event.
|
||||||
* callback. Manage the extent of the overview map accordingly,
|
* @this {ol.control.OverviewMap}
|
||||||
* then update the overview map box.
|
* @api
|
||||||
* @param {goog.events.Event} event Event.
|
|
||||||
*/
|
*/
|
||||||
ol.control.OverviewMap.prototype.handleMapPostrender = function(event) {
|
ol.control.OverviewMap.render = function(mapEvent) {
|
||||||
this.validateExtent_();
|
this.validateExtent_();
|
||||||
this.updateBox_();
|
this.updateBox_();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -62,8 +62,12 @@ 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) ?
|
||||||
|
options.render : ol.control.Rotate.render;
|
||||||
|
|
||||||
goog.base(this, {
|
goog.base(this, {
|
||||||
element: element,
|
element: element,
|
||||||
|
render: render,
|
||||||
target: options.target
|
target: options.target
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -135,9 +139,11 @@ ol.control.Rotate.prototype.resetNorth_ = function() {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @param {ol.MapEvent} mapEvent Map event.
|
||||||
|
* @this {ol.control.Rotate}
|
||||||
|
* @api
|
||||||
*/
|
*/
|
||||||
ol.control.Rotate.prototype.handleMapPostrender = function(mapEvent) {
|
ol.control.Rotate.render = function(mapEvent) {
|
||||||
var frameState = mapEvent.frameState;
|
var frameState = mapEvent.frameState;
|
||||||
if (goog.isNull(frameState)) {
|
if (goog.isNull(frameState)) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -112,8 +112,12 @@ ol.control.ScaleLine = function(opt_options) {
|
|||||||
*/
|
*/
|
||||||
this.toEPSG4326_ = null;
|
this.toEPSG4326_ = null;
|
||||||
|
|
||||||
|
var render = goog.isDef(options.render) ?
|
||||||
|
options.render : ol.control.ScaleLine.render;
|
||||||
|
|
||||||
goog.base(this, {
|
goog.base(this, {
|
||||||
element: this.element_,
|
element: this.element_,
|
||||||
|
render: render,
|
||||||
target: options.target
|
target: options.target
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -152,9 +156,11 @@ goog.exportProperty(
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @param {ol.MapEvent} mapEvent Map event.
|
||||||
|
* @this {ol.control.ScaleLine}
|
||||||
|
* @api
|
||||||
*/
|
*/
|
||||||
ol.control.ScaleLine.prototype.handleMapPostrender = function(mapEvent) {
|
ol.control.ScaleLine.render = function(mapEvent) {
|
||||||
var frameState = mapEvent.frameState;
|
var frameState = mapEvent.frameState;
|
||||||
if (goog.isNull(frameState)) {
|
if (goog.isNull(frameState)) {
|
||||||
this.viewState_ = null;
|
this.viewState_ = null;
|
||||||
|
|||||||
@@ -100,8 +100,12 @@ 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) ?
|
||||||
|
options.render : ol.control.ZoomSlider.render;
|
||||||
|
|
||||||
goog.base(this, {
|
goog.base(this, {
|
||||||
element: containerElement
|
element: containerElement,
|
||||||
|
render: render
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
goog.inherits(ol.control.ZoomSlider, ol.control.Control);
|
goog.inherits(ol.control.ZoomSlider, ol.control.Control);
|
||||||
@@ -166,9 +170,11 @@ ol.control.ZoomSlider.prototype.initSlider_ = function() {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @param {ol.MapEvent} mapEvent Map event.
|
||||||
|
* @this {ol.control.ZoomSlider}
|
||||||
|
* @api
|
||||||
*/
|
*/
|
||||||
ol.control.ZoomSlider.prototype.handleMapPostrender = function(mapEvent) {
|
ol.control.ZoomSlider.render = function(mapEvent) {
|
||||||
if (goog.isNull(mapEvent.frameState)) {
|
if (goog.isNull(mapEvent.frameState)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user