add new templatetag to display a map centered on a place

This commit is contained in:
Frédéric Péters 2018-06-22 13:21:36 +02:00
parent bc49366139
commit 5a2ea72886
1 changed files with 12 additions and 1 deletions

View File

@ -34,7 +34,7 @@ from django.utils.timezone import is_naive, make_aware
from django.utils.safestring import mark_safe
from combo.apps.dashboard.models import DashboardCell
from combo.apps.maps.models import MapLayer
from combo.apps.maps.models import Map, MapLayer
from combo.data.models import Page, ConfigJsonCell
from combo.public.views import render_cell
from combo.utils import requests
@ -646,3 +646,14 @@ def get_gnm_collectivities():
collectivities.append({'url': service.get('url'), 'label': matching_hobo['title']})
collectivities.sort(key=lambda x: x['label'])
return collectivities
@register.inclusion_tag('combo/gnm/place_map.html')
def gnm_place_map(lat, lng):
map_cell = Map()
map_cell.initial_zoom = '17'
map_cell.min_zoom = '17'
map_cell.max_zoom = '17'
context = map_cell.get_cell_extra_context({})
context['init_lat'] = lat
context['init_lng'] = lng
return context