Making Element/Node types more consistent.
This commit is contained in:
+34
-12
@@ -87,13 +87,13 @@ ol.Map = function() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {Element}
|
* @type {Node}
|
||||||
*/
|
*/
|
||||||
this.mapOverlay_ = null;
|
this.mapOverlay_ = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {Element}
|
* @type {Node}
|
||||||
*/
|
*/
|
||||||
this.staticOverlay_ = null;
|
this.staticOverlay_ = null;
|
||||||
|
|
||||||
@@ -433,8 +433,11 @@ ol.Map.prototype.setContainer = function(container) {
|
|||||||
* Check if everything is ready. Render if so.
|
* Check if everything is ready. Render if so.
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.conditionallyRender = function() {
|
ol.Map.prototype.conditionallyRender = function() {
|
||||||
if (!goog.isNull(this.layers_) && goog.isDef(this.zoom_) && !goog.isNull(this.center_)) {
|
if (goog.isDef(this.renderer_) && !goog.isNull(this.layers_) &&
|
||||||
this.renderer_.draw(this.layers_, this.center_, this.getResolutionForZoom(this.zoom_));
|
goog.isDef(this.zoom_) && !goog.isNull(this.center_)) {
|
||||||
|
this.renderer_.draw(this.layers_, this.center_,
|
||||||
|
this.getResolutionForZoom(this.zoom_)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -447,13 +450,10 @@ ol.Map.prototype.getViewport = function() {
|
|||||||
|
|
||||||
ol.Map.prototype.setViewport = function() {
|
ol.Map.prototype.setViewport = function() {
|
||||||
if (!this.viewport_) {
|
if (!this.viewport_) {
|
||||||
this.viewport_ = goog.dom.createDom('div', {
|
this.viewport_ = /** @type {Element} */ (goog.dom.createDom('div', {
|
||||||
'class': 'ol-viewport',
|
'class': 'ol-viewport',
|
||||||
'style': 'height:100%;width:100%;position:relative;top:0;left:0;overflow:hidden'
|
'style': 'width:100%;height:100%;top:0;left:0;position:relative;overflow:hidden'
|
||||||
});
|
}));
|
||||||
this.mapOverlay_ = goog.dom.createDom('div', 'ol-overlay-map');
|
|
||||||
this.staticOverlay_ = goog.dom.createDom('div', 'ol-overlay-static');
|
|
||||||
goog.dom.append(this.viewport_, this.mapOverlay_, this.staticOverlay_);
|
|
||||||
}
|
}
|
||||||
this.events_.setElement(this.viewport_);
|
this.events_.setElement(this.viewport_);
|
||||||
goog.dom.appendChild(this.container_, this.viewport_);
|
goog.dom.appendChild(this.container_, this.viewport_);
|
||||||
@@ -463,6 +463,28 @@ ol.Map.prototype.createRenderer = function() {
|
|||||||
var Renderer = ol.renderer.MapRenderer.pickRendererType(
|
var Renderer = ol.renderer.MapRenderer.pickRendererType(
|
||||||
ol.Map.preferredRenderers);
|
ol.Map.preferredRenderers);
|
||||||
this.renderer_ = new Renderer(this.viewport_);
|
this.renderer_ = new Renderer(this.viewport_);
|
||||||
|
|
||||||
|
//TODO Consider making a renderer responsible for managing the overlays
|
||||||
|
var viewport = this.viewport_;
|
||||||
|
if (!this.mapOverlay_ && !this.staticOverlay_) {
|
||||||
|
var staticCls = 'ol-overlay-static';
|
||||||
|
this.mapOverlay_ = goog.dom.createDom('div', 'ol-overlay-map');
|
||||||
|
this.staticOverlay_ = goog.dom.createDom('div', {
|
||||||
|
'class': staticCls,
|
||||||
|
'style': 'width:100%;height:100%;top:0;left:0;position:absolute'
|
||||||
|
});
|
||||||
|
// Prevent click events on links in the static overlay from getting
|
||||||
|
// through to listeners. This is not registered as priority listener,
|
||||||
|
// so priority listeners can still get the click event.
|
||||||
|
this.events_.register('click', function(evt) {
|
||||||
|
var node = evt.target;
|
||||||
|
return !(node.nodeName === 'A' &&
|
||||||
|
goog.dom.getAncestorByClass(node, staticCls));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (!goog.isNull(viewport)) {
|
||||||
|
goog.dom.append(viewport, this.mapOverlay_, this.staticOverlay_);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -497,14 +519,14 @@ ol.Map.prototype.zoomOut = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {Element} the map overlay element
|
* @returns {Node} the map overlay element
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.getMapOverlay = function() {
|
ol.Map.prototype.getMapOverlay = function() {
|
||||||
return this.mapOverlay_;
|
return this.mapOverlay_;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {Element} the static overlay element
|
* @returns {Node} the static overlay element
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.getStaticOverlay = function() {
|
ol.Map.prototype.getStaticOverlay = function() {
|
||||||
return this.staticOverlay_;
|
return this.staticOverlay_;
|
||||||
|
|||||||
@@ -104,7 +104,8 @@ ol.control.Zoom.prototype.handle = function(evt) {
|
|||||||
|
|
||||||
ol.control.Zoom.prototype.destroy = function() {
|
ol.control.Zoom.prototype.destroy = function() {
|
||||||
goog.dom.removeNode(goog.dom.getElementByClass(
|
goog.dom.removeNode(goog.dom.getElementByClass(
|
||||||
ol.control.Zoom.RES.CLS, this.map_.getViewport()
|
ol.control.Zoom.RES.CLS,
|
||||||
|
/** @type {Element} */ (this.map_.getViewport())
|
||||||
));
|
));
|
||||||
goog.base(this, 'destroy');
|
goog.base(this, 'destroy');
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ ol.event.Events.prototype.getElement = function() {
|
|||||||
* Attach this instance to a DOM element. When called, all browser events fired
|
* Attach this instance to a DOM element. When called, all browser events fired
|
||||||
* on the provided element will be relayed by this instance.
|
* on the provided element will be relayed by this instance.
|
||||||
*
|
*
|
||||||
* @param {Element} element A DOM element to attach
|
* @param {Element|Node} element A DOM element to attach
|
||||||
* browser events to. If called without this argument, all browser events
|
* browser events to. If called without this argument, all browser events
|
||||||
* will be detached from the element they are currently attached to.
|
* will be detached from the element they are currently attached to.
|
||||||
*/
|
*/
|
||||||
@@ -161,7 +161,7 @@ ol.event.Events.prototype.setElement = function(element) {
|
|||||||
this.destroySequences();
|
this.destroySequences();
|
||||||
delete this.element_;
|
delete this.element_;
|
||||||
}
|
}
|
||||||
this.element_ = element || null;
|
this.element_ = /** @type {Element} */ (element) || null;
|
||||||
if (goog.isDefAndNotNull(element)) {
|
if (goog.isDefAndNotNull(element)) {
|
||||||
this.createSequences();
|
this.createSequences();
|
||||||
for (t in types) {
|
for (t in types) {
|
||||||
|
|||||||
Reference in New Issue
Block a user