Merge branch 'dev'
This commit is contained in:
2400
package-lock.json
generated
2400
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
14
package.json
14
package.json
@@ -10,14 +10,14 @@
|
|||||||
"astro": "astro"
|
"astro": "astro"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@astrojs/sitemap": "^3.1.1",
|
"@astrojs/sitemap": "^3.1.4",
|
||||||
"@astrojs/vue": "^4.0.8",
|
"@astrojs/vue": "^4.1.0",
|
||||||
"@types/leaflet": "^1.9.8",
|
"@types/leaflet": "^1.9.12",
|
||||||
"@vueuse/core": "^10.8.0",
|
"@vueuse/core": "^10.9.0",
|
||||||
"astro": "^4.4.5",
|
"astro": "^4.7.1",
|
||||||
"vue": "^3.4.20"
|
"vue": "^3.4.27"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"sass": "^1.71.1"
|
"sass": "^1.77.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -457,6 +457,84 @@ function removeCustomMarker(marker, markerTitle) {
|
|||||||
saveCustomMarkers()
|
saveCustomMarkers()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* URL PARAMETERS
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* From the leaflet setup, get a working param config
|
||||||
|
*
|
||||||
|
* @returns Latitude, Longitude and zoom level of the map
|
||||||
|
*/
|
||||||
|
function getURLFromSetup() {
|
||||||
|
const centerOfMap = map.getCenter()
|
||||||
|
|
||||||
|
const lat = centerOfMap.lat
|
||||||
|
const lon = centerOfMap.lng
|
||||||
|
const zoom = parseFloat(map.getZoom().toFixed(1))
|
||||||
|
|
||||||
|
return { lat, lon, zoom }
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get leaflet coords from URL params
|
||||||
|
*
|
||||||
|
* @returns URLSearchParams
|
||||||
|
*/
|
||||||
|
function getCoordsSetupFromURL() {
|
||||||
|
const params = new URL(document.location).searchParams
|
||||||
|
|
||||||
|
return params
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the params in the URL can be parsed as leaflet coordinates
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
function hasInitialSetup() {
|
||||||
|
const params = new URL(document.location).searchParams
|
||||||
|
|
||||||
|
return params.has('lat') && params.has('lon')
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to refresh the URL params
|
||||||
|
*
|
||||||
|
* @returns void
|
||||||
|
*/
|
||||||
|
function setupToURL() {
|
||||||
|
const setup = getURLFromSetup()
|
||||||
|
|
||||||
|
const newParams = new URLSearchParams(setup)
|
||||||
|
const newUrl = new URL(window.location.href)
|
||||||
|
newUrl.search = newParams.toString()
|
||||||
|
|
||||||
|
window.history.replaceState(null, '', newUrl.toString())
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Uses the URL params to setup the leaflet map
|
||||||
|
*/
|
||||||
|
function setupFromURL() {
|
||||||
|
const setup = getCoordsSetupFromURL()
|
||||||
|
|
||||||
|
map.setView({ lat: setup.get('lat'), lng: setup.get('lon') }, setup.get('zoom') | minZoom, { animate: false })
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the map has initial params in the URL
|
||||||
|
// If not, just setup the default URL
|
||||||
|
if (hasInitialSetup()) {
|
||||||
|
setupFromURL()
|
||||||
|
} else {
|
||||||
|
setupToURL()
|
||||||
|
}
|
||||||
|
|
||||||
|
// When the map stops moving, update the URL to keep it up to date
|
||||||
|
map.on('moveend', () => {
|
||||||
|
setupToURL()
|
||||||
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UTILITIES
|
* UTILITIES
|
||||||
*/
|
*/
|
||||||
|
|||||||
1
src/env.d.ts
vendored
1
src/env.d.ts
vendored
@@ -1 +1,2 @@
|
|||||||
|
/// <reference path="../.astro/types.d.ts" />
|
||||||
/// <reference types="astro/client" />
|
/// <reference types="astro/client" />
|
||||||
|
|||||||
Reference in New Issue
Block a user