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
/
MergeFeature.js
65 lines (53 loc) · 1.92 KB
/
MergeFeature.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
64
65
/**
* @copyright 2011 geOps
* @license https://github.com/geops/ole/blob/master/license.txt
* @link https://github.com/geops/ole
*/
/**
* Class: OpenLayers.Editor.Control.MergeFeature
* ...
*
* Inherits from:
* - <OpenLayers.Control.Button>
*/
OpenLayers.Editor.Control.MergeFeature = OpenLayers.Class(OpenLayers.Control.Button, {
proxy: null,
title: OpenLayers.i18n('oleMergeFeature'),
/**
* Constructor: OpenLayers.Editor.Control.MergeFeature
* Create a new control for merging features.
*
* Parameters:
* layer - {<OpenLayers.Layer.Vector>}
* options - {Object} An optional object whose properties will be used
* to extend the control.
*/
initialize: function(layer, options) {
this.layer = layer;
OpenLayers.Control.Button.prototype.initialize.apply(this, [options]);
this.trigger = this.mergeFeature;
this.title = OpenLayers.i18n('oleMergeFeature');
this.displayClass = "oleControlDisabled " + this.displayClass;
},
/**
* Method: mergeFeature
*/
mergeFeature: function () {
if (this.layer.selectedFeatures.length < 2) {
this.map.editor.showStatus('error', OpenLayers.i18n('oleMergeFeatureSelectFeature'));
} else {
var wktFormat = new OpenLayers.Format.WKT(),
geo = wktFormat.write(this.layer.selectedFeatures);
this.map.editor.startWaiting(this.panel_div);
OpenLayers.Request.POST({
url: this.map.editor.oleUrl+'process/merge',
data: OpenLayers.Util.getParameterString({geo: geo}),
headers: {"Content-Type": "application/x-www-form-urlencoded"},
callback: this.map.editor.requestComplete,
proxy: this.proxy,
scope: this.map.editor
});
}
},
CLASS_NAME: "OpenLayers.Editor.Control.MergeFeature"
});