Skip to content

Commit

Permalink
latest
Browse files Browse the repository at this point in the history
  • Loading branch information
stiles committed Dec 31, 2024
1 parent 05c0f60 commit 693f9cc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
16 changes: 10 additions & 6 deletions docs/static/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ document.addEventListener("DOMContentLoaded", function () {
const mapLon = parseFloat(mapContainer.getAttribute("data-lon"));
const countryName = mapContainer.getAttribute("data-name");

const geojsonUrl = `/static/data/geo/${countryName}.geojson`;
// Dynamically determine the base path
const basePath = window.location.pathname.includes('/guessr-meta-generator/')
? '/guessr-meta-generator'
: '';

// Construct the GeoJSON URL
const geojsonUrl = `${basePath}/static/data/geo/${countryName}.geojson`;

console.log("GeoJSON URL:", geojsonUrl);

Expand All @@ -38,8 +44,8 @@ document.addEventListener("DOMContentLoaded", function () {
zoom: 5,
});

// Load country boundary GeoJSON
map.on('load', function () {
// Load country boundary GeoJSON
map.addSource('country-boundary', {
type: 'geojson',
data: geojsonUrl,
Expand Down Expand Up @@ -76,7 +82,6 @@ document.addEventListener("DOMContentLoaded", function () {
interactive: false,
});

// Add a source and layer for the bounding box on the inset map
insetMap.on('load', () => {
insetMap.addSource('main-map-bounds', {
type: 'geojson',
Expand Down Expand Up @@ -108,7 +113,7 @@ document.addEventListener("DOMContentLoaded", function () {
[bounds.getNorthWest().lng, bounds.getNorthWest().lat],
[bounds.getNorthEast().lng, bounds.getNorthEast().lat],
[bounds.getSouthEast().lng, bounds.getSouthEast().lat],
[bounds.getSouthWest().lng, bounds.getSouthWest().lat] // Close the polygon
[bounds.getSouthWest().lng, bounds.getSouthWest().lat], // Close the polygon
]],
},
};
Expand All @@ -128,5 +133,4 @@ document.addEventListener("DOMContentLoaded", function () {
updateInsetMap();
});
});
});

});
16 changes: 10 additions & 6 deletions static/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ document.addEventListener("DOMContentLoaded", function () {
const mapLon = parseFloat(mapContainer.getAttribute("data-lon"));
const countryName = mapContainer.getAttribute("data-name");

const geojsonUrl = `/static/data/geo/${countryName}.geojson`;
// Dynamically determine the base path
const basePath = window.location.pathname.includes('/guessr-meta-generator/')
? '/guessr-meta-generator'
: '';

// Construct the GeoJSON URL
const geojsonUrl = `${basePath}/static/data/geo/${countryName}.geojson`;

console.log("GeoJSON URL:", geojsonUrl);

Expand All @@ -38,8 +44,8 @@ document.addEventListener("DOMContentLoaded", function () {
zoom: 5,
});

// Load country boundary GeoJSON
map.on('load', function () {
// Load country boundary GeoJSON
map.addSource('country-boundary', {
type: 'geojson',
data: geojsonUrl,
Expand Down Expand Up @@ -76,7 +82,6 @@ document.addEventListener("DOMContentLoaded", function () {
interactive: false,
});

// Add a source and layer for the bounding box on the inset map
insetMap.on('load', () => {
insetMap.addSource('main-map-bounds', {
type: 'geojson',
Expand Down Expand Up @@ -108,7 +113,7 @@ document.addEventListener("DOMContentLoaded", function () {
[bounds.getNorthWest().lng, bounds.getNorthWest().lat],
[bounds.getNorthEast().lng, bounds.getNorthEast().lat],
[bounds.getSouthEast().lng, bounds.getSouthEast().lat],
[bounds.getSouthWest().lng, bounds.getSouthWest().lat] // Close the polygon
[bounds.getSouthWest().lng, bounds.getSouthWest().lat], // Close the polygon
]],
},
};
Expand All @@ -128,5 +133,4 @@ document.addEventListener("DOMContentLoaded", function () {
updateInsetMap();
});
});
});

});

0 comments on commit 693f9cc

Please sign in to comment.