Pushing map parameters to DB

This commit is contained in:
2021-12-20 21:27:33 +01:00
parent e384162c80
commit 0e06b0e591
14 changed files with 135 additions and 83 deletions

View File

@@ -106,16 +106,19 @@ oSpot.onKeydown = function(oEvent) {
}
function toggleFeedPanel(bShow, sMapAction) {
bOldValue = isFeedPanelOpen();
self.tmp('$Projects').toggleClass('with-feed', (typeof bShow === 'undefined')?null:bShow);
bShow = isFeedPanelOpen();
oSpot.onResize();
bNewValue = isFeedPanelOpen();
sMapAction = sMapAction || 'panTo';
switch(sMapAction) {
case 'none': break;
case 'panTo': oSpot.tmp('map').panBy([(isFeedPanelOpen()?1:-1)*self.tmp('$Feed').outerWidth(true)/2, 0], {duration: 0.5}); break;
case 'panToInstant': oSpot.tmp('map').panBy([(isFeedPanelOpen()?1:-1)*self.tmp('$Feed').outerWidth(true)/2, 0]); break;
case 'fitBounds': oSpot.tmp('map').fitBounds(self.tmp('track').getBounds(), {paddingTopLeft: L.point(5, self.tmp('marker_size').height + 5), paddingBottomRight: L.point(self.tmp('$Feed').outerWidth(true) + 5, 5)}); break;
if(bOldValue != bNewValue) {
oSpot.onResize();
sMapAction = sMapAction || 'panTo';
switch(sMapAction) {
case 'none': break;
case 'panTo': oSpot.tmp('map').panBy([(isFeedPanelOpen()?1:-1)*self.tmp('$Feed').outerWidth(true)/2, 0], {duration: 0.5}); break;
case 'panToInstant': oSpot.tmp('map').panBy([(isFeedPanelOpen()?1:-1)*self.tmp('$Feed').outerWidth(true)/2, 0]); break;
case 'fitBounds': oSpot.tmp('map').fitBounds(self.tmp('track').getBounds(), {paddingTopLeft: L.point(5, self.tmp('marker_size').height + 5), paddingBottomRight: L.point(self.tmp('$Feed').outerWidth(true) + 5, 5)}); break;
}
}
}
@@ -124,15 +127,18 @@ function isFeedPanelOpen() {
}
function toggleSettingsPanel(bShow, sMapAction) {
bOldValue = isSettingsPanelOpen();
self.tmp('$Projects').toggleClass('with-settings', (typeof bShow === 'undefined')?null:bShow);
oSpot.onResize();
bShow = isSettingsPanelOpen();
sMapAction = sMapAction || 'panTo';
switch(sMapAction) {
case 'none': break;
case 'panTo': oSpot.tmp('map').panBy([(isSettingsPanelOpen()?-1:1)*self.tmp('$Settings').outerWidth(true)/2, 0], {duration: 0.5}); break;
case 'panToInstant': oSpot.tmp('map').panBy([(isSettingsPanelOpen()?-1:1)*self.tmp('$Settings').outerWidth(true)/2, 0]); break;
bNewValue = isSettingsPanelOpen();
if(bOldValue != bNewValue) {
oSpot.onResize();
sMapAction = sMapAction || 'panTo';
switch(sMapAction) {
case 'none': break;
case 'panTo': oSpot.tmp('map').panBy([(isSettingsPanelOpen()?-1:1)*self.tmp('$Settings').outerWidth(true)/2, 0], {duration: 0.5}); break;
case 'panToInstant': oSpot.tmp('map').panBy([(isSettingsPanelOpen()?-1:1)*self.tmp('$Settings').outerWidth(true)/2, 0]); break;
}
}
}
@@ -163,7 +169,6 @@ function initPage(asHash) {
self.tmp('$Title', $('#title'));
self.tmp('updatable', true);
self.tmp('out-of-data', false);
self.tmp('tile_api', getWmtsApiUrl('{id}', '{y}', '{x}', '{z}'));
self.tmp('markers', 'object');
self.tmp('trail-markers', 'object');
self.tmp('marker_size', {width: 32, height: 32});
@@ -366,14 +371,17 @@ function getElevWidth() {
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,
var sMapName = oSpot.lang('map_'+asLayer.codename);
var asMapOptions = {
tileSize: parseInt(asLayer.tile_size),
zoomOffset: (parseInt(asLayer.tile_size) / -256 + 1),
zoomOffset: (parseInt(asLayer.tile_size) / -256 + 1),
minZoom: parseInt(asLayer.min_zoom),
maxZoom: parseInt(asLayer.max_zoom),
attribution: asLayer.attribution
});
}
if(asLayer.token != '') asMapOptions.token = asLayer.token;
oSpot.tmp('layers')[sMapName] = L.tileLayer(asLayer.pattern, asMapOptions);
});
}
@@ -410,9 +418,9 @@ function initSpotMessages(aoMessages, aoTracks) {
//Controls: Feed Panel
var oFeedPanel = L.control({position: bIsMobile?'bottomright':'topright'});
var $PostButton = $('#feed-button').clone();
$PostButton.click(toggleFeedPanel);
oFeedPanel.onAdd = function(oMap) {return $PostButton[0];};
var $FeedButton = $('#feed-button').clone();
$FeedButton.click(toggleFeedPanel);
oFeedPanel.onAdd = function(oMap) {return $FeedButton[0];};
oFeedPanel.addTo(oMap);
//Controls: Legend
@@ -868,7 +876,7 @@ function getPost(asPost) {
.append(bTimeDiff?$('<p>').addIcon('fa-timezone', true).append(oSpot.lang('local_time', sAbsTimeLocal)):'')
.append($('<a>', {'class':'drill'})
.append((!asPost.weather_icon || asPost.weather_icon=='unknown')?'':$('<span>', {'class':'weather', 'title':oSpot.lang(asPost.weather_cond)}).addIcon('fa-'+asPost.weather_icon).append($('<span>').text(asPost.weather_temp+'°C')))
.append($('<img>', {'class':'staticmap', title: oSpot.lang('click_zoom'), src: getWmtsApiUrl('static', asPost.latitude, asPost.longitude, 13)}))
.append($('<img>', {'class':'staticmap', title: oSpot.lang('click_zoom'), src: asPost.static_img_url}))
.append($('<span>', {'class': 'drill-icon fa-stack'})
.addIcon('fa-message fa-stack-2x')
.addIcon('fa-message-in fa-stack-1x fa-rotate-270')
@@ -961,10 +969,6 @@ function getPost(asPost) {
return $Post;
}
function getWmtsApiUrl(sMapId, iLat, iLng, iZoom) {
return self.consts.geo_server+'?a=tile&id='+sMapId+'&z='+iZoom+'&x='+iLng+'&y='+iLat;
}
function getMediaLink(asData, sType) {
var bTimeDiff = (asData.posted_on_formatted && asData.posted_on_formatted_local != asData.posted_on_formatted);