misc: add device geolocation as initial position for markers map (#89641)
gitea/wcs/pipeline/head This commit looks good
Details
gitea/wcs/pipeline/head This commit looks good
Details
This commit is contained in:
parent
b9b6912385
commit
62d178f73c
|
@ -1396,6 +1396,29 @@ def test_form_item_dynamic_map_data_source(pub, http_requests):
|
|||
assert len(resp_geojson.json['features']) == 2
|
||||
|
||||
|
||||
def test_form_item_map_data_source_initial_position(pub, http_requests):
|
||||
NamedDataSource.wipe()
|
||||
data_source = NamedDataSource(name='foobar')
|
||||
data_source.data_source = {
|
||||
'type': 'geojson',
|
||||
'value': 'http://remote.example.net/geojson',
|
||||
}
|
||||
data_source.id_property = 'id'
|
||||
data_source.label_template_property = '{{ text }}'
|
||||
data_source.cache_duration = '5'
|
||||
data_source.store()
|
||||
|
||||
formdef = create_formdef()
|
||||
formdef.fields = [
|
||||
fields.ItemField(id='1', label='map', display_mode='map', initial_position='geoloc'),
|
||||
]
|
||||
formdef.store()
|
||||
formdef.data_class().wipe()
|
||||
app = get_app(pub)
|
||||
resp = app.get('/test/')
|
||||
assert resp.pyquery('[data-init_with_geoloc="true"]')
|
||||
|
||||
|
||||
def test_form_item_timetable_data_source(pub, http_requests):
|
||||
NamedDataSource.wipe()
|
||||
data_source = NamedDataSource(name='foobar')
|
||||
|
|
|
@ -613,6 +613,7 @@ class ItemField(WidgetField, MapOptionsMixin, ItemFieldMixin, ItemWithImageField
|
|||
title=_('Initial Position'),
|
||||
options=(
|
||||
('', _('Default position (from markers)'), ''),
|
||||
('geoloc', _('Device geolocation'), 'geoloc'),
|
||||
('template', _('From template'), 'template'),
|
||||
),
|
||||
value=self.initial_position or '',
|
||||
|
|
Loading…
Reference in New Issue