Buildings and levels for the floor map, and make every identifier searchable
This commit is contained in:
@@ -43,7 +43,7 @@
|
||||
import { ref, computed, onMounted, onUnmounted, watch } from 'vue'
|
||||
import L from 'leaflet'
|
||||
import 'leaflet/dist/leaflet.css'
|
||||
import { loadMapConfig, blueprintUrlFor, state as mapConfig } from '@/composables/mapConfig'
|
||||
import { loadMapConfig, blueprintUrlFor, dimensionsFor, state as mapConfig } from '@/composables/mapConfig'
|
||||
import { printersApi } from '@/api'
|
||||
import { withBase } from '@/utils/basePath'
|
||||
import { currentTheme } from '@/stores/theme'
|
||||
@@ -55,8 +55,10 @@ const selected = ref({}) // printerid -> true
|
||||
let map = null
|
||||
let imageOverlay = null
|
||||
let markers = {} // printerid -> circleMarker
|
||||
let MAP_WIDTH = mapConfig.width
|
||||
let MAP_HEIGHT = mapConfig.height
|
||||
// The level being shown. The installer map runs before anyone logs in, which is
|
||||
// why /api/maplevels is public - without it there is no blueprint to draw.
|
||||
let MAP_WIDTH = 0
|
||||
let MAP_HEIGHT = 0
|
||||
|
||||
const SELECTED_COLOR = '#e53935'
|
||||
const NORMAL_COLOR = '#4CAF50'
|
||||
@@ -120,13 +122,13 @@ function renderMarkers() {
|
||||
}
|
||||
|
||||
watch(currentTheme, (theme) => {
|
||||
if (imageOverlay) imageOverlay.setUrl(blueprintUrlFor(theme))
|
||||
if (imageOverlay) imageOverlay.setUrl(blueprintUrlFor(theme, mapConfig.currentlevelid))
|
||||
})
|
||||
|
||||
onMounted(async () => {
|
||||
await loadMapConfig()
|
||||
MAP_WIDTH = mapConfig.width
|
||||
MAP_HEIGHT = mapConfig.height
|
||||
MAP_WIDTH = dimensionsFor(mapConfig.currentlevelid).width
|
||||
MAP_HEIGHT = dimensionsFor(mapConfig.currentlevelid).height
|
||||
|
||||
try {
|
||||
const response = await printersApi.installList()
|
||||
@@ -142,7 +144,7 @@ onMounted(async () => {
|
||||
attributionControl: false,
|
||||
})
|
||||
const bounds = [[0, 0], [MAP_HEIGHT, MAP_WIDTH]]
|
||||
imageOverlay = L.imageOverlay(blueprintUrlFor(currentTheme.value), bounds).addTo(map)
|
||||
imageOverlay = L.imageOverlay(blueprintUrlFor(currentTheme.value, mapConfig.currentlevelid), bounds).addTo(map)
|
||||
map.setView([MAP_HEIGHT / 2, MAP_WIDTH / 2], -2)
|
||||
map.setMaxBounds(bounds)
|
||||
renderMarkers()
|
||||
|
||||
Reference in New Issue
Block a user