-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(apis_entities): add a map route for place like entities
- Loading branch information
Showing
4 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// we center on vienna first | ||
var map = L.map('map').setView([47.26, 11.3933], 8); | ||
L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', { | ||
maxZoom: 19, | ||
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>' | ||
}).addTo(map); | ||
var markers = document.getElementById("markers"); | ||
for (option of markers.options) { | ||
var longitude = option.dataset.longitude; | ||
var latitude = option.dataset.latitude; | ||
if ((latitude > -180 && latitude < 180) && (longitude > -90 && longitude < 90)) { | ||
var marker = L.marker([latitude, longitude]).addTo(map).bindPopup(option.innerHtml); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{% extends "base.html" %} | ||
{% load static %} | ||
|
||
{% block scripts %} | ||
<script src="{% static "js/entities_map.js" %}"></script> | ||
{{ block.super }} | ||
{% endblock scripts %} | ||
|
||
{% block content %} | ||
<datalist id="markers"> | ||
{% for object in object_list %} | ||
{% if object.longitude and object.latitude %} | ||
<option value="{{ object.label | slugify }}" | ||
data-longitude="{{ object.longitude|floatformat:"4u" }}" | ||
data-latitude="{{ object.latitude|floatformat:"4u" }}"> | ||
<p> | ||
<b>{{ object.label }}</b> | ||
<p> | ||
<a href="{{ object.get_absolute_url }}">link</a> | ||
</p> | ||
</option> | ||
{% endif %} | ||
{% endfor %} | ||
</datalist> | ||
<div id="map" class="m-3" style="height: 80vh;"></div> | ||
{% endblock content %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters