Skip to content

Commit

Permalink
feat(apis_entities): introduce a map view for E53_Place entities
Browse files Browse the repository at this point in the history
  • Loading branch information
b1rger committed Sep 25, 2024
1 parent e9a3111 commit ba68493
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
13 changes: 13 additions & 0 deletions apis_core/apis_entities/static/js/E53_Place_detail_map.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
document.addEventListener('DOMContentLoaded', function() {
mapel = document.getElementById("map");
if (mapel) {
var markercontent = mapel.innerHTML;
var map = L.map('map').setView([mapel.dataset.latitude, mapel.dataset.longitude], 13);

L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);

L.marker([mapel.dataset.latitude, mapel.dataset.longitude]).addTo(map).bindPopup(markercontent).openPopup();
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{% extends "apis_core/apis_entities/abstractentity_detail.html" %}
{% load static %}

{% block scripts %}
{{ block.super }}
<script src="{% static "js/E53_Place_detail_map.js" %}"></script>
{% endblock %}

{% block col-zero %}
<div class="card">
<div class="card-body">{% include "generic/partials/object_table.html" %}</div>
<div class="card-body pt-0">
<table class="table table-hover table-bordered">
{% if object.latitude and object.longitude %}
<td id="map"
style="height: 300px"
data-longitude="{{ object.longitude|floatformat:"4u" }}"
data-latitude="{{ object.latitude|floatformat:"4u" }}">{{ object }}</td>
{% endif %}
</table>
</div>
<div class="card-footer">{% include "apis_entities/partials/linked_open_data.html" %}</div>
</div>
{% endblock %}

0 comments on commit ba68493

Please sign in to comment.