fix: deal with undefined

This commit is contained in:
moanos [he/him] 2025-01-02 11:14:34 +01:00
parent 6e2a2a1d5e
commit 8e7cdafee0

View File

@ -20,11 +20,17 @@
var center = [10.49, 50.68]; var center = [10.49, 50.68];
{% endif %} {% endif %}
{% if zoom_level %}
var zoom_level = {{ zoom_level }};
{% else %}
var zoom_level = 4;
{% endif %}
let map = new maplibregl.Map({ let map = new maplibregl.Map({
container: 'map', container: 'map',
style: '{% static "fellchensammlung/map/styles/colorful.json" %}', style: '{% static "fellchensammlung/map/styles/colorful.json" %}',
center: center, center: center,
zoom: {{ zoom_level }} zoom: zoom_level
}).addControl(new maplibregl.NavigationControl()); }).addControl(new maplibregl.NavigationControl());
{% for adoption_notice in adoption_notices_map %} {% for adoption_notice in adoption_notices_map %}
@ -46,6 +52,7 @@
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{% if search_radius %}
map.on('load', () => { map.on('load', () => {
const radius = {{ search_radius }}; // kilometer const radius = {{ search_radius }}; // kilometer
const options = { const options = {
@ -82,5 +89,6 @@
} }
}); });
}); });
{% endif %}
</script> </script>