geojs 1.12.7 → 1.12.9
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/.github/workflows/main.yml +1 -1
- package/CHANGELOG.md +42 -0
- package/geo.js +82 -47
- package/geo.lean.js +82 -47
- package/geo.lean.min.js +3 -3
- package/geo.min.js +3 -3
- package/package.json +1 -1
- package/src/annotation/lineAnnotation.js +2 -4
- package/src/annotation/polygonAnnotation.js +7 -7
- package/src/annotationLayer.js +46 -7
- package/src/event.js +7 -4
- package/src/fetchQueue.js +3 -3
- package/src/mapInteractor.js +1 -2
- package/src/quadFeature.js +4 -4
- package/src/registry.js +1 -2
- package/src/util/common.js +8 -8
package/package.json
CHANGED
|
@@ -42,8 +42,7 @@ var lineAnnotation = function (args) {
|
|
|
42
42
|
line: function (d) {
|
|
43
43
|
/* Return an array that has the same number of items as we have
|
|
44
44
|
* vertices. */
|
|
45
|
-
return Array
|
|
46
|
-
function () { return d; });
|
|
45
|
+
return Array(m_this.options('vertices').length).fill(d);
|
|
47
46
|
},
|
|
48
47
|
position: function (d, i) {
|
|
49
48
|
return m_this.options('vertices')[i];
|
|
@@ -53,8 +52,7 @@ var lineAnnotation = function (args) {
|
|
|
53
52
|
line: function (d) {
|
|
54
53
|
/* Return an array that has the same number of items as we have
|
|
55
54
|
* vertices. */
|
|
56
|
-
return Array
|
|
57
|
-
function () { return d; });
|
|
55
|
+
return Array(m_this.options('vertices').length).fill(d);
|
|
58
56
|
},
|
|
59
57
|
position: function (d, i) {
|
|
60
58
|
return m_this.options('vertices')[i];
|
|
@@ -43,7 +43,9 @@ var polygonAnnotation = function (args) {
|
|
|
43
43
|
return new polygonAnnotation(args);
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
var m_this = this;
|
|
47
|
+
|
|
48
|
+
args = util.deepMerge({
|
|
47
49
|
style: {
|
|
48
50
|
polygon: function (d) { return d.polygon; }
|
|
49
51
|
},
|
|
@@ -52,12 +54,11 @@ var polygonAnnotation = function (args) {
|
|
|
52
54
|
const coord = m_this._coordinates();
|
|
53
55
|
/* Return an array that has the same number of items as we have
|
|
54
56
|
* vertices. */
|
|
55
|
-
return Array
|
|
56
|
-
function () { return d; });
|
|
57
|
+
return Array((coord.outer || coord).length).fill(d);
|
|
57
58
|
},
|
|
58
59
|
position: function (d, i) {
|
|
59
60
|
if (d.x !== undefined) {
|
|
60
|
-
return d
|
|
61
|
+
return d;
|
|
61
62
|
}
|
|
62
63
|
return m_this.options('vertices')[i];
|
|
63
64
|
}
|
|
@@ -65,13 +66,12 @@ var polygonAnnotation = function (args) {
|
|
|
65
66
|
cursorStyle: {
|
|
66
67
|
position: util.identityFunction
|
|
67
68
|
}
|
|
68
|
-
}, args);
|
|
69
|
+
}, this.constructor.defaults, args);
|
|
69
70
|
args.vertices = args.vertices || args.coordinates || [];
|
|
70
71
|
delete args.coordinates;
|
|
71
72
|
annotation.call(this, 'polygon', args);
|
|
72
73
|
|
|
73
|
-
var
|
|
74
|
-
s_actions = this.actions,
|
|
74
|
+
var s_actions = this.actions,
|
|
75
75
|
s_state = this.state;
|
|
76
76
|
|
|
77
77
|
/**
|
package/src/annotationLayer.js
CHANGED
|
@@ -491,18 +491,22 @@ var annotationLayer = function (arg) {
|
|
|
491
491
|
* gcs, `null` to use the map gcs, or any other transform.
|
|
492
492
|
* @param {boolean} [update] If `false`, don't update the layer after adding
|
|
493
493
|
* the annotation.
|
|
494
|
+
* @param {boolean} [trigger] If `false`, do trigger add_before and add
|
|
495
|
+
* events.
|
|
494
496
|
* @returns {this} The current layer.
|
|
495
497
|
* @fires geo.event.annotation.add_before
|
|
496
498
|
* @fires geo.event.annotation.add
|
|
497
499
|
*/
|
|
498
|
-
this.addAnnotation = function (annotation, gcs, update) {
|
|
500
|
+
this.addAnnotation = function (annotation, gcs, update, trigger) {
|
|
499
501
|
if (m_annotationIds[annotation.id()] === undefined) {
|
|
500
502
|
while (m_this.annotationById(annotation.id())) {
|
|
501
503
|
annotation.newId();
|
|
502
504
|
}
|
|
503
|
-
|
|
504
|
-
annotation
|
|
505
|
-
|
|
505
|
+
if (trigger !== false) {
|
|
506
|
+
m_this.geoTrigger(geo_event.annotation.add_before, {
|
|
507
|
+
annotation: annotation
|
|
508
|
+
});
|
|
509
|
+
}
|
|
506
510
|
m_annotations.push(annotation);
|
|
507
511
|
m_annotationIds[annotation.id()] = annotation;
|
|
508
512
|
annotation.layer(m_this);
|
|
@@ -516,8 +520,43 @@ var annotationLayer = function (arg) {
|
|
|
516
520
|
m_this.modified();
|
|
517
521
|
m_this.draw();
|
|
518
522
|
}
|
|
523
|
+
if (trigger !== false) {
|
|
524
|
+
m_this.geoTrigger(geo_event.annotation.add, {
|
|
525
|
+
annotation: annotation
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
return m_this;
|
|
530
|
+
};
|
|
531
|
+
|
|
532
|
+
/**
|
|
533
|
+
* Add multiple annotations to the layer. The annotations could be in any
|
|
534
|
+
* state.
|
|
535
|
+
*
|
|
536
|
+
* @param {geo.annotation[]} annotations The annotations to add.
|
|
537
|
+
* @param {string|geo.transform|null} [gcs] `undefined` to use the interface
|
|
538
|
+
* gcs, `null` to use the map gcs, or any other transform.
|
|
539
|
+
* @param {boolean} [update] If `false`, don't update the layer after adding
|
|
540
|
+
* the annotation.
|
|
541
|
+
* @returns {this} The current layer.
|
|
542
|
+
* @fires geo.event.annotation.add_before
|
|
543
|
+
* @fires geo.event.annotation.add
|
|
544
|
+
*/
|
|
545
|
+
this.addMultipleAnnotations = function (annotations, gcs, update) {
|
|
546
|
+
const added = [];
|
|
547
|
+
m_this.geoTrigger(geo_event.annotation.add_before, {
|
|
548
|
+
annotations: annotations
|
|
549
|
+
});
|
|
550
|
+
for (let i = 0; i < annotations.length; i += 1) {
|
|
551
|
+
const annotation = annotations[i];
|
|
552
|
+
if (m_annotationIds[annotation.id()] === undefined) {
|
|
553
|
+
this.addAnnotation(annotation, gcs, update, false);
|
|
554
|
+
added.push(annotation);
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
if (added.length) {
|
|
519
558
|
m_this.geoTrigger(geo_event.annotation.add, {
|
|
520
|
-
|
|
559
|
+
annotations: added
|
|
521
560
|
});
|
|
522
561
|
}
|
|
523
562
|
return m_this;
|
|
@@ -536,7 +575,7 @@ var annotationLayer = function (arg) {
|
|
|
536
575
|
*/
|
|
537
576
|
this.removeAnnotation = function (annotation, update, pos) {
|
|
538
577
|
if (annotation.id && m_annotationIds[annotation.id()] !== undefined) {
|
|
539
|
-
pos =
|
|
578
|
+
pos = m_annotations.indexOf(annotation);
|
|
540
579
|
if (annotation === m_this.currentAnnotation) {
|
|
541
580
|
m_this.currentAnnotation = null;
|
|
542
581
|
}
|
|
@@ -815,7 +854,7 @@ var annotationLayer = function (arg) {
|
|
|
815
854
|
var type = (data.properties || {}).annotationType || feature.featureType,
|
|
816
855
|
options = Object.assign({}, data.properties || {}),
|
|
817
856
|
position, datagcs, i, existing;
|
|
818
|
-
if (
|
|
857
|
+
if (!annotationList.includes(type)) {
|
|
819
858
|
return;
|
|
820
859
|
}
|
|
821
860
|
options.style = options.style || {};
|
package/src/event.js
CHANGED
|
@@ -656,20 +656,23 @@ geo_event.camera.viewport = 'geo_camera_viewport';
|
|
|
656
656
|
geo_event.annotation = {};
|
|
657
657
|
|
|
658
658
|
/**
|
|
659
|
-
* Triggered when
|
|
659
|
+
* Triggered when or more multiple annotations have been added.
|
|
660
660
|
*
|
|
661
661
|
* @event geo.event.annotation.add
|
|
662
662
|
* @type {geo.event.base}
|
|
663
|
-
* @property {geo.annotation} annotation The annotation that was added.
|
|
663
|
+
* @property {geo.annotation} [annotation] The annotation that was added.
|
|
664
|
+
* @property {geo.annotation} [annotations] The annotations that were added.
|
|
664
665
|
*/
|
|
665
666
|
geo_event.annotation.add = 'geo_annotation_add';
|
|
666
667
|
|
|
667
668
|
/**
|
|
668
|
-
* Triggered when
|
|
669
|
+
* Triggered when one or multiple annotations are about to be added.
|
|
669
670
|
*
|
|
670
671
|
* @event geo.event.annotation.add_before
|
|
671
672
|
* @type {geo.event.base}
|
|
672
|
-
* @property {geo.annotation} annotation The annotation that will be added.
|
|
673
|
+
* @property {geo.annotation} [annotation] The annotation that will be added.
|
|
674
|
+
* @property {geo.annotation[]} [annotations] The annotations that will be
|
|
675
|
+
* added.
|
|
673
676
|
*/
|
|
674
677
|
geo_event.annotation.add_before = 'geo_annotation_add_before';
|
|
675
678
|
|
package/src/fetchQueue.js
CHANGED
|
@@ -144,7 +144,7 @@ var fetchQueue = function (options) {
|
|
|
144
144
|
*/
|
|
145
145
|
this.add = function (defer, callback, atEnd) {
|
|
146
146
|
if (defer.__fetchQueue) {
|
|
147
|
-
var pos =
|
|
147
|
+
var pos = m_this._queue.indexOf(defer);
|
|
148
148
|
if (pos >= 0) {
|
|
149
149
|
// m_this._queue.splice(pos, 1);
|
|
150
150
|
m_this._addToQueue(defer, atEnd, pos);
|
|
@@ -215,7 +215,7 @@ var fetchQueue = function (options) {
|
|
|
215
215
|
* @returns {number} -1 if not in the queue, or the position in the queue.
|
|
216
216
|
*/
|
|
217
217
|
this.get = function (defer) {
|
|
218
|
-
return
|
|
218
|
+
return m_this._queue.indexOf(defer);
|
|
219
219
|
};
|
|
220
220
|
|
|
221
221
|
/**
|
|
@@ -225,7 +225,7 @@ var fetchQueue = function (options) {
|
|
|
225
225
|
* @returns {boolean} `true` if the object was removed.
|
|
226
226
|
*/
|
|
227
227
|
this.remove = function (defer) {
|
|
228
|
-
var pos =
|
|
228
|
+
var pos = m_this._queue.indexOf(defer);
|
|
229
229
|
if (pos >= 0) {
|
|
230
230
|
m_this._queue.splice(pos, 1);
|
|
231
231
|
return true;
|
package/src/mapInteractor.js
CHANGED
|
@@ -1598,8 +1598,7 @@ var mapInteractor = function (args) {
|
|
|
1598
1598
|
clearState();
|
|
1599
1599
|
|
|
1600
1600
|
// if momentum is enabled, start the action here
|
|
1601
|
-
if (m_options.momentum.enabled &&
|
|
1602
|
-
$.inArray(oldAction, m_options.momentum.actions) >= 0) {
|
|
1601
|
+
if (m_options.momentum.enabled && m_options.momentum.actions.includes(oldAction)) {
|
|
1603
1602
|
var t = (new Date()).valueOf();
|
|
1604
1603
|
var dt = t - m_mouse.time + m_mouse.deltaTime;
|
|
1605
1604
|
if (t - m_mouse.time < m_options.momentum.stopTime) {
|
package/src/quadFeature.js
CHANGED
|
@@ -466,8 +466,8 @@ var quadFeature = function (arg) {
|
|
|
466
466
|
prev_onload = image.onload;
|
|
467
467
|
image.onload = function () {
|
|
468
468
|
if (previewColor !== undefined) {
|
|
469
|
-
if (
|
|
470
|
-
clrQuads.splice(
|
|
469
|
+
if (clrQuads.includes(quad)) {
|
|
470
|
+
clrQuads.splice(clrQuads.indexOf(quad), 1);
|
|
471
471
|
}
|
|
472
472
|
delete quadinfo.clrquad;
|
|
473
473
|
}
|
|
@@ -544,8 +544,8 @@ var quadFeature = function (arg) {
|
|
|
544
544
|
prev_onload = video.onloadeddata;
|
|
545
545
|
video.onloadeddata = function () {
|
|
546
546
|
if (previewColor !== undefined) {
|
|
547
|
-
if (
|
|
548
|
-
clrQuads.splice(
|
|
547
|
+
if (clrQuads.includes(quad)) {
|
|
548
|
+
clrQuads.splice(clrQuads.indexOf(quad), 1);
|
|
549
549
|
}
|
|
550
550
|
delete quadinfo.clrquad;
|
|
551
551
|
}
|
package/src/registry.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
var $ = require('jquery');
|
|
2
1
|
var geo_action = require('./action');
|
|
3
2
|
var util = require('./util/common');
|
|
4
3
|
|
|
@@ -460,7 +459,7 @@ registry.featuresForAnnotations = function (annotationList) {
|
|
|
460
459
|
features.push(feature);
|
|
461
460
|
} else {
|
|
462
461
|
annotationList[ann].forEach(function (state) {
|
|
463
|
-
if (
|
|
462
|
+
if (annotations[ann].features[feature].includes(state)) {
|
|
464
463
|
features.push(feature);
|
|
465
464
|
}
|
|
466
465
|
});
|
package/src/util/common.js
CHANGED
|
@@ -464,7 +464,7 @@ var util = {
|
|
|
464
464
|
do {
|
|
465
465
|
found = util.hasAction(actions, action, name, owner);
|
|
466
466
|
if (found) {
|
|
467
|
-
actions.splice(
|
|
467
|
+
actions.splice(actions.indexOf(found), 1);
|
|
468
468
|
removed += 1;
|
|
469
469
|
}
|
|
470
470
|
} while (found);
|
|
@@ -1010,16 +1010,16 @@ var util = {
|
|
|
1010
1010
|
continue;
|
|
1011
1011
|
}
|
|
1012
1012
|
const copy = source[key];
|
|
1013
|
-
if (copy && typeof copy === 'object' &&
|
|
1014
|
-
let
|
|
1013
|
+
if (copy && typeof copy === 'object' && (copy.constructor === Object || Array.isArray(copy))) {
|
|
1014
|
+
let value = target[key];
|
|
1015
1015
|
if (!Array.isArray(copy)) {
|
|
1016
|
-
if (typeof
|
|
1017
|
-
|
|
1016
|
+
if (typeof value !== 'object' || Array.isArray(value)) {
|
|
1017
|
+
value = {};
|
|
1018
1018
|
}
|
|
1019
|
-
} else if (!Array.isArray(
|
|
1020
|
-
|
|
1019
|
+
} else if (!Array.isArray(value)) {
|
|
1020
|
+
value = [];
|
|
1021
1021
|
}
|
|
1022
|
-
target[key] = util.deepMerge(
|
|
1022
|
+
target[key] = util.deepMerge(value, copy);
|
|
1023
1023
|
} else if (copy !== undefined) {
|
|
1024
1024
|
target[key] = copy;
|
|
1025
1025
|
}
|