Store maps (layers) settings in DB + display only project-relevant layers

This commit is contained in:
2020-08-18 23:12:40 +02:00
parent da3b16db46
commit b6ec8c908e
4 changed files with 80 additions and 18 deletions

View File

@@ -228,8 +228,10 @@ function initProject(sProjectCodeName, oFocusPost){
mimeType: 'application/json'
})
).done(function(aoMessages, aoTracks) {
initSpotMessages(aoMessages[0]['data']['messages'] || [], aoTracks[0], aoMessages[0]['desc']=='No Data');
updateSettingsPanel(aoMessages[0]['data']['last_update']);
var asData = aoMessages[0]['data'];
setMapLayers(asData['maps']);
initSpotMessages(asData['messages'] || [], aoTracks[0], aoMessages[0]['desc']=='No Data');
updateSettingsPanel(asData['last_update']);
});
//Show/Hide Poster Panel
@@ -353,21 +355,22 @@ function getElevWidth() {
return iPageWidth - iFeedPanelWidth - iSettingsPanelWidth - iLegendWidth - oElevRightMarging;
}
function setMapLayers(asLayers) {
oSpot.tmp('layers', {});
$.each(asLayers, function(iKey, asLayer) {
oSpot.tmp('layers')[oSpot.lang('map_'+asLayer.codename)] = L.tileLayer(self.tmp('tile_api'), {
id: asLayer.geo_name,
minZoom: parseInt(asLayer.min_zoom),
maxZoom: parseInt(asLayer.max_zoom),
attribution: asLayer.attribution
});
});
}
function initSpotMessages(aoMessages, aoTracks, bNoFeed) {
//Tile layers
aoLayers = {};
aoLayers[oSpot.lang('map_satellite')] = L.tileLayer(self.tmp('tile_api'), {id: 'mapbox.satellite-streets', minZoom: 0, maxZoom: 19});
aoLayers[oSpot.lang('map_otm')] = L.tileLayer(self.tmp('tile_api'), {id: 'opentopomap', minZoom: 2, maxZoom: 19});
aoLayers[oSpot.lang('map_ign_france')] = L.tileLayer(self.tmp('tile_api'), {id: 'ign.fr', minZoom: 0, maxZoom: 18, tileSize: 256});
aoLayers[oSpot.lang('map_ign_spain')] = L.tileLayer(self.tmp('tile_api'), {id: 'ign.es', minZoom: 1, maxZoom: 20});
aoLayers[oSpot.lang('map_linz')] = L.tileLayer(self.tmp('tile_api'), {id: 'linz', maxZoom: 17, continuousWorld: true, attribution: 'Sourced from LINZ. CC BY 4.0'});
aoLayers[oSpot.lang('map_usgs')] = L.tileLayer(self.tmp('tile_api'), {id: 'usgs', minZoom: 1, maxZoom: 16});
//aoLayers[oSpot.lang('map_natgeo')] = L.tileLayer(self.tmp('tile_api'), {id: 'natgeo.pct', minZoom: 5, maxZoom: 14});
//Map
var oMap = L.map(self.tmp('$Map')[0], {
layers: [aoLayers[oSpot.lang('map_satellite')]],
layers: [oSpot.tmp('layers')[oSpot.lang('map_satellite')]],
attributionControl: false,
zoomControl: false
});
@@ -465,7 +468,7 @@ function initSpotMessages(aoMessages, aoTracks, bNoFeed) {
}
//Controls: Tiles (layers): Add & Move to Settings Panel
L.control.layers(aoLayers, null, {position: 'topleft'}).addTo(oMap);
L.control.layers(oSpot.tmp('layers'), null, {position: 'topleft'}).addTo(oMap);
$('#layers').empty().append($('.leaflet-control-layers-list .leaflet-control-layers-base'));
//Actual Tracks: Track with corresponding colors