@abi-software/flatmap-viewer 2.3.3-b.3 → 2.3.3-b.4
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/README.rst +1 -1
- package/package.json +1 -1
- package/src/flatmap-viewer.js +4 -5
- package/src/interactions.js +30 -30
package/README.rst
CHANGED
|
@@ -38,7 +38,7 @@ The map server endpoint is specified as ``MAP_ENDPOINT`` in ``src/main.js``. It
|
|
|
38
38
|
Package Installation
|
|
39
39
|
====================
|
|
40
40
|
|
|
41
|
-
* ``npm install @abi-software/flatmap-viewer@2.3.3-b.
|
|
41
|
+
* ``npm install @abi-software/flatmap-viewer@2.3.3-b.4``
|
|
42
42
|
|
|
43
43
|
Documentation
|
|
44
44
|
-------------
|
package/package.json
CHANGED
package/src/flatmap-viewer.js
CHANGED
|
@@ -1122,13 +1122,12 @@ class FlatMap
|
|
|
1122
1122
|
}
|
|
1123
1123
|
|
|
1124
1124
|
/**
|
|
1125
|
-
*
|
|
1125
|
+
* Select features and zoom the map to them.
|
|
1126
1126
|
*
|
|
1127
|
-
* @param {Array.<string>}
|
|
1127
|
+
* @param {Array.<string>} featureIds An array of feature identifiers
|
|
1128
1128
|
* @param {Object} [options]
|
|
1129
|
-
* @param {boolean} [options.
|
|
1130
|
-
* @param {
|
|
1131
|
-
* @param {number} [options.padding=100] Padding around the composite bounding box
|
|
1129
|
+
* @param {boolean} [options.noZoomIn=false] Don't zoom in (although zoom out as necessary)
|
|
1130
|
+
* @param {number} [options.padding=10] Padding in pixels around the composite bounding box
|
|
1132
1131
|
*/
|
|
1133
1132
|
zoomToFeatures(externalIds, options=null)
|
|
1134
1133
|
//=======================================
|
package/src/interactions.js
CHANGED
|
@@ -580,16 +580,15 @@ export class UserInteractions
|
|
|
580
580
|
showSearchResults(featureIds)
|
|
581
581
|
//===========================
|
|
582
582
|
{
|
|
583
|
-
this.
|
|
583
|
+
this.unselectFeatures();
|
|
584
|
+
this.zoomToFeatures(featureIds, {noZoomIn: true});
|
|
584
585
|
}
|
|
585
586
|
|
|
586
587
|
/**
|
|
587
|
-
*
|
|
588
|
+
* Select features and zoom the map to them.
|
|
588
589
|
*
|
|
589
590
|
* @param {Array.<string>} featureIds An array of feature identifiers
|
|
590
591
|
* @param {Object} [options]
|
|
591
|
-
* @param {boolean} [options.select=true] Select the features zoomed to
|
|
592
|
-
* @param {boolean} [options.highlight=false] Highlight the features zoomed to
|
|
593
592
|
* @param {boolean} [options.noZoomIn=false] Don't zoom in (although zoom out as necessary)
|
|
594
593
|
* @param {number} [options.padding=10] Padding in pixels around the composite bounding box
|
|
595
594
|
*/
|
|
@@ -597,16 +596,11 @@ export class UserInteractions
|
|
|
597
596
|
//======================================
|
|
598
597
|
{
|
|
599
598
|
options = utils.setDefaults(options, {
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
false, noZoomIn:
|
|
603
|
-
false, padding:10
|
|
599
|
+
noZoomIn: false,
|
|
600
|
+
padding: 10
|
|
604
601
|
});
|
|
605
|
-
const select = (options.select === true);
|
|
606
|
-
const highlight = (options.highlight === true);
|
|
607
602
|
if (featureIds.length) {
|
|
608
|
-
this.
|
|
609
|
-
if (select) this.unselectFeatures();
|
|
603
|
+
this.unselectFeatures();
|
|
610
604
|
let bbox = null;
|
|
611
605
|
if (options.noZoomIn) {
|
|
612
606
|
const bounds = this._map.getBounds().toArray();
|
|
@@ -615,19 +609,11 @@ export class UserInteractions
|
|
|
615
609
|
for (const featureId of featureIds) {
|
|
616
610
|
const annotation = this._flatmap.annotation(featureId);
|
|
617
611
|
if (annotation) {
|
|
618
|
-
|
|
619
|
-
this.selectFeature(featureId);
|
|
620
|
-
} else if (highlight) {
|
|
621
|
-
this.highlightFeature_(featureId);
|
|
622
|
-
}
|
|
612
|
+
this.selectFeature(featureId);
|
|
623
613
|
bbox = expandBounds(bbox, annotation.bounds);
|
|
624
614
|
if ('type' in annotation && annotation.type.startsWith('line')) {
|
|
625
615
|
for (const pathFeatureId of this.__pathManager.lineFeatureIds([featureId])) {
|
|
626
|
-
|
|
627
|
-
this.selectFeature(pathFeatureId);
|
|
628
|
-
} else if (highlight) {
|
|
629
|
-
this.highlightFeature_(pathFeatureId);
|
|
630
|
-
}
|
|
616
|
+
this.selectFeature(pathFeatureId);
|
|
631
617
|
const pathAnnotation = this._flatmap.annotation(pathFeatureId)
|
|
632
618
|
bbox = expandBounds(bbox, pathAnnotation.bounds);
|
|
633
619
|
}
|
|
@@ -652,15 +638,24 @@ export class UserInteractions
|
|
|
652
638
|
// Remove any existing popup
|
|
653
639
|
|
|
654
640
|
if (this._currentPopup) {
|
|
641
|
+
if (options && options.preserveSelection) {
|
|
642
|
+
this._currentPopup.options.preserveSelection = options.preserveSelection;
|
|
643
|
+
}
|
|
655
644
|
this._currentPopup.remove();
|
|
656
645
|
}
|
|
657
646
|
|
|
658
|
-
if
|
|
659
|
-
|
|
647
|
+
// Clear selection if we are not preserving it
|
|
648
|
+
|
|
649
|
+
if (options && options.preserveSelection) {
|
|
650
|
+
delete options.preserveSelection; // Don't pass to onClose()
|
|
651
|
+
} else { // via the popup's options
|
|
660
652
|
this.unselectFeatures();
|
|
661
|
-
this.selectFeature(featureId);
|
|
662
653
|
}
|
|
663
654
|
|
|
655
|
+
// Select the feature
|
|
656
|
+
|
|
657
|
+
this.selectFeature(featureId);
|
|
658
|
+
|
|
664
659
|
// Find the pop-up's postion
|
|
665
660
|
|
|
666
661
|
let location = null;
|
|
@@ -680,7 +675,7 @@ export class UserInteractions
|
|
|
680
675
|
}
|
|
681
676
|
this.setModal_();
|
|
682
677
|
this._currentPopup = new maplibre.Popup(options).addTo(this._map);
|
|
683
|
-
this._currentPopup.on('close', this.
|
|
678
|
+
this._currentPopup.on('close', this.__onCloseCurrentPopup.bind(this));
|
|
684
679
|
this._currentPopup.setLngLat(location);
|
|
685
680
|
if (typeof content === 'object') {
|
|
686
681
|
this._currentPopup.setDOMContent(content);
|
|
@@ -690,11 +685,16 @@ export class UserInteractions
|
|
|
690
685
|
}
|
|
691
686
|
}
|
|
692
687
|
|
|
693
|
-
|
|
694
|
-
|
|
688
|
+
__onCloseCurrentPopup()
|
|
689
|
+
//=====================
|
|
695
690
|
{
|
|
696
|
-
this.
|
|
697
|
-
|
|
691
|
+
if (this._currentPopup) {
|
|
692
|
+
this.__clearModal();
|
|
693
|
+
if (!(this._currentPopup.options && this._currentPopup.options.preserveSelection)) {
|
|
694
|
+
this.unselectFeatures();
|
|
695
|
+
}
|
|
696
|
+
this._currentPopup = null;
|
|
697
|
+
}
|
|
698
698
|
}
|
|
699
699
|
|
|
700
700
|
removeTooltip_()
|