@abi-software/flatmapvuer 1.15.0 → 1.16.1-demo.0
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/dist/flatmapvuer.js +438 -379
- package/dist/flatmapvuer.umd.cjs +18 -10
- package/dist/style.css +1 -1
- package/package.json +11 -5
- package/src/assets/fonts.scss +2 -0
- package/src/assets/styles.scss +0 -2
- package/src/components/FlatmapVuer.vue +4 -3
- package/src/components/MultiFlatmapVuer.vue +3 -1
- package/src/components/index.js +1 -0
- package/src/main.js +1 -0
- package/src/services/somaLocationMarkers.js +125 -0
- package/vite.config.js +12 -4
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abi-software/flatmapvuer",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.16.1-demo.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"engines": {
|
|
6
|
-
"node": "
|
|
6
|
+
"node": "^24.20.0"
|
|
7
7
|
},
|
|
8
8
|
"files": [
|
|
9
9
|
"dist/*",
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
"./src/*": "./src/*"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@abi-software/map-utilities": "1.
|
|
51
|
+
"@abi-software/map-utilities": "1.11.0",
|
|
52
52
|
"@abi-software/sparc-annotation": "0.3.2",
|
|
53
|
-
"@abi-software/svg-sprite": "1.
|
|
53
|
+
"@abi-software/svg-sprite": "1.4.0",
|
|
54
54
|
"@element-plus/icons-vue": "^2.3.2",
|
|
55
55
|
"css-element-queries": "^1.2.3",
|
|
56
56
|
"element-plus": "^2.14.5",
|
|
@@ -90,5 +90,11 @@
|
|
|
90
90
|
"browserslist": [
|
|
91
91
|
"> 1%",
|
|
92
92
|
"last 2 versions"
|
|
93
|
-
]
|
|
93
|
+
],
|
|
94
|
+
"allowScripts": {
|
|
95
|
+
"cypress@15.21.1": true,
|
|
96
|
+
"@parcel/watcher@2.6.0": true,
|
|
97
|
+
"fsevents@2.3.3": true,
|
|
98
|
+
"esbuild@0.21.5": true
|
|
99
|
+
}
|
|
94
100
|
}
|
package/src/assets/styles.scss
CHANGED
|
@@ -634,6 +634,7 @@ import { capitalise, normaliseAlertToStringArray } from './utilities.js'
|
|
|
634
634
|
import yellowstar from '../icons/yellowstar'
|
|
635
635
|
import ResizeSensor from 'css-element-queries/src/ResizeSensor'
|
|
636
636
|
import flatmap from '../services/flatmapLoader.js'
|
|
637
|
+
import { attachSomaLocationMarkerMethods } from '../services/somaLocationMarkers.js'
|
|
637
638
|
import { AnnotationService } from '@abi-software/sparc-annotation'
|
|
638
639
|
import { mapState } from 'pinia'
|
|
639
640
|
import { useMainStore } from '@/store/index'
|
|
@@ -2845,7 +2846,7 @@ export default {
|
|
|
2845
2846
|
}
|
|
2846
2847
|
)
|
|
2847
2848
|
promise1.then((returnedObject) => {
|
|
2848
|
-
this.mapImp = returnedObject
|
|
2849
|
+
this.mapImp = attachSomaLocationMarkerMethods(returnedObject)
|
|
2849
2850
|
this.serverURL = this.mapImp.makeServerUrl('').slice(0, -1)
|
|
2850
2851
|
let mapVersion = this.mapImp.details.version
|
|
2851
2852
|
this.setFlightPathInfo(mapVersion)
|
|
@@ -4296,7 +4297,7 @@ export default {
|
|
|
4296
4297
|
@media (max-width: 1250px) {
|
|
4297
4298
|
height: 125px !important; // important is needed here as we are over-riding the style set by the flatmap
|
|
4298
4299
|
width: 180px !important;
|
|
4299
|
-
|
|
4300
|
+
.maplibregl-canvas .maplibregl-canvas {
|
|
4300
4301
|
height: 125px !important;
|
|
4301
4302
|
width: 180px !important;
|
|
4302
4303
|
}
|
|
@@ -4304,7 +4305,7 @@ export default {
|
|
|
4304
4305
|
@media (min-width: 1251px) {
|
|
4305
4306
|
height: 190px !important;
|
|
4306
4307
|
width: 300px !important;
|
|
4307
|
-
|
|
4308
|
+
.maplibregl-canvas .maplibregl-canvas {
|
|
4308
4309
|
height: 190px !important;
|
|
4309
4310
|
width: 300px !important;
|
|
4310
4311
|
}
|
|
@@ -638,7 +638,9 @@ export default {
|
|
|
638
638
|
*/
|
|
639
639
|
changeViewingMode: function (modeName) {
|
|
640
640
|
let map = this.getCurrentFlatmap()
|
|
641
|
-
map
|
|
641
|
+
if (map) {
|
|
642
|
+
map.changeViewingMode(modeName)
|
|
643
|
+
}
|
|
642
644
|
},
|
|
643
645
|
setConnectionType: function (type) {
|
|
644
646
|
let map = this.getCurrentFlatmap();
|
package/src/components/index.js
CHANGED
package/src/main.js
CHANGED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
const SOMA_MARKER_COLOUR = '#1b7f6b'
|
|
2
|
+
const SOMA_MARKER_SECONDARY_COLOUR = '#f4f1de'
|
|
3
|
+
const SOMA_MARKER_TEXT_COLOUR = '#12312b'
|
|
4
|
+
const SOMA_MARKER_MAX_COUNT_LABEL = '99+'
|
|
5
|
+
|
|
6
|
+
const normalizeSomaLocations = function (somaLocations) {
|
|
7
|
+
return (Array.isArray(somaLocations) ? somaLocations : [])
|
|
8
|
+
.map((item) => ({
|
|
9
|
+
label: String(item?.label || '').trim(),
|
|
10
|
+
curie: String(item?.curie || '').trim(),
|
|
11
|
+
count: Number(item?.count || 0),
|
|
12
|
+
}))
|
|
13
|
+
.filter((item) => item.curie && item.count > 0)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const formatCount = function (count) {
|
|
17
|
+
if (count > 99) return SOMA_MARKER_MAX_COUNT_LABEL
|
|
18
|
+
return String(count)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const createSomaLocationMarkerElement = function (somaLocation) {
|
|
22
|
+
const wrapper = document.createElement('div')
|
|
23
|
+
wrapper.className = 'flatmapvuer-soma-location-marker'
|
|
24
|
+
wrapper.title = somaLocation.label || somaLocation.curie
|
|
25
|
+
wrapper.style.width = '34px'
|
|
26
|
+
wrapper.style.height = '48px'
|
|
27
|
+
wrapper.style.display = 'flex'
|
|
28
|
+
wrapper.style.alignItems = 'center'
|
|
29
|
+
wrapper.style.justifyContent = 'center'
|
|
30
|
+
wrapper.style.transform = 'translate(-50%, -100%)'
|
|
31
|
+
|
|
32
|
+
const countLabel = formatCount(somaLocation.count)
|
|
33
|
+
wrapper.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="-1 -1 27 42" width="34" height="48" aria-hidden="true">
|
|
34
|
+
<ellipse style="fill: rgb(0, 0, 0); fill-opacity: 0.18;" cx="12" cy="36" rx="8" ry="4"/>
|
|
35
|
+
<path d="M12.25.25a12.254 12.254 0 0 0-12 12.494
|
|
36
|
+
c0 6.444 6.488 12.109 11.059 22.564.549 1.256 1.333 1.256 1.882 0
|
|
37
|
+
C17.762 24.853 24.25 19.186 24.25 12.744A12.254 12.254 0 0 0 12.25.25Z"
|
|
38
|
+
style="fill:${SOMA_MARKER_COLOUR};stroke:${SOMA_MARKER_SECONDARY_COLOUR};stroke-width:1.1"/>
|
|
39
|
+
<circle cx="12.5" cy="12.5" r="8" fill="${SOMA_MARKER_SECONDARY_COLOUR}"/>
|
|
40
|
+
<text x="12.5" y="16.1" text-anchor="middle" style="font-size:7.5px;font-weight:700;fill:${SOMA_MARKER_TEXT_COLOUR};font-family:Arial, sans-serif">${countLabel}</text>
|
|
41
|
+
</svg>`
|
|
42
|
+
|
|
43
|
+
return wrapper
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const resolveMarkerPlacement = function (mapImp, curie) {
|
|
47
|
+
const featureIds = Array.isArray(mapImp?.modelFeatureIds?.(curie)) ? mapImp.modelFeatureIds(curie) : []
|
|
48
|
+
const placements = []
|
|
49
|
+
const seenFeatureUris = new Set()
|
|
50
|
+
|
|
51
|
+
for (const featureId of featureIds) {
|
|
52
|
+
const annotation = mapImp.annotation(featureId)
|
|
53
|
+
const featureUri = String(annotation?.uri || '').trim()
|
|
54
|
+
if (featureUri && !seenFeatureUris.has(featureUri)) {
|
|
55
|
+
seenFeatureUris.add(featureUri)
|
|
56
|
+
placements.push({
|
|
57
|
+
type: 'feature-uri',
|
|
58
|
+
value: featureUri,
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Fall back to model placement only when no feature URI can be resolved.
|
|
64
|
+
if (!placements.length && featureIds.length) {
|
|
65
|
+
placements.push({
|
|
66
|
+
type: 'model',
|
|
67
|
+
value: curie,
|
|
68
|
+
})
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return placements
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export const attachSomaLocationMarkerMethods = function (mapImp) {
|
|
75
|
+
if (!mapImp || mapImp.addSomaLocationMarkers) {
|
|
76
|
+
return mapImp
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
let markerIds = []
|
|
80
|
+
|
|
81
|
+
mapImp.clearSomaLocationMarkers = function () {
|
|
82
|
+
markerIds.forEach((markerId) => {
|
|
83
|
+
mapImp.removeMarker(markerId)
|
|
84
|
+
})
|
|
85
|
+
markerIds = []
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
mapImp.addSomaLocationMarkers = function (somaLocations) {
|
|
89
|
+
const normalizedSomaLocations = normalizeSomaLocations(somaLocations)
|
|
90
|
+
const placedSomaLocations = []
|
|
91
|
+
|
|
92
|
+
mapImp.clearSomaLocationMarkers()
|
|
93
|
+
|
|
94
|
+
normalizedSomaLocations.forEach((somaLocation) => {
|
|
95
|
+
const placements = resolveMarkerPlacement(mapImp, somaLocation.curie)
|
|
96
|
+
if (!placements.length) return
|
|
97
|
+
|
|
98
|
+
let somaLocationPlaced = false
|
|
99
|
+
placements.forEach((placement) => {
|
|
100
|
+
const markerElement = createSomaLocationMarkerElement(somaLocation)
|
|
101
|
+
let addedMarkerIds = []
|
|
102
|
+
|
|
103
|
+
if (placement.type === 'feature-uri') {
|
|
104
|
+
addedMarkerIds = mapImp.addMarkerByFeatureUri(placement.value, { element: markerElement })
|
|
105
|
+
} else if (placement.type === 'model') {
|
|
106
|
+
const markerId = mapImp.addMarker(placement.value, { element: markerElement })
|
|
107
|
+
addedMarkerIds = markerId > -1 ? [markerId] : []
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (!addedMarkerIds.length) return
|
|
111
|
+
|
|
112
|
+
markerIds.push(...addedMarkerIds)
|
|
113
|
+
somaLocationPlaced = true
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
if (somaLocationPlaced) {
|
|
117
|
+
placedSomaLocations.push(somaLocation)
|
|
118
|
+
}
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
return placedSomaLocations
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return mapImp
|
|
125
|
+
}
|
package/vite.config.js
CHANGED
|
@@ -41,18 +41,26 @@ export default defineConfig(({ command, mode }) => {
|
|
|
41
41
|
],
|
|
42
42
|
resolve: {
|
|
43
43
|
alias: {
|
|
44
|
-
'@': path.resolve(
|
|
44
|
+
'@': path.resolve(import.meta.dirname, './src'),
|
|
45
45
|
}
|
|
46
46
|
},
|
|
47
47
|
build: {
|
|
48
48
|
lib: {
|
|
49
|
-
entry: path.resolve(
|
|
49
|
+
entry: path.resolve(import.meta.dirname, "./src/components/index.js"),
|
|
50
50
|
name: "FlatmapVuer",
|
|
51
51
|
fileName: 'flatmapvuer',
|
|
52
52
|
},
|
|
53
53
|
rollupOptions: {
|
|
54
|
-
external: [
|
|
55
|
-
"
|
|
54
|
+
external: [
|
|
55
|
+
"vue",
|
|
56
|
+
"@abi-software/sparc-annotation",
|
|
57
|
+
"@abi-software/svg-sprite",
|
|
58
|
+
"@abi-software/map-utilities",
|
|
59
|
+
"@element-plus/icons-vue",
|
|
60
|
+
"pinia",
|
|
61
|
+
"@abi-software/svg-sprite/dist/style.css",
|
|
62
|
+
"@abi-software/map-utilities/dist/style.css"
|
|
63
|
+
],
|
|
56
64
|
output: {
|
|
57
65
|
globals: {
|
|
58
66
|
vue: "Vue",
|