Add method for retrieving ol.Overlay by id
This commit is contained in:
@@ -19,6 +19,7 @@ goog.require('ol.extent');
|
||||
* @enum {string}
|
||||
*/
|
||||
ol.OverlayProperty = {
|
||||
ID: 'id',
|
||||
ELEMENT: 'element',
|
||||
MAP: 'map',
|
||||
OFFSET: 'offset',
|
||||
@@ -73,6 +74,12 @@ ol.Overlay = function(options) {
|
||||
|
||||
goog.base(this);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {number|string|undefined}
|
||||
*/
|
||||
this.id_ = undefined;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {boolean}
|
||||
@@ -187,6 +194,17 @@ ol.Overlay.prototype.getElement = function() {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the feature identifier. This is an identifier for the overlay and
|
||||
* is set explicitly by calling {@link ol.Overlay#setId}.
|
||||
* @return {number|string|undefined} Id.
|
||||
* @api
|
||||
*/
|
||||
ol.Overlay.prototype.getId = function() {
|
||||
return this.id_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the map associated with this overlay.
|
||||
* @return {ol.Map|undefined} The map that the overlay is part of.
|
||||
@@ -211,6 +229,15 @@ ol.Overlay.prototype.getOffset = function() {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Workaround to overcome circular dependency.
|
||||
* @return {ol.OverlayProperty}
|
||||
*/
|
||||
ol.Overlay.prototype.getOverlayIdProperty = function() {
|
||||
return ol.OverlayProperty.ID;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the current position of this overlay.
|
||||
* @return {ol.Coordinate|undefined} The spatial point that the overlay is
|
||||
@@ -321,6 +348,22 @@ ol.Overlay.prototype.setElement = function(element) {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Set the feature id. The feature id can be used with the
|
||||
* {@link ol.Map#getOverlayById} method.
|
||||
* @param {number|string} id The feature id.
|
||||
* @observable
|
||||
* @api
|
||||
*/
|
||||
ol.Overlay.prototype.setId = function(id) {
|
||||
goog.asserts.assert(id !== undefined, 'overlay id should be defined');
|
||||
if (id != this.id_) {
|
||||
this.id_ = id;
|
||||
this.set(ol.OverlayProperty.ID, id);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Set the map to be associated with this overlay.
|
||||
* @param {ol.Map|undefined} map The map that the overlay is part of.
|
||||
|
||||
Reference in New Issue
Block a user