Closed ErwinKomen closed 2 years ago
Needed for this is a translation from Kloeke-code to coordinates.
LemmaMapView
entries
with fields:
trefwoord
: the trefwoord that determines the icon (gif) for this data pointwoord
: the dialect word that may pop up when hovering over this data pointstad
: the name of the stad (could also be shown, if needed)point
: the coordinates (in WGS84) for this data tpointlemma_map
(in diadict.js) should now use these data to show a mapHvdH heeft twee suggesties:
Okay, the above is implemented now, and there even is a popup showing! Next step:
mapview
'wbd.mapview',
to INSTALLED_APPS
MapView
in your views.py
from wbd.mapview.views import MapView
MapView
LemmaSearchForm
below in the example, and that this form is able to deal with is_valid()
url(r'^lemma/map/(?P<pk>\d+)/$', csrf_exempt(LemmaMapView.as_view()), name='lemmamap'),
from django.views.decorators.csrf import csrf_exempt
{% include 'mapview/map_view.html' %}
ru.mapview.lemma_map(this)
class LemmaMapView(MapView):
model = Lemma
modEntry = Entry
frmSearch = LemmaSearchForm
order_by = "trefwoord"
labelfield = "gloss"
def initialize(self):
# Entries with a 'form' value
self.add_entry('woord', 'str', 'woord', 'woord')
self.add_entry('stad', 'str', 'dialect__stad', 'dialectCity')
self.add_entry('kloeke', 'str', 'dialect__nieuw', 'dialectCode')
self.add_entry('aflevering', 'int', 'aflevering__id', 'aflevering')
self.add_entry('mijn', 'int', 'mijnlijst__id', 'mijn')
# Entries without a 'form' value
self.add_entry('trefwoord', 'str', 'trefwoord__woord')
self.add_entry('point', 'str', 'dialect__coordinate__point')
self.add_entry('place', 'str', 'dialect__coordinate__place')
def get_popup(self, entry):
"""Create a popup from the 'key' values defined in [initialize()]"""
pop_up = '<p class="h6">{}</p>'.format(entry['woord'])
pop_up += '<hr style="border: 1px solid green" />'
pop_up += '<p style="font-size: smaller;"><span style="color: purple;">{}</span> {}</p>'.format(
entry['kloeke'], entry['stad'])
return pop_up
A button to call the JS routine for the mapview app:
<a role="button" class="btn btn-xs" title="Toon trefwoorden op kaart"
onclick="ru.mapview.lemma_map(this);"
targeturl="{% url 'lemmamap' item.entry.lemma.id %}"
targetid="erwin"
>
<i class="far fa-map" style="color: brown;"></i>
</a>
When one lemma is chosen, add the possibility to get a visualization with a map. The map should show: