feat: Add basic map

This commit is contained in:
moanos [he/him] 2024-08-24 08:36:10 +02:00
parent 080c590d9e
commit cb1c3e52da
7 changed files with 51 additions and 1 deletions

File diff suppressed because one or more lines are too long

View File

@ -8,6 +8,7 @@
<!-- Add additional CSS in static file --> <!-- Add additional CSS in static file -->
{% load static %} {% load static %}
<link rel="stylesheet" href="{% static 'fellchensammlung/css/styles.css' %}"> <link rel="stylesheet" href="{% static 'fellchensammlung/css/styles.css' %}">
<link href="{% static 'fellchensammlung/css/leaflet.css' %}" rel="stylesheet" type="text/css">
<link href="{% static 'fontawesomefree/css/fontawesome.css' %}" rel="stylesheet" type="text/css"> <link href="{% static 'fontawesomefree/css/fontawesome.css' %}" rel="stylesheet" type="text/css">
<link href="{% static 'fontawesomefree/css/brands.css' %}" rel="stylesheet" type="text/css"> <link href="{% static 'fontawesomefree/css/brands.css' %}" rel="stylesheet" type="text/css">
<link href="{% static 'fontawesomefree/css/solid.css' %}" rel="stylesheet" type="text/css"> <link href="{% static 'fontawesomefree/css/solid.css' %}" rel="stylesheet" type="text/css">

View File

@ -0,0 +1,7 @@
{% extends "fellchensammlung/base_generic.html" %}
{% load i18n %}
{% block content %}
<h1>{% translate 'Karte' %}</h1>
{% include "fellchensammlung/partials/partial-map.html" %}
{% endblock %}

View File

@ -0,0 +1,29 @@
{% load static %}
<div id="map"></div>
<script src="{% static 'fellchensammlung/leaflet.js' %}"></script>
<script>
// Initialize the map and set its view to the desired geographical coordinates and zoom level
var map = L.map('map').setView([51.505, -0.09], 13);
// Add the OpenStreetMap tile layer
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
// Example coordinates for markers
var markers = [
{coords: [51.5, -0.09], popup: "Marker 1"},
{coords: [51.515, -0.1], popup: "Marker 2"},
{coords: [51.52, -0.12], popup: "Marker 3"}
];
// Loop through the marker coordinates and add them to the map
markers.forEach(function (marker) {
L.marker(marker.coords).addTo(map)
.bindPopup(marker.popup)
.openPopup();
});
</script>

View File

@ -27,6 +27,8 @@ urlpatterns = [
# ex: /search/ # ex: /search/
path("suchen/", views.search, name="search"), path("suchen/", views.search, name="search"),
# ex: /map/
path("map/", views.map, name="map"),
# ex: /vermitteln/ # ex: /vermitteln/
path("vermitteln/", views.add_adoption_notice, name="add-adoption"), path("vermitteln/", views.add_adoption_notice, name="add-adoption"),

View File

@ -38,7 +38,8 @@ def fail_if_user_not_owner_or_trust_level(user, django_object, trust_level=User.
def index(request): def index(request):
"""View function for home page of site.""" """View function for home page of site."""
latest_adoption_list = AdoptionNotice.objects.filter(adoptionnoticestatus__major_status=AdoptionNoticeStatus.ACTIVE).order_by("-created_at")[:5] latest_adoption_list = AdoptionNotice.objects.filter(
adoptionnoticestatus__major_status=AdoptionNoticeStatus.ACTIVE).order_by("-created_at")[:5]
active_adoptions = [adoption for adoption in latest_adoption_list if adoption.is_active] active_adoptions = [adoption for adoption in latest_adoption_list if adoption.is_active]
language_code = translation.get_language() language_code = translation.get_language()
lang = Language.objects.get(languagecode=language_code) lang = Language.objects.get(languagecode=language_code)
@ -395,6 +396,10 @@ def modqueue(request):
return render(request, 'fellchensammlung/modqueue.html', context=context) return render(request, 'fellchensammlung/modqueue.html', context=context)
def map(request):
return render(request, 'fellchensammlung/map.html')
def metrics(request): def metrics(request):
data = gather_metrics_data() data = gather_metrics_data()
return JsonResponse(data) return JsonResponse(data)