Refactoring osm map

This commit is contained in:
reverend 2020-09-12 11:42:18 +02:00
parent dcfb329c5a
commit fed90d4f7b
2 changed files with 9 additions and 5 deletions

View File

@ -92,6 +92,10 @@ class Place (models.Model):
tags = TaggableManager(blank=True) tags = TaggableManager(blank=True)
def get_absolute_url(self):
return reverse('place_detail', kwargs={'pk': self.pk})
@classmethod @classmethod
# Get center position of LP-geocoordinates. # Get center position of LP-geocoordinates.
def average_latlon(cls, place_list): def average_latlon(cls, place_list):

View File

@ -11,20 +11,20 @@
}), }),
], ],
view: new ol.View({ view: new ol.View({
center: ol.proj.fromLonLat([{{place_map_center.longitude}}, {{place_map_center.latitude}}]), center: ol.proj.fromLonLat([{{config.map_center.longitude}}, {{config.map_center.latitude}}]),
zoom: 9 zoom: 9
}) })
}); });
var vectorSource = new ol.source.Vector({ var vectorSource = new ol.source.Vector({
features: [ features: [
{% for place in place_list %} {% for config.point in point_list %}
new ol.Feature({ new ol.Feature({
geometry: new ol.geom.Point( geometry: new ol.geom.Point(
ol.proj.fromLonLat([{{place.longitude}},{{place.latitude}}]) ol.proj.fromLonLat([{{point.longitude}},{{point.latitude}}])
), ),
url: '{% url 'place_detail' pk=place.pk %}', url: '{{point.get_absolute_url}}',
name: '{{place.name}}' name: '{{point.name}}'
}), }),
{% endfor %} {% endfor %}
] ]