This repository has been archived by the owner on Apr 5, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 75
/
DeleteAllFeatures.js
63 lines (51 loc) · 1.7 KB
/
DeleteAllFeatures.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/**
* @copyright 2011 geOps
* @author Just van den Broecke
* @license https://github.com/geops/ole/blob/master/license.txt
* @link https://github.com/geops/ole
*/
/**
* Class: OpenLayers.Editor.Control.DeleteAllFeatures
* The DeleteAllFeatures provides a button to delete all features
* from a given layer.
*
* Inherits from:
* - <OpenLayers.Control.Button>
*/
OpenLayers.Editor.Control.DeleteAllFeatures = OpenLayers.Class(OpenLayers.Control.Button, {
/**
* Property: layer
* {<OpenLayers.Layer.Vector>}
*/
layer: null,
title: OpenLayers.i18n('oleDeleteAllFeatures'),
/**
* Constructor: OpenLayers.Editor.Control.DeleteAllFeatures
* Create a new control for deleting all features from given layer.
*
* Parameters:
* layer - {<OpenLayers.Layer.Vector>} The layer from which selected
* features will be deleted.
* options - {Object} An optional object whose properties will be used
* to extend the control.
*/
initialize: function (layer, options) {
this.layer = layer;
this.title = OpenLayers.i18n('oleDeleteAllFeatures');
OpenLayers.Control.Button.prototype.initialize.apply(this, [options]);
this.trigger = this.deleteAllFeatures;
this.displayClass = "oleControlEnabled " + this.displayClass;
},
/**
* Method: deleteAllFeatures
*/
deleteAllFeatures: function () {
if (this.layer.features.length > 0) {
this.layer.destroyFeatures();
}
if (this.map.editor.editLayer) {
this.map.editor.editLayer.destroyFeatures();
}
},
CLASS_NAME: 'OpenLayers.Editor.Control.DeleteAllFeatures'
});