Merge pull request #6801 from ahocevar/renderfeature-getid
Add getId method for ol.render.Feature
This commit is contained in:
@@ -44,9 +44,9 @@ ol.format.MVT = function(opt_options) {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {function((ol.geom.Geometry|Object.<string, *>)=)|
|
||||
* @type {function((ol.geom.Geometry|Object.<string,*>)=)|
|
||||
* function(ol.geom.GeometryType,Array.<number>,
|
||||
* (Array.<number>|Array.<Array.<number>>),Object.<string, *>)}
|
||||
* (Array.<number>|Array.<Array.<number>>),Object.<string,*>,number)}
|
||||
*/
|
||||
this.featureClass_ = options.featureClass ?
|
||||
options.featureClass : ol.render.Feature;
|
||||
@@ -137,8 +137,9 @@ ol.format.MVT.prototype.readRenderFeature_ = function(rawFeature, layer) {
|
||||
|
||||
var values = rawFeature.properties;
|
||||
values[this.layerName_] = layer;
|
||||
var id = rawFeature.id;
|
||||
|
||||
return new this.featureClass_(geometryType, flatCoordinates, ends, values);
|
||||
return new this.featureClass_(geometryType, flatCoordinates, ends, values, id);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -16,14 +16,21 @@ goog.require('ol.geom.GeometryType');
|
||||
* to be right-handed for polygons.
|
||||
* @param {Array.<number>|Array.<Array.<number>>} ends Ends or Endss.
|
||||
* @param {Object.<string, *>} properties Properties.
|
||||
* @param {number|string|undefined} id Feature id.
|
||||
*/
|
||||
ol.render.Feature = function(type, flatCoordinates, ends, properties) {
|
||||
ol.render.Feature = function(type, flatCoordinates, ends, properties, id) {
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.Extent|undefined}
|
||||
*/
|
||||
this.extent_;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {number|string|undefined}
|
||||
*/
|
||||
this.id_ = id;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.geom.GeometryType}
|
||||
@@ -85,6 +92,16 @@ ol.render.Feature.prototype.getExtent = function() {
|
||||
return this.extent_;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the feature identifier. This is a stable identifier for the feature and
|
||||
* is set when reading data from a remote source.
|
||||
* @return {number|string|undefined} Id.
|
||||
* @api
|
||||
*/
|
||||
ol.render.Feature.prototype.getId = function() {
|
||||
return this.id_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {Array.<number>} Flat coordinates.
|
||||
@@ -104,7 +121,6 @@ ol.render.Feature.prototype.getFlatCoordinates =
|
||||
/**
|
||||
* Get the feature for working with its geometry.
|
||||
* @return {ol.render.Feature} Feature.
|
||||
* @api
|
||||
*/
|
||||
ol.render.Feature.prototype.getGeometry = function() {
|
||||
return this;
|
||||
|
||||
Reference in New Issue
Block a user