Add background color property
This commit is contained in:
@@ -2,6 +2,7 @@ goog.provide('ol.Map');
|
||||
goog.provide('ol.MapProperty');
|
||||
|
||||
goog.require('goog.array');
|
||||
goog.require('goog.color');
|
||||
goog.require('goog.dom.ViewportSizeMonitor');
|
||||
goog.require('goog.events');
|
||||
goog.require('goog.events.BrowserEvent');
|
||||
@@ -27,6 +28,7 @@ goog.require('ol.Projection');
|
||||
* @enum {string}
|
||||
*/
|
||||
ol.MapProperty = {
|
||||
BACKGROUND_COLOR: 'backgroundColor',
|
||||
CENTER: 'center',
|
||||
CONTROLS: 'controls',
|
||||
EXTENT: 'extent',
|
||||
@@ -131,6 +133,10 @@ ol.Map = function(target, opt_values, opt_viewportSizeMonitor) {
|
||||
goog.events.listen(this.viewportSizeMonitor_, goog.events.EventType.RESIZE,
|
||||
this.handleViewportResize, false, this);
|
||||
|
||||
goog.events.listen(this,
|
||||
ol.Object.getChangedEventType(ol.MapProperty.BACKGROUND_COLOR),
|
||||
this.handleBackgroundColorChanged, false, this);
|
||||
|
||||
goog.events.listen(
|
||||
this, ol.Object.getChangedEventType(ol.MapProperty.CENTER),
|
||||
this.handleCenterChanged, false, this);
|
||||
@@ -216,6 +222,15 @@ ol.Map.prototype.forEachVisibleLayer = function(f, opt_obj) {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {string|undefined} Background color.
|
||||
*/
|
||||
ol.Map.prototype.getBackgroundColor = function() {
|
||||
return /** @type {string|undefined} */ (
|
||||
this.get(ol.MapProperty.BACKGROUND_COLOR));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {goog.math.Coordinate|undefined} Center.
|
||||
*/
|
||||
@@ -341,6 +356,11 @@ ol.Map.prototype.getTarget = function() {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
ol.Map.prototype.handleBackgroundColorChanged = goog.nullFunction;
|
||||
|
||||
|
||||
/**
|
||||
* @param {goog.events.BrowserEvent} event Event.
|
||||
*/
|
||||
@@ -539,6 +559,15 @@ ol.Map.prototype.removeLayerRenderer = function(layer) {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {string} backgroundColor Background color.
|
||||
*/
|
||||
ol.Map.prototype.setBackgroundColor = function(backgroundColor) {
|
||||
goog.color.parse(backgroundColor);
|
||||
this.set(ol.MapProperty.BACKGROUND_COLOR, backgroundColor);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {goog.math.Coordinate} center Center.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user