Skip to content

Commit

Permalink
Move show connectivity tooltip method to flatmapvuer
Browse files Browse the repository at this point in the history
  • Loading branch information
akhuoa committed Nov 18, 2024
1 parent 858bf22 commit 1fa085f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 61 deletions.
1 change: 1 addition & 0 deletions src/components/viewers/Flatmap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
@shown-map-tooltip="onMapTooltipShown"
@connectivity-info-open="onConnectivityInfoOpen"
@connectivity-info-close="onConnectivityInfoClose"
@connectivity-graph-error="onConnectivityGraphError"
:connectivityInfoSidebar="connectivityInfoSidebar"
:pathControls="true"
ref="flatmap"
Expand Down
65 changes: 4 additions & 61 deletions src/components/viewers/MultiFlatmap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
:annotationSidebar="annotationSidebar"
@connectivity-info-open="onConnectivityInfoOpen"
@connectivity-info-close="onConnectivityInfoClose"
@connectivity-graph-error="onConnectivityGraphError"
:connectivityInfoSidebar="connectivityInfoSidebar"
ref="multiflatmap"
:displayMinimap="true"
Expand Down Expand Up @@ -428,67 +429,9 @@ export default {
});
},
showConnectivityTooltips: function (payload) {
const { connectivityInfo, data } = payload;
const featuresToHighlight = [];
const connectivityData = [];
const filteredConnectivityData = [];
const errorData = [];
const flatmap = this.$refs.multiflatmap.getCurrentFlatmap();
if (!data.length) {
// Close all tooltips on the current flatmap element
flatmap.removeActiveTooltips();
} else {
data.forEach((item) => {
connectivityData.push({
id: item.id,
label: item.label,
});
});
}
// to keep the highlighted path on map
if (connectivityInfo && connectivityInfo.featureId) {
featuresToHighlight.push(...connectivityInfo.featureId);
}
// search the features on the map first
if (this.flatmapReady && flatmap.mapImp) {
connectivityData.forEach((connectivity, i) => {
const {id, label} = connectivity;
const response = flatmap.mapImp.search(id);
if (response?.results.length) {
const featureId = response?.results[0].featureId;
filteredConnectivityData.push({
featureId,
id,
label,
});
featuresToHighlight.push(id);
} else {
errorData.push(connectivity);
}
});
if (filteredConnectivityData.length) {
// show tooltip of the first item
// with all labels
flatmap.createTooltipForConnectivity(filteredConnectivityData);
} else {
errorData.push(...connectivityData);
// Close all tooltips on the current flatmap element
flatmap.removeActiveTooltips();
}
// Emit error message for connectivity graph
if (errorData.length) {
this.emitConnectivityGraphError(errorData);
}
// highlight all available features
flatmap.mapImp.zoomToFeatures(featuresToHighlight, { noZoomIn: true });
if (this.flatmapReady) {
const flatmap = this.$refs.multiflatmap.getCurrentFlatmap();
flatmap.showConnectivityTooltips(payload);
}
},
},
Expand Down
3 changes: 3 additions & 0 deletions src/mixins/ContentMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,9 @@ export default {
onConnectivityInfoClose: function () {
EventBus.emit('connectivity-info-close');
},
onConnectivityGraphError: function (errorInfo) {
EventBus.emit('connectivity-graph-error', errorInfo);
},
},
data: function () {
return {
Expand Down

0 comments on commit 1fa085f

Please sign in to comment.