@@ -120,9 +120,9 @@ export var ThemeLayer = L.Layer.extend({
120120 } ,
121121
122122 /**
123- * @function ThemeLayer.prototype.addFeatures
124- * @description 添加数据 。
125- * @param {(ServerFeature|ThemeFeature| GeoJSONObject) } features - 待转换的要素 。
123+ * @function L.supermap. ThemeLayer.prototype.addFeatures
124+ * @description 向专题图图层中添加数据 。
125+ * @param {(Array.<SuperMap. ServerFeature>|Array.<L.supermap.themeFeature>|Array.< GeoJSONObject>|SuperMap.ServerFeature|L.supermap.themeFeature|GeoJSONObject ) } features - 待添加要素 。
126126 */
127127 addFeatures : function ( features ) { // eslint-disable-line no-unused-vars
128128 //子类实现此方法
@@ -140,7 +140,7 @@ export var ThemeLayer = L.Layer.extend({
140140 /**
141141 * @function ThemeLayer.prototype.destroyFeatures
142142 * @description 销毁要素。
143- * @param {Array.<FeatureVector> } features - 待销毁的要素 。
143+ * @param {Array.<FeatureVector>|FeatureVector } features - 将被销毁的要素 。
144144 */
145145 destroyFeatures : function ( features ) {
146146 if ( features === undefined ) {
@@ -150,6 +150,9 @@ export var ThemeLayer = L.Layer.extend({
150150 return ;
151151 }
152152 this . removeFeatures ( features ) ;
153+ if ( ! Array . isArray ( features ) ) {
154+ features = [ features ] ;
155+ }
153156 for ( var i = features . length - 1 ; i >= 0 ; i -- ) {
154157 features [ i ] . destroy ( ) ;
155158 }
@@ -158,7 +161,7 @@ export var ThemeLayer = L.Layer.extend({
158161 /**
159162 * @function L.supermap.ThemeLayer.prototype.removeFeatures
160163 * @description 从专题图中删除 feature。这个函数删除所有传递进来的矢量要素。
161- * @param {(Array.<SuperMap.Feature.Vector> |Function) } features - 将被删除的要素或用来过滤的回调函数。
164+ * @param {(Array.<FeatureVector>|FeatureVector |Function) } features - 将被删除的要素或用来过滤的回调函数。
162165 */
163166 removeFeatures : function ( features ) {
164167 var me = this ;
@@ -168,7 +171,7 @@ export var ThemeLayer = L.Layer.extend({
168171 if ( features === me . features ) {
169172 return me . removeAllFeatures ( ) ;
170173 }
171- if ( ! L . Util . isArray ( features ) && ! typeof features === 'function' ) {
174+ if ( ! L . Util . isArray ( features ) && ! ( typeof features === 'function' ) ) {
172175 features = [ features ] ;
173176 }
174177
@@ -211,10 +214,10 @@ export var ThemeLayer = L.Layer.extend({
211214
212215 var succeed = featuresFailRemoved . length == 0 ;
213216 /**
214- * @event ThemeLayer#featuresremoved
215- * @description 成功删除要素之后触发 。
216- * @property {Array.<FeatureVector> } features - 事件对象 。
217- * @property {boolean } succeed - 要素是否删除成功 ,true 为删除成功,false 为删除失败。
217+ * @event L.supermap. ThemeLayer#featuresremoved
218+ * @description 删除的要素成功之后触发 。
219+ * @property {Array.<FeatureVector> } features - 删除失败的要素数组 。
220+ * @property {boolean } succeed - 要输是否删除成功 ,true 为删除成功,false 为删除失败。
218221 */
219222 me . fire ( "featuresremoved" , {
220223 features : featuresFailRemoved ,
@@ -242,7 +245,7 @@ export var ThemeLayer = L.Layer.extend({
242245 * @function ThemeLayer.prototype.getFeatures
243246 * @description 查看当前图层中的有效数据。
244247 * @param {Function } [filter] - 根据条件过滤要素的回调函数。
245- * @returns {Array } 返回图层中的有效数据 。
248+ * @returns {Array.<FeatureVector> } 返回图层中的要素 。
246249 */
247250 getFeatures : function ( filter ) {
248251 var len = this . features . length ;
@@ -256,10 +259,11 @@ export var ThemeLayer = L.Layer.extend({
256259 } ,
257260
258261 /**
259- * @function ThemeLayer.prototype.getFeatureBy
260- * @description 过滤属性。
261- * @param {string } property - 过滤某个属性名。
262- * @param {string } value - 返回属性值。
262+ * @function L.supermap.ThemeLayer.prototype.getFeatureBy
263+ * @description 在专题图的要素数组 features 里面遍历每一个 feature,当 feature[property] === value 时,返回此 feature(并且只返回第一个)。
264+ * @param {string } property - 要的某个属性名。
265+ * @param {string } value - 对应属性名得值。
266+ * @returns {Array.<FeatureVector> } 返回图层中的要素。
263267 */
264268 getFeatureBy : function ( property , value ) {
265269 var me = this ;
@@ -278,17 +282,18 @@ export var ThemeLayer = L.Layer.extend({
278282 * @function ThemeLayer.prototype.getFeatureById
279283 * @description 返回指定 ID 的矢量要素,不存在则返回 null。
280284 * @param {number } featureId - 要素 ID。
285+ * @returns {Array.<FeatureVector> } 返回图层中的要素。
281286 */
282287 getFeatureById : function ( featureId ) {
283288 return this . getFeatureBy ( 'id' , featureId ) ;
284289 } ,
285290
286291 /**
287- * @function ThemeLayer.prototype.getFeaturesByAttribute
288- * @description 指定属性名和属性值 ,返回所有匹配的要素数组。
289- * @param {string } attrName - 属性名 。
290- * @param {string } attrValue - 属性值 。
291- * @returns {Array } 返回所有匹配的要素数组。
292+ * @function L.supermap. ThemeLayer.prototype.getFeaturesByAttribute
293+ * @description 通过给定一个属性的 key 值和 value 值 ,返回所有匹配的要素数组。
294+ * @param {string } attrName - key 值 。
295+ * @param {string } attrValue - value 值 。
296+ * @returns {Array.<FeatureVector> } 返回所有匹配的要素数组。
292297 */
293298 getFeaturesByAttribute : function ( attrName , attrValue ) {
294299 var me = this ,
@@ -456,7 +461,7 @@ export var ThemeLayer = L.Layer.extend({
456461 /**
457462 * @function ThemeLayer.prototype.toiClientFeature
458463 * @description 转为 iClient 要素。
459- * @param {(ServerFeature|ThemeFeature| GeoJSONObject) } features - 待转换的要素 。
464+ * @param {(Array.<SuperMap. ServerFeature>|Array.<L.supermap.themeFeature>|Array.< GeoJSONObject>|SuperMap.ServerFeature|L.supermap.themeFeature|GeoJSONObject ) } features - 待转要素 。
460465 * @returns {Array.<FeatureVector> } 转换后的 iClient 要素。
461466 */
462467 toiClientFeature : function ( features ) {
@@ -491,8 +496,8 @@ export var ThemeLayer = L.Layer.extend({
491496 /**
492497 * @function ThemeLayer.prototype.toFeature
493498 * @deprecated
494- * @description 转为 iClient 要素,该方法将被弃用,由 {@link ThemeLayer#toiClientFeature} 代替。
495- * @param {(ServerFeature|ThemeFeature| GeoJSONObject) } features - 待转换的要素 。
499+ * @description 转为 iClient 要素,该方法将被弃用,由 {@link L.supermap. ThemeLayer#toiClientFeature} 代替。
500+ * @param {(Array.<SuperMap. ServerFeature>|Array.<L.supermap.themeFeature>|Array.< GeoJSONObject>|SuperMap.ServerFeature|L.supermap.themeFeature|GeoJSONObject ) } features - 待转要素 。
496501 * @returns {FeatureVector } 转换后的 iClient 要素。
497502 */
498503 toFeature : function ( features ) {
0 commit comments