gluon-config-mode-geo-location-with-map: add site.conf zoom parameter

This commit is contained in:
Jan-Tarek Butt 2018-07-22 15:11:27 +02:00
parent 33573168fa
commit 6729624b68
3 changed files with 31 additions and 19 deletions

View File

@ -37,29 +37,36 @@ config_mode.geo_location.show_altitude \: optional
The remaining options are only valid for the The remaining options are only valid for the
``gluon-config-mode-geo-location-with-map`` package: ``gluon-config-mode-geo-location-with-map`` package:
config_mode.geo_location.map_lon \: optional config_mode.geo_location.map.lon \: optional
- represents the default longitude value to use for the center of the map. - represents the default longitude value to use for the center of the map.
- defaults to ``0.0`` - defaults to ``0.0``
config_mode.geo_location.map_lat \: optional config_mode.geo_location.map.lat \: optional
- represents the default latitude value to use for the center of the map. - represents the default latitude value to use for the center of the map.
- defaults to ``0.0`` - defaults to ``0.0``
The map will center to the position defined in map_lat and map_lon, unless a The map will center to the position defined in **lat** and **lon**, unless a
location was already defined. The new defined location will become the location was already defined. The new defined location will become the
new center. new center.
config_mode.geo_location.openlayers_js_url \: optional config_mode.geo_location.map.zoom \: optional
- Natural number between ``0-17`` for the zoom level of the map.
- defaults to ``12``
config_mode.geo_location.map.openlayers_js_url \: optional
- ``url`` set an URL for OpenStreetMap layers. - ``url`` set an URL for OpenStreetMap layers.
- defaults to ``http://dev.openlayers.org/OpenLayers.js`` - defaults to ``http://dev.openlayers.org/OpenLayers.js``
Example:: Example::
config_mode = { config_mode = {
geo_location = { geo_location = {
map_lon = 52.951947558, map = {
map_lat = 7.844238281, lon = 52.951947558,
openlayers_js_url = 'http://osm.ffnw.de/.static/ol/OpenLayers.js', lat = 7.844238281,
show_altitude = true, zoom = 12,
}, openlayers_js_url = 'http://osm.ffnw.de/.static/ol/OpenLayers.js',
}, },
show_altitude = true,
},
},

View File

@ -14,18 +14,22 @@ return function(form, uci)
if uci_longitude ~= nil then if uci_longitude ~= nil then
return uci_longitude return uci_longitude
end end
return site.config_mode.geo_location.map_lon(0.0) return site.config_mode.geo_location.map.lon(0.0)
end end
local function show_lat() local function show_lat()
if uci_latitude ~= nil then if uci_latitude ~= nil then
return uci_latitude return uci_latitude
end end
return site.config_mode.geo_location.map_lat(0.0) return site.config_mode.geo_location.map.lat(0.0)
end
local function site_zoom()
return site.config_mode.geo_location.map.zoom(12)
end end
local function show_olurl() local function show_olurl()
return site.config_mode.geo_location.openlayers_js_url('http://dev.openlayers.org/OpenLayers.js') return site.config_mode.geo_location.map.openlayers_js_url('http://dev.openlayers.org/OpenLayers.js')
end end
#endif #endif
@ -58,7 +62,7 @@ return function(form, uci)
<div id="locationPickerMap" style="width:100%; height:300px; display: none;"></div> <div id="locationPickerMap" style="width:100%; height:300px; display: none;"></div>
<script type="text/javascript" src="/static/osm.js"></script> <script type="text/javascript" src="/static/osm.js"></script>
<script type="text/javascript"> <script type="text/javascript">
var latitude=]] .. show_lon() .. ",longitude=" .. show_lat() .. [[; var latitude=]] .. show_lon() .. ",longitude=" .. show_lat() .. ",zoom=" .. site_zoom() .. [[;
function loadedContent() { function loadedContent() {
document.addEventListener("DOMContentLoaded", showMap, false); document.addEventListener("DOMContentLoaded", showMap, false);
setInterval(function() { setInterval(function() {

View File

@ -1,6 +1,7 @@
need_boolean(in_site({'config_mode', 'geo_location', 'show_altitude'}), false) need_boolean(in_site({'config_mode', 'geo_location', 'show_altitude'}), false)
#ifdef WITHMAP #ifdef WITHMAP
need_string(in_site({'config_mode', 'geo_location', 'openlayers_js_url'}), false) need_string(in_site({'config_mode', 'geo_location', 'map', 'openlayers_js_url'}), false)
need_number(in_site({'config_mode', 'geo_location', 'map_lon'}), false) need_number(in_site({'config_mode', 'geo_location', 'map', 'lon'}), false)
need_number(in_site({'config_mode', 'geo_location', 'map_lat'}), false) need_number(in_site({'config_mode', 'geo_location', 'map', 'lat'}), false)
need_number(in_site({'config_mode', 'geo_location', 'map', 'zoom'}), false)
#endif #endif