diff --git a/frontend/src/components/TheLeafletMap.vue b/frontend/src/components/TheLeafletMap.vue index 47c0a57..e00d89c 100644 --- a/frontend/src/components/TheLeafletMap.vue +++ b/frontend/src/components/TheLeafletMap.vue @@ -59,6 +59,12 @@ onMounted(async () => { // query the api for the features await mapStore.fetchPerceptualModelsGeojson() + // Convert to Leaflet LatLngBounds + const bounds = L.latLngBounds(mapStore.allAvailableCoordinates); + + // Restrict panning to within bounds + leaflet.setMaxBounds(bounds); + // layer toggling let mixed = { "Perceptual Models": layerGroup, diff --git a/frontend/src/stores/map.js b/frontend/src/stores/map.js index ae06ae7..a05fea8 100644 --- a/frontend/src/stores/map.js +++ b/frontend/src/stores/map.js @@ -12,6 +12,7 @@ export const useMapStore = defineStore('map', () => { const perceptualModelsGeojson = ref([]) const mapLoaded = ref(false) let currentFilteredData = ref([]) + const allAvailableCoordinates = [] const markerClusterGroup = L.markerClusterGroup({ iconCreateFunction: (cluster) => { const childCount = cluster.getChildCount(); @@ -41,9 +42,8 @@ export const useMapStore = defineStore('map', () => { }, }); - function onEachFeature(feature, layer) { + function onEachFeature(feature, layer) { let content = `

Perceptual model of ${feature.properties.location.long_name}

` - if(feature.properties.citation.url) { content += '
' content += '

URL:

' @@ -104,6 +104,9 @@ export const useMapStore = defineStore('map', () => { content += '

Temporal zone:

' content += `${feature.properties.temporal_zone_type.temporal_property}` } + + allAvailableCoordinates.push(adjustLatLon(feature.properties.location.lat, feature.properties.location.lon)) + layer.bindPopup(content, { maxWidth: 400, maxHeight: 300, @@ -183,6 +186,12 @@ export const useMapStore = defineStore('map', () => { layerGroup.value.addLayer(markerClusterGroup); } + function adjustLatLon(lat, lon) { + return [ + lat < 0 ? lat - 10 : lat + 10, + lon < 0 ? lon - 10 : lon + 10 + ]; +} return { leaflet, modelFeatures, @@ -191,6 +200,7 @@ export const useMapStore = defineStore('map', () => { fetchPerceptualModelsGeojson, filterFeatures, resetFilter, - currentFilteredData + currentFilteredData, + allAvailableCoordinates } })