Add default place (link)
This commit is contained in:
parent
ff1baf7003
commit
6741a22527
1 changed files with 11 additions and 1 deletions
|
|
@ -41,6 +41,8 @@ map.on('click', onMapClick);
|
||||||
let markers = {};
|
let markers = {};
|
||||||
let categories = {};
|
let categories = {};
|
||||||
fetch('/marker.json').then(response => response.json()).then(marker_data => {
|
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)
|
for(let category_name in marker_data)
|
||||||
{
|
{
|
||||||
const category_data = marker_data[category_name];
|
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 => {
|
category_data.places.forEach(marker_info => {
|
||||||
const marker = L.marker(
|
const marker = L.marker(
|
||||||
[marker_info.lat, marker_info.lon],
|
[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);
|
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] = {
|
categories[category_name] = {
|
||||||
icon: icon, icon_url: `/images/${category_data.icon}`, name: category_data.name, enable: false};
|
icon: icon, icon_url: `/images/${category_data.icon}`, name: category_data.name, enable: false};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue