Added OSM map to place_detail view and template.

This commit is contained in:
Marcus Scholz 2020-08-22 09:19:01 +02:00
parent 7cb8bc6bac
commit 3ef31eda0f
2 changed files with 9 additions and 1 deletions

View File

@ -1,5 +1,9 @@
{% extends 'global.html'%} {% extends 'global.html'%}
{% load static %} {% load static %}
{% block additional_head %}
<link rel="stylesheet" href="{% static 'maps/ol.css' %}" type="text/css">
<script src="{% static 'maps/ol.js' %}"></script>
{% endblock additional_head %}
{% load thumbnail %} {% load thumbnail %}
{% block title %}{{place.name}}{% endblock %} {% block title %}{{place.name}}{% endblock %}
@ -27,6 +31,7 @@
<section class="LP-Section"> <section class="LP-Section">
<h1 class="LP-Headline">Map-Links</h1> <h1 class="LP-Headline">Map-Links</h1>
{% include 'partials/osm_map.html' %}
<div class="LP-LinkList"> <div class="LP-LinkList">
<ul class="LP-LinkList__List"> <ul class="LP-LinkList__List">
<li class="LP-LinkList__Item"><a target="_blank" href="https://www.google.com/maps?q={{place.latitude}},{{place.longitude}}" class="LP-Link"><span class="LP-Text">Google Maps</span></a></li> <li class="LP-LinkList__Item"><a target="_blank" href="https://www.google.com/maps?q={{place.latitude}},{{place.longitude}}" class="LP-Link"><span class="LP-Text">Google Maps</span></a></li>

View File

@ -57,8 +57,11 @@ class PlaceListView(IsAuthenticated, ListView):
class PlaceDetailView(IsAuthenticated, View): class PlaceDetailView(IsAuthenticated, View):
def get(self, request, pk): def get(self, request, pk):
place = Place.objects.get(pk=pk)
context = { context = {
'place': Place.objects.get(pk=pk) 'place': place,
'place_list': [ place ],
'place_map_center': [ place.latitude, place.longitude ]
} }
return render(request, 'place/place_detail.html', context) return render(request, 'place/place_detail.html', context)