/
Flatmap.vue
146 lines (141 loc) · 4.07 KB
/
Flatmap.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<template>
<FlatmapVuer
:state="entry.state"
:entry="entry.resource"
@resource-selected="flatmaprResourceSelected(entry.type, $event)"
@pan-zoom-callback="flatmapPanZoomCallback"
:name="entry.resource"
style="height: 100%; width: 100%"
:minZoom="entry.minZoom"
:helpMode="helpMode"
:pathControls="true"
ref="flatmap"
@ready="flatmapReadyCall"
:displayMinimap="false"
:displayWarning="true"
:enableOpenMapUI="true"
:flatmapAPI="flatmapAPI"
:sparcAPI="apiLocation"
:userApiKey="userApiKey"
@open-map="openMap"
/>
</template>
<script>
/* eslint-disable no-alert, no-console */
import { FlatmapVuer } from "@abi-software/flatmapvuer";
import EventBus from "../EventBus";
import ContentMixin from "../../mixins/ContentMixin";
import DynamicMarkerMixin from "../../mixins/DynamicMarkerMixin";
import "@abi-software/flatmapvuer/dist/style.css";
export default {
name: "Flatmap",
mixins: [ ContentMixin, DynamicMarkerMixin ],
components: {
FlatmapVuer,
},
methods: {
getState: function () {
return this.$refs.flatmap.getState();
},
/**
* Perform a local search on this contentvuer
*/
search: function (term) {
return this.$refs.flatmap.searchAndShowResult(term);
},
getFlatmapImp() {
return this.$refs.flatmap.mapImp;
},
flatmaprResourceSelected: function (type, resource) {
this.$refs.flatmap.resourceSelected(
type, resource, (this.$refs.map.viewingMode === "Exploration"));
},
flatmapReadyCall: function (flatmap) {
let provClone = {id: this.entry.id, prov: this.getFlatmapImp().provenance}; //create clone of provenance and add id
EventBus.emit("mapImpProv", provClone); // send clone to context card
this.$emit("flatmap-provenance-ready", provClone);
this.getAvailableTerms();
if (this.entry.resource === "FunctionalConnectivity"){
this.flatmapReadyForMarkerUpdates(flatmap);
}
},
highlightFeatures: function(info) {
let name = info.name;
const flatmap = this.$refs.flatmap.mapImp;
if (name) {
const results = flatmap.search(name);
if (results.featureIds[0]) {
flatmap.highlightFeatures([
flatmap.modelForFeature(results.featureIds[0]),
]);
}
}
},
/**
* Append the list of suggested terms to suggestions
*/
searchSuggestions: function (term, suggestions) {
if (term && this.$refs.flatmap.mapImp) {
const results = this.$refs.flatmap.mapImp.search(term);
results.__featureIds.forEach(id => {
const annotation = this.$refs.flatmap.mapImp.annotation(id);
if (annotation && annotation.label)
suggestions.push(annotation.label);
});
}
},
zoomToFeatures: function(info, forceSelect) {
let name = info.name;
const flatmap = this.$refs.flatmap.mapImp;
if (name) {
const results = flatmap.search(name);
if (results.featureIds.length) {
let externalId = flatmap.modelForFeature(results.featureIds[0]);
if (externalId) {
if (forceSelect) {
flatmap.selectFeatures(externalId);
}
flatmap.zoomToFeatures(externalId);
} else flatmap.clearSearchResults();
}
} else {
flatmap.clearSearchResults();
}
},
},
computed: {
facetSpecies() {
return this.settingsStore.facets.species;
},
},
mounted: function() {
this.getAvailableTerms();
EventBus.on("markerUpdate", () => {
this.flatmapMarkerZoomUpdate(true, undefined);
});
},
};
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="scss">
:deep(.maplibregl-popup) {
z-index: 3;
}
:deep(.flatmapvuer-popover) {
.maplibregl-popup-content {
border-radius: 4px;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
pointer-events: auto;
width: 25em;
background: #fff;
}
}
:deep(.maplibregl-marker) {
&.standard-marker {
z-index: 2;
}
&.highlight-marker {
z-index: 1;
}
}
</style>