Adding selection layer and implementing basic click selection

This commit is contained in:
ahocevar
2013-08-09 20:11:33 +02:00
parent e2526621d1
commit 871388d2c0
4 changed files with 91 additions and 7 deletions
+38 -2
View File
@@ -201,6 +201,16 @@ ol.layer.FeatureCache.prototype.getFeaturesByIds_ = function(ids) {
};
/**
* @param {string} uid Feature uid.
* @return {ol.Feature|undefined} The feature with the provided uid if it is in
* the cache, otherwise undefined.
*/
ol.layer.FeatureCache.prototype.getFeatureWithUid = function(uid) {
return this.idLookup_[uid];
};
/**
* Remove a feature from the cache.
* @param {ol.Feature} feature Feature.
@@ -287,6 +297,11 @@ ol.layer.Vector = function(options) {
*/
this.polygonVertices_ = new ol.geom.SharedVertices();
/**
* @type {boolean} Whether this is a temporary layer
*/
this.temp = goog.isDef(options.temp) ? options.temp : false;
};
goog.inherits(ol.layer.Vector, ol.layer.Layer);
@@ -313,6 +328,17 @@ ol.layer.Vector.prototype.addFeatures = function(features) {
};
/**
* Remove all features from the layer.
*/
ol.layer.Vector.prototype.clear = function() {
this.featureCache_.clear();
this.dispatchEvent(/** @type {ol.layer.VectorLayerEventObject} */ ({
type: goog.events.EventType.CHANGE
}));
};
/**
* @return {ol.source.Vector} Source.
*/
@@ -426,6 +452,16 @@ ol.layer.Vector.prototype.groupFeaturesBySymbolizerLiteral =
};
/**
* @param {string|number} uid Feature uid.
* @return {ol.Feature|undefined} The feature with the provided uid if it is on
* the layer, otherwise undefined.
*/
ol.layer.Vector.prototype.getFeatureWithUid = function(uid) {
return this.featureCache_.getFeatureWithUid(/** @type {string} */ (uid));
};
/**
* @param {Object|Element|Document|string} data Feature data.
* @param {ol.parser.Parser} parser Feature parser.
@@ -537,7 +573,7 @@ ol.layer.Vector.prototype.removeFeatures = function(features) {
* @return {string} Feature info.
*/
ol.layer.Vector.uidTransformFeatureInfo = function(features) {
var featureIds = goog.array.map(features,
var uids = goog.array.map(features,
function(feature) { return goog.getUid(feature); });
return featureIds.join(', ');
return uids.join(', ');
};