Add default place (link)

This commit is contained in:
Corentin 2025-10-23 18:57:29 +09:00
commit 6741a22527

View file

@ -41,6 +41,8 @@ map.on('click', onMapClick);
let markers = {};
let categories = {};
fetch('/marker.json').then(response => response.json()).then(marker_data => {
const params = new URLSearchParams(document.location.search);
let default_place = params.get('place');
for(let category_name in marker_data)
{
const category_data = marker_data[category_name];
@ -49,8 +51,16 @@ fetch('/marker.json').then(response => response.json()).then(marker_data => {
category_data.places.forEach(marker_info => {
const marker = L.marker(
[marker_info.lat, marker_info.lon],
{title: marker_info.name, icon: icon}).bindPopup(`<h3>${marker_info.name}</h3>${marker_info.description}`);
{title: marker_info.name, icon: icon}).bindPopup(
`<h3>${marker_info.name}</h3>
<div class="description">${marker_info.description}</div>
<div><a href="/?place=${marker_info.name}">link<\a></div>`);
category_markers.push(marker);
if(marker_info.name === default_place)
{
marker.addTo(map);
map.setView([marker_info.lat, marker_info.lon], 16);
}
});
categories[category_name] = {
icon: icon, icon_url: `/images/${category_data.icon}`, name: category_data.name, enable: false};