@abi-software/flatmapvuer 1.14.0 → 1.14.1
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/package.json
CHANGED
|
@@ -1737,6 +1737,9 @@ export default {
|
|
|
1737
1737
|
provenanceTaxonomy: taxons,
|
|
1738
1738
|
alert: featuresAlert
|
|
1739
1739
|
}]
|
|
1740
|
+
if (eventType === 'mouseenter') {
|
|
1741
|
+
this.lastHoveredFeature = data;
|
|
1742
|
+
}
|
|
1740
1743
|
if (eventType === 'click') {
|
|
1741
1744
|
// If multiple paths overlap at the click location,
|
|
1742
1745
|
// `data` is an object with numeric keys for each feature (e.g., {0: {...}, 1: {...}, ..., mapUUID: '...'}).
|
|
@@ -1856,6 +1859,7 @@ export default {
|
|
|
1856
1859
|
// Fallback: remove any existing toolitp on DOM
|
|
1857
1860
|
const tooltips = this.$el.querySelectorAll('.flatmap-tooltip-popup');
|
|
1858
1861
|
tooltips.forEach((tooltip) => tooltip.remove());
|
|
1862
|
+
this.lastHoveredFeature = null;
|
|
1859
1863
|
},
|
|
1860
1864
|
/**
|
|
1861
1865
|
* Function to create tooltip for the provided connectivity data.
|
|
@@ -1899,6 +1903,9 @@ export default {
|
|
|
1899
1903
|
const connectivityData = [];
|
|
1900
1904
|
const errorData = [];
|
|
1901
1905
|
|
|
1906
|
+
// Remove last hovered feature to avoid showing tooltip for the last hovered feature.
|
|
1907
|
+
this.lastHoveredFeature = null;
|
|
1908
|
+
|
|
1902
1909
|
// to keep the highlighted path on map
|
|
1903
1910
|
if (connectivityInfo && connectivityInfo.featureId) {
|
|
1904
1911
|
featuresToHighlight.push(...connectivityInfo.featureId);
|
|
@@ -2302,6 +2309,7 @@ export default {
|
|
|
2302
2309
|
document.querySelectorAll('.maplibregl-popup').forEach((item) => {
|
|
2303
2310
|
item.style.display = 'none'
|
|
2304
2311
|
})
|
|
2312
|
+
this.lastHoveredFeature = null;
|
|
2305
2313
|
},
|
|
2306
2314
|
/**
|
|
2307
2315
|
* @public
|
|
@@ -3106,10 +3114,22 @@ export default {
|
|
|
3106
3114
|
provenanceTaxonomy: feature.taxons,
|
|
3107
3115
|
alert: normaliseAlertToStringArray(feature.alert),
|
|
3108
3116
|
}
|
|
3117
|
+
|
|
3109
3118
|
// Show popup for all modes
|
|
3110
3119
|
this.checkAndCreatePopups([data], mapclick)
|
|
3120
|
+
|
|
3121
|
+
// Check pathway fetures and set lastHoveredFeature for tooltip content replacement.
|
|
3122
|
+
const isPathwayFeature = (feature.id.startsWith('ilxtr:') || feature.id.startsWith('ilx:'));
|
|
3123
|
+
if (isPathwayFeature) {
|
|
3124
|
+
this.lastHoveredFeature = feature;
|
|
3125
|
+
this.lastHoveredFeature.mapUUID = this.mapImp.uuid;
|
|
3126
|
+
} else {
|
|
3127
|
+
this.lastHoveredFeature = null;
|
|
3128
|
+
}
|
|
3129
|
+
|
|
3130
|
+
// flatmap-tooltip-popup is used for custom tooltip content replacement.
|
|
3111
3131
|
this.mapImp.showPopup(featureId, capitalise(feature.label), {
|
|
3112
|
-
className: 'custom-popup',
|
|
3132
|
+
className: isPathwayFeature ? 'flatmap-tooltip-popup' : 'custom-popup',
|
|
3113
3133
|
positionAtLastClick: false,
|
|
3114
3134
|
preserveSelection: true,
|
|
3115
3135
|
})
|
|
@@ -3153,6 +3173,62 @@ export default {
|
|
|
3153
3173
|
setConnectionType: function (type) {
|
|
3154
3174
|
this.connectionType = type;
|
|
3155
3175
|
},
|
|
3176
|
+
/**
|
|
3177
|
+
* MutationObserver callback to intercept tooltip popup DOM elements
|
|
3178
|
+
* and customize their content before the browser renders them.
|
|
3179
|
+
*/
|
|
3180
|
+
_handleTooltipMutation: function (mutations) {
|
|
3181
|
+
for (const mutation of mutations) {
|
|
3182
|
+
for (const node of mutation.addedNodes) {
|
|
3183
|
+
if (node.nodeType === 1) {
|
|
3184
|
+
// Check if the added node itself is the tooltip popup
|
|
3185
|
+
if (node.matches && node.matches('.flatmap-tooltip-popup')) {
|
|
3186
|
+
this._applyCustomTooltipContent(node);
|
|
3187
|
+
} else if (node.querySelector) {
|
|
3188
|
+
// Check if it contains a tooltip popup
|
|
3189
|
+
const popup = node.querySelector('.flatmap-tooltip-popup');
|
|
3190
|
+
if (popup) {
|
|
3191
|
+
this._applyCustomTooltipContent(popup);
|
|
3192
|
+
}
|
|
3193
|
+
}
|
|
3194
|
+
}
|
|
3195
|
+
}
|
|
3196
|
+
}
|
|
3197
|
+
},
|
|
3198
|
+
/**
|
|
3199
|
+
* Replace the default tooltip content with custom content from
|
|
3200
|
+
* the tooltipContentProvider prop, if available.
|
|
3201
|
+
*/
|
|
3202
|
+
_applyCustomTooltipContent: function (popupEl) {
|
|
3203
|
+
if (!this.tooltipContentProvider || !this.lastHoveredFeature) return;
|
|
3204
|
+
try {
|
|
3205
|
+
const featureData = this.lastHoveredFeature;
|
|
3206
|
+
// Detect multi-feature data format used by click events when multiple
|
|
3207
|
+
// paths overlap: {0: {...}, 1: {...}, ..., mapUUID: '...'}
|
|
3208
|
+
const isMultiFeature = featureData[0] && typeof featureData[0] === 'object';
|
|
3209
|
+
let customHtml;
|
|
3210
|
+
if (isMultiFeature) {
|
|
3211
|
+
const features = [];
|
|
3212
|
+
const mapUUID = featureData.mapUUID;
|
|
3213
|
+
for (const [key, value] of Object.entries(featureData)) {
|
|
3214
|
+
if (key !== 'mapUUID' && value && typeof value === 'object') {
|
|
3215
|
+
features.push({ ...value, mapUUID });
|
|
3216
|
+
}
|
|
3217
|
+
}
|
|
3218
|
+
customHtml = this.tooltipContentProvider(features.length > 1 ? features : features[0]);
|
|
3219
|
+
} else {
|
|
3220
|
+
customHtml = this.tooltipContentProvider(featureData);
|
|
3221
|
+
}
|
|
3222
|
+
if (customHtml) {
|
|
3223
|
+
const contentEl = popupEl.querySelector('.maplibregl-popup-content');
|
|
3224
|
+
if (contentEl) {
|
|
3225
|
+
contentEl.innerHTML = customHtml;
|
|
3226
|
+
}
|
|
3227
|
+
}
|
|
3228
|
+
} catch (e) {
|
|
3229
|
+
console.warn('[flatmapvuer] Error in tooltipContentProvider:', e);
|
|
3230
|
+
}
|
|
3231
|
+
},
|
|
3156
3232
|
},
|
|
3157
3233
|
props: {
|
|
3158
3234
|
/**
|
|
@@ -3393,6 +3469,17 @@ export default {
|
|
|
3393
3469
|
return []
|
|
3394
3470
|
},
|
|
3395
3471
|
},
|
|
3472
|
+
/**
|
|
3473
|
+
* A function that provides custom tooltip HTML content for path features.
|
|
3474
|
+
* The function receives the feature data from the mouseenter event (including `id`, `label`, etc.)
|
|
3475
|
+
* and should return an HTML string to display in the tooltip, or return null/undefined
|
|
3476
|
+
* to keep the default tooltip.
|
|
3477
|
+
* This is used by mapintegratedvuer to show 'long-label' from connectivity knowledge.
|
|
3478
|
+
*/
|
|
3479
|
+
tooltipContentProvider: {
|
|
3480
|
+
type: Function,
|
|
3481
|
+
default: null,
|
|
3482
|
+
},
|
|
3396
3483
|
},
|
|
3397
3484
|
provide() {
|
|
3398
3485
|
return {
|
|
@@ -3495,6 +3582,8 @@ export default {
|
|
|
3495
3582
|
drawnCreatedEvent: {},
|
|
3496
3583
|
previousEditEvent: {},
|
|
3497
3584
|
previousDeletedEvent: {},
|
|
3585
|
+
lastHoveredFeature: null,
|
|
3586
|
+
tooltipObserver: null,
|
|
3498
3587
|
connectionEntry: {},
|
|
3499
3588
|
existDrawnFeatures: [], // Store all exist drawn features
|
|
3500
3589
|
doubleClickedFeature: false,
|
|
@@ -3693,6 +3782,27 @@ export default {
|
|
|
3693
3782
|
this.createFlatmap()
|
|
3694
3783
|
}
|
|
3695
3784
|
refreshFlatmapKnowledgeCache();
|
|
3785
|
+
|
|
3786
|
+
// Set up MutationObserver to customize tooltip content when
|
|
3787
|
+
// tooltipContentProvider prop is provided.
|
|
3788
|
+
if (this.tooltipContentProvider) {
|
|
3789
|
+
this.$nextTick(() => {
|
|
3790
|
+
const container = this.$refs.flatmapContainer || this.$el;
|
|
3791
|
+
if (container) {
|
|
3792
|
+
this.tooltipObserver = new MutationObserver(this._handleTooltipMutation.bind(this));
|
|
3793
|
+
this.tooltipObserver.observe(container, {
|
|
3794
|
+
childList: true,
|
|
3795
|
+
subtree: true,
|
|
3796
|
+
});
|
|
3797
|
+
}
|
|
3798
|
+
});
|
|
3799
|
+
}
|
|
3800
|
+
},
|
|
3801
|
+
beforeUnmount: function () {
|
|
3802
|
+
if (this.tooltipObserver) {
|
|
3803
|
+
this.tooltipObserver.disconnect();
|
|
3804
|
+
this.tooltipObserver = null;
|
|
3805
|
+
}
|
|
3696
3806
|
},
|
|
3697
3807
|
}
|
|
3698
3808
|
</script>
|
|
@@ -3855,6 +3965,9 @@ export default {
|
|
|
3855
3965
|
|
|
3856
3966
|
:deep(.flatmap-tooltip-popup),
|
|
3857
3967
|
:deep(.custom-popup) {
|
|
3968
|
+
font-family: Asap, sans-serif !important;
|
|
3969
|
+
font-size: 14px !important;
|
|
3970
|
+
|
|
3858
3971
|
&.maplibregl-popup-anchor-bottom {
|
|
3859
3972
|
.maplibregl-popup-content {
|
|
3860
3973
|
margin-bottom: 12px;
|
|
@@ -4449,4 +4562,23 @@ export default {
|
|
|
4449
4562
|
}
|
|
4450
4563
|
}
|
|
4451
4564
|
|
|
4565
|
+
.flatmap-feature-label {
|
|
4566
|
+
padding: 6px !important;
|
|
4567
|
+
font-family: Asap, sans-serif !important;
|
|
4568
|
+
font-size: 14px !important;
|
|
4569
|
+
|
|
4570
|
+
// provided by tooltipContentProvider from mapintegratedvuer
|
|
4571
|
+
&.flatmap-connectivity-label {
|
|
4572
|
+
text-align: left !important;
|
|
4573
|
+
}
|
|
4574
|
+
}
|
|
4575
|
+
|
|
4576
|
+
.id-tag {
|
|
4577
|
+
color: #444;
|
|
4578
|
+
background: #e0e0e0;
|
|
4579
|
+
padding: 2px 4px;
|
|
4580
|
+
border-radius: 4px;
|
|
4581
|
+
font-size: .75rem !important;
|
|
4582
|
+
letter-spacing: 1.05px;
|
|
4583
|
+
}
|
|
4452
4584
|
</style>
|
|
@@ -94,6 +94,7 @@
|
|
|
94
94
|
:showOpenMapButton="showOpenMapButton"
|
|
95
95
|
:showPathwayFilter="showPathwayFilter"
|
|
96
96
|
:externalLegends="externalLegends"
|
|
97
|
+
:tooltipContentProvider="tooltipContentProvider"
|
|
97
98
|
/>
|
|
98
99
|
|
|
99
100
|
<!-- multiflatmap-error -->
|
|
@@ -893,6 +894,14 @@ export default {
|
|
|
893
894
|
return []
|
|
894
895
|
},
|
|
895
896
|
},
|
|
897
|
+
/**
|
|
898
|
+
* A function that provides custom tooltip HTML content for path features.
|
|
899
|
+
* Passed through to each FlatmapVuer instance.
|
|
900
|
+
*/
|
|
901
|
+
tooltipContentProvider: {
|
|
902
|
+
type: Function,
|
|
903
|
+
default: null,
|
|
904
|
+
},
|
|
896
905
|
},
|
|
897
906
|
data: function () {
|
|
898
907
|
return {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* a single source for the flatmap-viewer library import
|
|
3
3
|
*/
|
|
4
|
-
import * as flatmap from 'https://cdn.jsdelivr.net/npm/@abi-software/flatmap-viewer@4.4.
|
|
4
|
+
import * as flatmap from 'https://cdn.jsdelivr.net/npm/@abi-software/flatmap-viewer@4.4.5/+esm';
|
|
5
5
|
|
|
6
6
|
export default flatmap;
|