Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions frontend/src/components/TheLeafletMap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
16 changes: 13 additions & 3 deletions frontend/src/stores/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -41,9 +42,8 @@ export const useMapStore = defineStore('map', () => {
},
});

function onEachFeature(feature, layer) {
function onEachFeature(feature, layer) {
let content = `<h3>Perceptual model of <strong>${feature.properties.location.long_name}</strong></h3>`

if(feature.properties.citation.url) {
content += '<br>'
content += '<h4 class="d-inline-block mr-2">URL:</h4>'
Expand Down Expand Up @@ -104,6 +104,9 @@ export const useMapStore = defineStore('map', () => {
content += '<h4>Temporal zone:</h4>'
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,
Expand Down Expand Up @@ -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,
Expand All @@ -191,6 +200,7 @@ export const useMapStore = defineStore('map', () => {
fetchPerceptualModelsGeojson,
filterFeatures,
resetFilter,
currentFilteredData
currentFilteredData,
allAvailableCoordinates
}
})
Loading