@ohuoy/easymap 1.0.24 → 1.0.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{src/components/control → lib/mapbox-gl-draw/src}/extendMode/direct_select_rect.js +1 -1
- package/{src/components/control → lib/mapbox-gl-draw/src}/extendMode/simple_select_rect.js +1 -1
- package/lib/mapbox-gl-draw/src/lib/common_selectors.js +4 -0
- package/lib/mapbox-gl-draw/src/lib/geojson-area.js +92 -0
- package/lib/mapbox-gl-draw/src/lib/mouse_event_point.js +1 -1
- package/lib/mapbox-gl-draw/src/lib/point-geometry.js +314 -0
- package/lib/mapbox-gl-draw/src/lib/sort_features.js +1 -1
- package/package.json +1 -1
- package/src/components/control/DrawBar.js +3 -3
- package/src/components/control/constants.js +0 -101
- package/src/components/control/lib/common_selectors.js +0 -68
- package/src/components/control/lib/constrain_feature_movement.js +0 -83
- package/src/components/control/lib/create_midpoint.js +0 -35
- package/src/components/control/lib/create_supplementary_points.js +0 -83
- package/src/components/control/lib/create_vertex.js +0 -29
- package/src/components/control/lib/double_click_zoom.js +0 -18
- package/src/components/control/lib/euclidean_distance.js +0 -5
- package/src/components/control/lib/features_at.js +0 -48
- package/src/components/control/lib/get_features_and_set_cursor.js +0 -22
- package/src/components/control/lib/id.js +0 -7
- package/src/components/control/lib/index.js +0 -43
- package/src/components/control/lib/is_click.js +0 -18
- package/src/components/control/lib/is_event_at_coordinates.js +0 -6
- package/src/components/control/lib/is_tap.js +0 -15
- package/src/components/control/lib/map_event_to_bounding_box.js +0 -14
- package/src/components/control/lib/mode_handler.js +0 -116
- package/src/components/control/lib/mouse_event_point.js +0 -19
- package/src/components/control/lib/move_features.js +0 -33
- package/src/components/control/lib/sort_features.js +0 -38
- package/src/components/control/lib/string_set.js +0 -55
- package/src/components/control/lib/string_sets_are_equal.js +0 -4
- package/src/components/control/lib/theme.js +0 -153
- package/src/components/control/lib/to_dense_array.js +0 -11
- /package/{src/components/control → lib/mapbox-gl-draw/src}/extendMode/rectmode.js +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import MapboxDraw from "
|
|
1
|
+
import MapboxDraw from "../../index.js";
|
|
2
2
|
import * as CommonSelectors from "../lib/common_selectors.js";
|
|
3
3
|
import constrainFeatureMovement from '../lib/constrain_feature_movement.js';
|
|
4
4
|
import * as Constants from '../constants.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import MapboxDraw from "
|
|
1
|
+
import MapboxDraw from ".././../index.js";
|
|
2
2
|
import * as CommonSelectors from "../lib/common_selectors.js";
|
|
3
3
|
import * as Constants from '../constants.js';
|
|
4
4
|
//import createSupplementaryPoints from '@mapbox/mapbox-gl-draw/src/lib/create_supplementary_points.js'
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// var wgs84 = require('wgs84');
|
|
2
|
+
import wgs84 from 'wgs84'
|
|
3
|
+
|
|
4
|
+
// module.exports.geometry = geometry;
|
|
5
|
+
// module.exports.ring = ringArea;
|
|
6
|
+
|
|
7
|
+
export function geometry(_) {
|
|
8
|
+
var area = 0, i;
|
|
9
|
+
switch (_.type) {
|
|
10
|
+
case 'Polygon':
|
|
11
|
+
return polygonArea(_.coordinates);
|
|
12
|
+
case 'MultiPolygon':
|
|
13
|
+
for (i = 0; i < _.coordinates.length; i++) {
|
|
14
|
+
area += polygonArea(_.coordinates[i]);
|
|
15
|
+
}
|
|
16
|
+
return area;
|
|
17
|
+
case 'Point':
|
|
18
|
+
case 'MultiPoint':
|
|
19
|
+
case 'LineString':
|
|
20
|
+
case 'MultiLineString':
|
|
21
|
+
return 0;
|
|
22
|
+
case 'GeometryCollection':
|
|
23
|
+
for (i = 0; i < _.geometries.length; i++) {
|
|
24
|
+
area += geometry(_.geometries[i]);
|
|
25
|
+
}
|
|
26
|
+
return area;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function polygonArea(coords) {
|
|
31
|
+
var area = 0;
|
|
32
|
+
if (coords && coords.length > 0) {
|
|
33
|
+
area += Math.abs(ringArea(coords[0]));
|
|
34
|
+
for (var i = 1; i < coords.length; i++) {
|
|
35
|
+
area -= Math.abs(ringArea(coords[i]));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return area;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Calculate the approximate area of the polygon were it projected onto
|
|
43
|
+
* the earth. Note that this area will be positive if ring is oriented
|
|
44
|
+
* clockwise, otherwise it will be negative.
|
|
45
|
+
*
|
|
46
|
+
* Reference:
|
|
47
|
+
* Robert. G. Chamberlain and William H. Duquette, "Some Algorithms for
|
|
48
|
+
* Polygons on a Sphere", JPL Publication 07-03, Jet Propulsion
|
|
49
|
+
* Laboratory, Pasadena, CA, June 2007 http://trs-new.jpl.nasa.gov/dspace/handle/2014/40409
|
|
50
|
+
*
|
|
51
|
+
* Returns:
|
|
52
|
+
* {float} The approximate signed geodesic area of the polygon in square
|
|
53
|
+
* meters.
|
|
54
|
+
*/
|
|
55
|
+
|
|
56
|
+
function ringArea(coords) {
|
|
57
|
+
var p1, p2, p3, lowerIndex, middleIndex, upperIndex, i,
|
|
58
|
+
area = 0,
|
|
59
|
+
coordsLength = coords.length;
|
|
60
|
+
|
|
61
|
+
if (coordsLength > 2) {
|
|
62
|
+
for (i = 0; i < coordsLength; i++) {
|
|
63
|
+
if (i === coordsLength - 2) {// i = N-2
|
|
64
|
+
lowerIndex = coordsLength - 2;
|
|
65
|
+
middleIndex = coordsLength -1;
|
|
66
|
+
upperIndex = 0;
|
|
67
|
+
} else if (i === coordsLength - 1) {// i = N-1
|
|
68
|
+
lowerIndex = coordsLength - 1;
|
|
69
|
+
middleIndex = 0;
|
|
70
|
+
upperIndex = 1;
|
|
71
|
+
} else { // i = 0 to N-3
|
|
72
|
+
lowerIndex = i;
|
|
73
|
+
middleIndex = i+1;
|
|
74
|
+
upperIndex = i+2;
|
|
75
|
+
}
|
|
76
|
+
p1 = coords[lowerIndex];
|
|
77
|
+
p2 = coords[middleIndex];
|
|
78
|
+
p3 = coords[upperIndex];
|
|
79
|
+
area += ( rad(p3[0]) - rad(p1[0]) ) * Math.sin( rad(p2[1]));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
area = area * wgs84.RADIUS * wgs84.RADIUS / 2;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return area;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function rad(_) {
|
|
89
|
+
return _ * Math.PI / 180;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export const ring = ringArea;
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// module.exports = Point;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A standalone point geometry with useful accessor, comparison, and
|
|
7
|
+
* modification methods.
|
|
8
|
+
*
|
|
9
|
+
* @class Point
|
|
10
|
+
* @param {Number} x the x-coordinate. this could be longitude or screen
|
|
11
|
+
* pixels, or any other sort of unit.
|
|
12
|
+
* @param {Number} y the y-coordinate. this could be latitude or screen
|
|
13
|
+
* pixels, or any other sort of unit.
|
|
14
|
+
* @example
|
|
15
|
+
* var point = new Point(-77, 38);
|
|
16
|
+
*/
|
|
17
|
+
function Point(x, y) {
|
|
18
|
+
this.x = x;
|
|
19
|
+
this.y = y;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
Point.prototype = {
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Clone this point, returning a new point that can be modified
|
|
26
|
+
* without affecting the old one.
|
|
27
|
+
* @return {Point} the clone
|
|
28
|
+
*/
|
|
29
|
+
clone: function() { return new Point(this.x, this.y); },
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Add this point's x & y coordinates to another point,
|
|
33
|
+
* yielding a new point.
|
|
34
|
+
* @param {Point} p the other point
|
|
35
|
+
* @return {Point} output point
|
|
36
|
+
*/
|
|
37
|
+
add: function(p) { return this.clone()._add(p); },
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Subtract this point's x & y coordinates to from point,
|
|
41
|
+
* yielding a new point.
|
|
42
|
+
* @param {Point} p the other point
|
|
43
|
+
* @return {Point} output point
|
|
44
|
+
*/
|
|
45
|
+
sub: function(p) { return this.clone()._sub(p); },
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Multiply this point's x & y coordinates by point,
|
|
49
|
+
* yielding a new point.
|
|
50
|
+
* @param {Point} p the other point
|
|
51
|
+
* @return {Point} output point
|
|
52
|
+
*/
|
|
53
|
+
multByPoint: function(p) { return this.clone()._multByPoint(p); },
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Divide this point's x & y coordinates by point,
|
|
57
|
+
* yielding a new point.
|
|
58
|
+
* @param {Point} p the other point
|
|
59
|
+
* @return {Point} output point
|
|
60
|
+
*/
|
|
61
|
+
divByPoint: function(p) { return this.clone()._divByPoint(p); },
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Multiply this point's x & y coordinates by a factor,
|
|
65
|
+
* yielding a new point.
|
|
66
|
+
* @param {Point} k factor
|
|
67
|
+
* @return {Point} output point
|
|
68
|
+
*/
|
|
69
|
+
mult: function(k) { return this.clone()._mult(k); },
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Divide this point's x & y coordinates by a factor,
|
|
73
|
+
* yielding a new point.
|
|
74
|
+
* @param {Point} k factor
|
|
75
|
+
* @return {Point} output point
|
|
76
|
+
*/
|
|
77
|
+
div: function(k) { return this.clone()._div(k); },
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Rotate this point around the 0, 0 origin by an angle a,
|
|
81
|
+
* given in radians
|
|
82
|
+
* @param {Number} a angle to rotate around, in radians
|
|
83
|
+
* @return {Point} output point
|
|
84
|
+
*/
|
|
85
|
+
rotate: function(a) { return this.clone()._rotate(a); },
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Rotate this point around p point by an angle a,
|
|
89
|
+
* given in radians
|
|
90
|
+
* @param {Number} a angle to rotate around, in radians
|
|
91
|
+
* @param {Point} p Point to rotate around
|
|
92
|
+
* @return {Point} output point
|
|
93
|
+
*/
|
|
94
|
+
rotateAround: function(a,p) { return this.clone()._rotateAround(a,p); },
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Multiply this point by a 4x1 transformation matrix
|
|
98
|
+
* @param {Array<Number>} m transformation matrix
|
|
99
|
+
* @return {Point} output point
|
|
100
|
+
*/
|
|
101
|
+
matMult: function(m) { return this.clone()._matMult(m); },
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Calculate this point but as a unit vector from 0, 0, meaning
|
|
105
|
+
* that the distance from the resulting point to the 0, 0
|
|
106
|
+
* coordinate will be equal to 1 and the angle from the resulting
|
|
107
|
+
* point to the 0, 0 coordinate will be the same as before.
|
|
108
|
+
* @return {Point} unit vector point
|
|
109
|
+
*/
|
|
110
|
+
unit: function() { return this.clone()._unit(); },
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Compute a perpendicular point, where the new y coordinate
|
|
114
|
+
* is the old x coordinate and the new x coordinate is the old y
|
|
115
|
+
* coordinate multiplied by -1
|
|
116
|
+
* @return {Point} perpendicular point
|
|
117
|
+
*/
|
|
118
|
+
perp: function() { return this.clone()._perp(); },
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Return a version of this point with the x & y coordinates
|
|
122
|
+
* rounded to integers.
|
|
123
|
+
* @return {Point} rounded point
|
|
124
|
+
*/
|
|
125
|
+
round: function() { return this.clone()._round(); },
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Return the magitude of this point: this is the Euclidean
|
|
129
|
+
* distance from the 0, 0 coordinate to this point's x and y
|
|
130
|
+
* coordinates.
|
|
131
|
+
* @return {Number} magnitude
|
|
132
|
+
*/
|
|
133
|
+
mag: function() {
|
|
134
|
+
return Math.sqrt(this.x * this.x + this.y * this.y);
|
|
135
|
+
},
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Judge whether this point is equal to another point, returning
|
|
139
|
+
* true or false.
|
|
140
|
+
* @param {Point} other the other point
|
|
141
|
+
* @return {boolean} whether the points are equal
|
|
142
|
+
*/
|
|
143
|
+
equals: function(other) {
|
|
144
|
+
return this.x === other.x &&
|
|
145
|
+
this.y === other.y;
|
|
146
|
+
},
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Calculate the distance from this point to another point
|
|
150
|
+
* @param {Point} p the other point
|
|
151
|
+
* @return {Number} distance
|
|
152
|
+
*/
|
|
153
|
+
dist: function(p) {
|
|
154
|
+
return Math.sqrt(this.distSqr(p));
|
|
155
|
+
},
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Calculate the distance from this point to another point,
|
|
159
|
+
* without the square root step. Useful if you're comparing
|
|
160
|
+
* relative distances.
|
|
161
|
+
* @param {Point} p the other point
|
|
162
|
+
* @return {Number} distance
|
|
163
|
+
*/
|
|
164
|
+
distSqr: function(p) {
|
|
165
|
+
var dx = p.x - this.x,
|
|
166
|
+
dy = p.y - this.y;
|
|
167
|
+
return dx * dx + dy * dy;
|
|
168
|
+
},
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Get the angle from the 0, 0 coordinate to this point, in radians
|
|
172
|
+
* coordinates.
|
|
173
|
+
* @return {Number} angle
|
|
174
|
+
*/
|
|
175
|
+
angle: function() {
|
|
176
|
+
return Math.atan2(this.y, this.x);
|
|
177
|
+
},
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Get the angle from this point to another point, in radians
|
|
181
|
+
* @param {Point} b the other point
|
|
182
|
+
* @return {Number} angle
|
|
183
|
+
*/
|
|
184
|
+
angleTo: function(b) {
|
|
185
|
+
return Math.atan2(this.y - b.y, this.x - b.x);
|
|
186
|
+
},
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Get the angle between this point and another point, in radians
|
|
190
|
+
* @param {Point} b the other point
|
|
191
|
+
* @return {Number} angle
|
|
192
|
+
*/
|
|
193
|
+
angleWith: function(b) {
|
|
194
|
+
return this.angleWithSep(b.x, b.y);
|
|
195
|
+
},
|
|
196
|
+
|
|
197
|
+
/*
|
|
198
|
+
* Find the angle of the two vectors, solving the formula for
|
|
199
|
+
* the cross product a x b = |a||b|sin(θ) for θ.
|
|
200
|
+
* @param {Number} x the x-coordinate
|
|
201
|
+
* @param {Number} y the y-coordinate
|
|
202
|
+
* @return {Number} the angle in radians
|
|
203
|
+
*/
|
|
204
|
+
angleWithSep: function(x, y) {
|
|
205
|
+
return Math.atan2(
|
|
206
|
+
this.x * y - this.y * x,
|
|
207
|
+
this.x * x + this.y * y);
|
|
208
|
+
},
|
|
209
|
+
|
|
210
|
+
_matMult: function(m) {
|
|
211
|
+
var x = m[0] * this.x + m[1] * this.y,
|
|
212
|
+
y = m[2] * this.x + m[3] * this.y;
|
|
213
|
+
this.x = x;
|
|
214
|
+
this.y = y;
|
|
215
|
+
return this;
|
|
216
|
+
},
|
|
217
|
+
|
|
218
|
+
_add: function(p) {
|
|
219
|
+
this.x += p.x;
|
|
220
|
+
this.y += p.y;
|
|
221
|
+
return this;
|
|
222
|
+
},
|
|
223
|
+
|
|
224
|
+
_sub: function(p) {
|
|
225
|
+
this.x -= p.x;
|
|
226
|
+
this.y -= p.y;
|
|
227
|
+
return this;
|
|
228
|
+
},
|
|
229
|
+
|
|
230
|
+
_mult: function(k) {
|
|
231
|
+
this.x *= k;
|
|
232
|
+
this.y *= k;
|
|
233
|
+
return this;
|
|
234
|
+
},
|
|
235
|
+
|
|
236
|
+
_div: function(k) {
|
|
237
|
+
this.x /= k;
|
|
238
|
+
this.y /= k;
|
|
239
|
+
return this;
|
|
240
|
+
},
|
|
241
|
+
|
|
242
|
+
_multByPoint: function(p) {
|
|
243
|
+
this.x *= p.x;
|
|
244
|
+
this.y *= p.y;
|
|
245
|
+
return this;
|
|
246
|
+
},
|
|
247
|
+
|
|
248
|
+
_divByPoint: function(p) {
|
|
249
|
+
this.x /= p.x;
|
|
250
|
+
this.y /= p.y;
|
|
251
|
+
return this;
|
|
252
|
+
},
|
|
253
|
+
|
|
254
|
+
_unit: function() {
|
|
255
|
+
this._div(this.mag());
|
|
256
|
+
return this;
|
|
257
|
+
},
|
|
258
|
+
|
|
259
|
+
_perp: function() {
|
|
260
|
+
var y = this.y;
|
|
261
|
+
this.y = this.x;
|
|
262
|
+
this.x = -y;
|
|
263
|
+
return this;
|
|
264
|
+
},
|
|
265
|
+
|
|
266
|
+
_rotate: function(angle) {
|
|
267
|
+
var cos = Math.cos(angle),
|
|
268
|
+
sin = Math.sin(angle),
|
|
269
|
+
x = cos * this.x - sin * this.y,
|
|
270
|
+
y = sin * this.x + cos * this.y;
|
|
271
|
+
this.x = x;
|
|
272
|
+
this.y = y;
|
|
273
|
+
return this;
|
|
274
|
+
},
|
|
275
|
+
|
|
276
|
+
_rotateAround: function(angle, p) {
|
|
277
|
+
var cos = Math.cos(angle),
|
|
278
|
+
sin = Math.sin(angle),
|
|
279
|
+
x = p.x + cos * (this.x - p.x) - sin * (this.y - p.y),
|
|
280
|
+
y = p.y + sin * (this.x - p.x) + cos * (this.y - p.y);
|
|
281
|
+
this.x = x;
|
|
282
|
+
this.y = y;
|
|
283
|
+
return this;
|
|
284
|
+
},
|
|
285
|
+
|
|
286
|
+
_round: function() {
|
|
287
|
+
this.x = Math.round(this.x);
|
|
288
|
+
this.y = Math.round(this.y);
|
|
289
|
+
return this;
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Construct a point from an array if necessary, otherwise if the input
|
|
295
|
+
* is already a Point, or an unknown type, return it unchanged
|
|
296
|
+
* @param {Array<Number>|Point|*} a any kind of input value
|
|
297
|
+
* @return {Point} constructed point, or passed-through value.
|
|
298
|
+
* @example
|
|
299
|
+
* // this
|
|
300
|
+
* var point = Point.convert([0, 1]);
|
|
301
|
+
* // is equivalent to
|
|
302
|
+
* var point = new Point(0, 1);
|
|
303
|
+
*/
|
|
304
|
+
Point.convert = function (a) {
|
|
305
|
+
if (a instanceof Point) {
|
|
306
|
+
return a;
|
|
307
|
+
}
|
|
308
|
+
if (Array.isArray(a)) {
|
|
309
|
+
return new Point(a[0], a[1]);
|
|
310
|
+
}
|
|
311
|
+
return a;
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
export default Point;
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
|
|
2
2
|
import MapboxDraw from "../../../lib/mapbox-gl-draw";
|
|
3
|
-
import rect from '
|
|
3
|
+
import rect from '../../../lib/mapbox-gl-draw/src/extendMode/rectmode'
|
|
4
4
|
import ExtendControlList from './ExtendControlList.js'
|
|
5
|
-
import simple_select_rect from "
|
|
6
|
-
import direct_select_rect from "
|
|
5
|
+
import simple_select_rect from "../../../lib/mapbox-gl-draw/src/extendMode/simple_select_rect.js";
|
|
6
|
+
import direct_select_rect from "../../../lib/mapbox-gl-draw/src/extendMode/direct_select_rect.js";
|
|
7
7
|
export default class DrawBar {
|
|
8
8
|
drawEntity = null
|
|
9
9
|
drawing = false
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
export const classes = {
|
|
2
|
-
CANVAS: 'mapboxgl-canvas',
|
|
3
|
-
CONTROL_BASE: 'mapboxgl-ctrl',
|
|
4
|
-
CONTROL_PREFIX: 'mapboxgl-ctrl-',
|
|
5
|
-
CONTROL_BUTTON: 'mapbox-gl-draw_ctrl-draw-btn',
|
|
6
|
-
CONTROL_BUTTON_LINE: 'mapbox-gl-draw_line',
|
|
7
|
-
CONTROL_BUTTON_POLYGON: 'mapbox-gl-draw_polygon',
|
|
8
|
-
CONTROL_BUTTON_POINT: 'mapbox-gl-draw_point',
|
|
9
|
-
CONTROL_BUTTON_TRASH: 'mapbox-gl-draw_trash',
|
|
10
|
-
CONTROL_BUTTON_COMBINE_FEATURES: 'mapbox-gl-draw_combine',
|
|
11
|
-
CONTROL_BUTTON_UNCOMBINE_FEATURES: 'mapbox-gl-draw_uncombine',
|
|
12
|
-
CONTROL_GROUP: 'mapboxgl-ctrl-group',
|
|
13
|
-
ATTRIBUTION: 'mapboxgl-ctrl-attrib',
|
|
14
|
-
ACTIVE_BUTTON: 'active',
|
|
15
|
-
BOX_SELECT: 'mapbox-gl-draw_boxselect'
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export const sources = {
|
|
19
|
-
HOT: 'mapbox-gl-draw-hot',
|
|
20
|
-
COLD: 'mapbox-gl-draw-cold'
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export const cursors = {
|
|
24
|
-
ADD: 'add',
|
|
25
|
-
MOVE: 'move',
|
|
26
|
-
DRAG: 'drag',
|
|
27
|
-
POINTER: 'pointer',
|
|
28
|
-
NONE: 'none'
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export const types = {
|
|
32
|
-
POLYGON: 'polygon',
|
|
33
|
-
LINE: 'line_string',
|
|
34
|
-
POINT: 'point'
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export const geojsonTypes = {
|
|
38
|
-
FEATURE: 'Feature',
|
|
39
|
-
POLYGON: 'Polygon',
|
|
40
|
-
LINE_STRING: 'LineString',
|
|
41
|
-
POINT: 'Point',
|
|
42
|
-
FEATURE_COLLECTION: 'FeatureCollection',
|
|
43
|
-
MULTI_PREFIX: 'Multi',
|
|
44
|
-
MULTI_POINT: 'MultiPoint',
|
|
45
|
-
MULTI_LINE_STRING: 'MultiLineString',
|
|
46
|
-
MULTI_POLYGON: 'MultiPolygon'
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export const modes = {
|
|
50
|
-
DRAW_LINE_STRING: 'draw_line_string',
|
|
51
|
-
DRAW_POLYGON: 'draw_polygon',
|
|
52
|
-
DRAW_POINT: 'draw_point',
|
|
53
|
-
SIMPLE_SELECT: 'simple_select',
|
|
54
|
-
DIRECT_SELECT: 'direct_select'
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
export const events = {
|
|
58
|
-
CREATE: 'draw.create',
|
|
59
|
-
DELETE: 'draw.delete',
|
|
60
|
-
UPDATE: 'draw.update',
|
|
61
|
-
SELECTION_CHANGE: 'draw.selectionchange',
|
|
62
|
-
MODE_CHANGE: 'draw.modechange',
|
|
63
|
-
ACTIONABLE: 'draw.actionable',
|
|
64
|
-
RENDER: 'draw.render',
|
|
65
|
-
COMBINE_FEATURES: 'draw.combine',
|
|
66
|
-
UNCOMBINE_FEATURES: 'draw.uncombine'
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
export const updateActions = {
|
|
70
|
-
MOVE: 'move',
|
|
71
|
-
CHANGE_PROPERTIES: 'change_properties',
|
|
72
|
-
CHANGE_COORDINATES: 'change_coordinates'
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
export const meta = {
|
|
76
|
-
FEATURE: 'feature',
|
|
77
|
-
MIDPOINT: 'midpoint',
|
|
78
|
-
VERTEX: 'vertex'
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
export const activeStates = {
|
|
82
|
-
ACTIVE: 'true',
|
|
83
|
-
INACTIVE: 'false'
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
export const interactions = [
|
|
87
|
-
'scrollZoom',
|
|
88
|
-
'boxZoom',
|
|
89
|
-
'dragRotate',
|
|
90
|
-
'dragPan',
|
|
91
|
-
'keyboard',
|
|
92
|
-
'doubleClickZoom',
|
|
93
|
-
'touchZoomRotate'
|
|
94
|
-
];
|
|
95
|
-
|
|
96
|
-
export const LAT_MIN = -90;
|
|
97
|
-
export const LAT_RENDERED_MIN = -85;
|
|
98
|
-
export const LAT_MAX = 90;
|
|
99
|
-
export const LAT_RENDERED_MAX = 85;
|
|
100
|
-
export const LNG_MIN = -270;
|
|
101
|
-
export const LNG_MAX = 270;
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import * as Constants from '../constants.js';
|
|
2
|
-
|
|
3
|
-
export function isOfMetaType(type) {
|
|
4
|
-
return function(e) {
|
|
5
|
-
const featureTarget = e.featureTarget;
|
|
6
|
-
if (!featureTarget) return false;
|
|
7
|
-
if (!featureTarget.properties) return false;
|
|
8
|
-
return featureTarget.properties.meta === type;
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function isShiftMousedown(e) {
|
|
13
|
-
if (!e.originalEvent) return false;
|
|
14
|
-
if (!e.originalEvent.shiftKey) return false;
|
|
15
|
-
return e.originalEvent.button === 0;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export function isActiveFeature(e) {
|
|
19
|
-
if (!e.featureTarget) return false;
|
|
20
|
-
if (!e.featureTarget.properties) return false;
|
|
21
|
-
return e.featureTarget.properties.active === Constants.activeStates.ACTIVE &&
|
|
22
|
-
e.featureTarget.properties.meta === Constants.meta.FEATURE;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function isInactiveFeature(e) {
|
|
26
|
-
if (!e.featureTarget) return false;
|
|
27
|
-
if (!e.featureTarget.properties) return false;
|
|
28
|
-
return e.featureTarget.properties.active === Constants.activeStates.INACTIVE &&
|
|
29
|
-
e.featureTarget.properties.meta === Constants.meta.FEATURE;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function noTarget(e) {
|
|
33
|
-
return e.featureTarget === undefined;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export function isFeature(e) {
|
|
37
|
-
if (!e.featureTarget) return false;
|
|
38
|
-
if (!e.featureTarget.properties) return false;
|
|
39
|
-
return e.featureTarget.properties.meta === Constants.meta.FEATURE;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export function isVertex(e) {
|
|
43
|
-
const featureTarget = e.featureTarget;
|
|
44
|
-
if (!featureTarget) return false;
|
|
45
|
-
if (!featureTarget.properties) return false;
|
|
46
|
-
return featureTarget.properties.meta === Constants.meta.VERTEX;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export function isShiftDown(e) {
|
|
50
|
-
if (!e.originalEvent) return false;
|
|
51
|
-
return e.originalEvent.shiftKey === true;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export function isEscapeKey(e) {
|
|
55
|
-
return e.keyCode === 27;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export function isRKey(e) {
|
|
59
|
-
return e.keyCode === 82;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export function isEnterKey(e) {
|
|
63
|
-
return e.keyCode === 13;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export function isTrue() {
|
|
67
|
-
return true;
|
|
68
|
-
}
|