@@ -174,6 +174,12 @@ ol.Map = function(mapOptions) {
|
|||||||
*/
|
*/
|
||||||
this.target_ = mapOptionsInternal.target;
|
this.target_ = mapOptionsInternal.target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {?number}
|
||||||
|
*/
|
||||||
|
this.viewPropertyListenerKey_ = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {Element}
|
* @type {Element}
|
||||||
@@ -277,8 +283,16 @@ ol.Map = function(mapOptions) {
|
|||||||
*/
|
*/
|
||||||
this.tileQueue_ = new ol.TileQueue(goog.bind(this.getTilePriority, this));
|
this.tileQueue_ = new ol.TileQueue(goog.bind(this.getTilePriority, this));
|
||||||
|
|
||||||
|
goog.events.listen(this, ol.Object.getChangedEventType(ol.MapProperty.VIEW),
|
||||||
|
this.handleViewChanged_, false, this);
|
||||||
|
goog.events.listen(this, ol.Object.getChangedEventType(ol.MapProperty.SIZE),
|
||||||
|
this.handleSizeChanged_, false, this);
|
||||||
|
goog.events.listen(
|
||||||
|
this, ol.Object.getChangedEventType(ol.MapProperty.BACKGROUND_COLOR),
|
||||||
|
this.handleBackgroundColorChanged_, false, this),
|
||||||
this.setValues(mapOptionsInternal.values);
|
this.setValues(mapOptionsInternal.values);
|
||||||
|
|
||||||
|
// this gives the map an initial size
|
||||||
this.handleBrowserWindowResize();
|
this.handleBrowserWindowResize();
|
||||||
|
|
||||||
this.controls_.forEach(
|
this.controls_.forEach(
|
||||||
@@ -550,6 +564,14 @@ ol.Map.prototype.handlePostRender = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
ol.Map.prototype.handleBackgroundColorChanged_ = function() {
|
||||||
|
this.render();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
@@ -559,6 +581,40 @@ ol.Map.prototype.handleBrowserWindowResize = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
ol.Map.prototype.handleSizeChanged_ = function() {
|
||||||
|
this.render();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
ol.Map.prototype.handleViewPropertyChanged_ = function() {
|
||||||
|
this.render();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
ol.Map.prototype.handleViewChanged_ = function() {
|
||||||
|
if (!goog.isNull(this.viewPropertyListenerKey_)) {
|
||||||
|
goog.events.unlistenByKey(this.viewPropertyListenerKey_);
|
||||||
|
this.viewPropertyListenerKey_ = null;
|
||||||
|
}
|
||||||
|
var view = this.getView();
|
||||||
|
if (goog.isDefAndNotNull(view)) {
|
||||||
|
this.viewPropertyListenerKey_ = goog.events.listen(
|
||||||
|
view, ol.ObjectEventType.CHANGED,
|
||||||
|
this.handleViewPropertyChanged_, false, this);
|
||||||
|
}
|
||||||
|
this.render();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {boolean} Is defined.
|
* @return {boolean} Is defined.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -76,50 +76,6 @@ ol.renderer.canvas.Map.prototype.getCanvas = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritDoc
|
|
||||||
*/
|
|
||||||
ol.renderer.canvas.Map.prototype.handleBackgroundColorChanged = function() {
|
|
||||||
this.getMap().render();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritDoc
|
|
||||||
*/
|
|
||||||
ol.renderer.canvas.Map.prototype.handleViewPropertyChanged = function() {
|
|
||||||
goog.base(this, 'handleViewPropertyChanged');
|
|
||||||
this.getMap().render();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {goog.events.Event} event Event.
|
|
||||||
* @protected
|
|
||||||
*/
|
|
||||||
ol.renderer.canvas.Map.prototype.handleLayerRendererChange = function(event) {
|
|
||||||
this.getMap().render();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritDoc
|
|
||||||
*/
|
|
||||||
ol.renderer.canvas.Map.prototype.handleSizeChanged = function() {
|
|
||||||
goog.base(this, 'handleSizeChanged');
|
|
||||||
this.getMap().render();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritDoc
|
|
||||||
*/
|
|
||||||
ol.renderer.canvas.Map.prototype.handleViewChanged = function() {
|
|
||||||
goog.base(this, 'handleViewChanged');
|
|
||||||
this.getMap().render();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -40,40 +40,24 @@ ol.renderer.Map = function(container, map) {
|
|||||||
*/
|
*/
|
||||||
this.layerRenderers = {};
|
this.layerRenderers = {};
|
||||||
|
|
||||||
/**
|
//
|
||||||
* @private
|
// We listen to layer add/remove to add/remove layer renderers.
|
||||||
* @type {Array.<number>}
|
//
|
||||||
*/
|
|
||||||
this.layersListenerKeys_ = null;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {?number}
|
* @type {?number}
|
||||||
*/
|
*/
|
||||||
this.viewPropertyListenerKey_ = null;
|
this.mapLayersChangedListenerKey_ =
|
||||||
|
goog.events.listen(
|
||||||
|
map, ol.Object.getChangedEventType(ol.MapProperty.LAYERS),
|
||||||
|
this.handleLayersChanged, false, this);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {Array.<number>}
|
* @type {Array.<number>}
|
||||||
*/
|
*/
|
||||||
this.mapListenerKeys_ = [
|
this.layersListenerKeys_ = null;
|
||||||
goog.events.listen(
|
|
||||||
map, ol.Object.getChangedEventType(ol.MapProperty.BACKGROUND_COLOR),
|
|
||||||
this.handleBackgroundColorChanged, false, this),
|
|
||||||
|
|
||||||
goog.events.listen(
|
|
||||||
map, ol.Object.getChangedEventType(ol.MapProperty.LAYERS),
|
|
||||||
this.handleLayersChanged, false, this),
|
|
||||||
|
|
||||||
goog.events.listen(
|
|
||||||
map, ol.Object.getChangedEventType(ol.MapProperty.SIZE),
|
|
||||||
this.handleSizeChanged, false, this),
|
|
||||||
|
|
||||||
goog.events.listen(
|
|
||||||
map, ol.Object.getChangedEventType(ol.MapProperty.VIEW),
|
|
||||||
this.handleViewChanged, false, this)
|
|
||||||
];
|
|
||||||
|
|
||||||
};
|
};
|
||||||
goog.inherits(ol.renderer.Map, goog.Disposable);
|
goog.inherits(ol.renderer.Map, goog.Disposable);
|
||||||
@@ -136,10 +120,7 @@ ol.renderer.Map.prototype.disposeInternal = function() {
|
|||||||
goog.object.forEach(this.layerRenderers, function(layerRenderer) {
|
goog.object.forEach(this.layerRenderers, function(layerRenderer) {
|
||||||
goog.dispose(layerRenderer);
|
goog.dispose(layerRenderer);
|
||||||
});
|
});
|
||||||
goog.array.forEach(this.mapListenerKeys_, goog.events.unlistenByKey);
|
goog.events.unlistenByKey(this.mapLayersChangedListenerKey_);
|
||||||
if (!goog.isNull(this.viewPropertyListenerKey_)) {
|
|
||||||
goog.events.unlistenByKey(this.viewPropertyListenerKey_);
|
|
||||||
}
|
|
||||||
if (!goog.isNull(this.layersListenerKeys_)) {
|
if (!goog.isNull(this.layersListenerKeys_)) {
|
||||||
goog.array.forEach(this.layersListenerKeys_, goog.events.unlistenByKey);
|
goog.array.forEach(this.layersListenerKeys_, goog.events.unlistenByKey);
|
||||||
}
|
}
|
||||||
@@ -174,12 +155,6 @@ ol.renderer.Map.prototype.getMap = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle background color changed.
|
|
||||||
*/
|
|
||||||
ol.renderer.Map.prototype.handleBackgroundColorChanged = goog.nullFunction;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.CollectionEvent} collectionEvent Collection event.
|
* @param {ol.CollectionEvent} collectionEvent Collection event.
|
||||||
* @protected
|
* @protected
|
||||||
@@ -223,40 +198,6 @@ ol.renderer.Map.prototype.handleLayersRemove = function(collectionEvent) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @protected
|
|
||||||
*/
|
|
||||||
ol.renderer.Map.prototype.handleViewPropertyChanged = function() {
|
|
||||||
this.getMap().render();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @protected
|
|
||||||
*/
|
|
||||||
ol.renderer.Map.prototype.handleSizeChanged = function() {
|
|
||||||
this.getMap().render();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @protected
|
|
||||||
*/
|
|
||||||
ol.renderer.Map.prototype.handleViewChanged = function() {
|
|
||||||
if (!goog.isNull(this.viewPropertyListenerKey_)) {
|
|
||||||
goog.events.unlistenByKey(this.viewPropertyListenerKey_);
|
|
||||||
this.viewPropertyListenerKey_ = null;
|
|
||||||
}
|
|
||||||
var view = this.getMap().getView();
|
|
||||||
if (goog.isDefAndNotNull(view)) {
|
|
||||||
this.viewPropertyListenerKey_ = goog.events.listen(
|
|
||||||
view, ol.ObjectEventType.CHANGED,
|
|
||||||
this.handleViewPropertyChanged, false, this);
|
|
||||||
}
|
|
||||||
this.getMap().render();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.layer.Layer} layer Layer.
|
* @param {ol.layer.Layer} layer Layer.
|
||||||
* @protected
|
* @protected
|
||||||
|
|||||||
@@ -409,14 +409,6 @@ ol.renderer.webgl.Map.prototype.getShader = function(shaderObject) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritDoc
|
|
||||||
*/
|
|
||||||
ol.renderer.webgl.Map.prototype.handleBackgroundColorChanged = function() {
|
|
||||||
this.getMap().render();
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {goog.events.Event} event Event.
|
* @param {goog.events.Event} event Event.
|
||||||
* @protected
|
* @protected
|
||||||
|
|||||||
Reference in New Issue
Block a user