Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show hidden map if it's requested by URL wtracks?map=... #27

Merged
merged 2 commits into from
Dec 24, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 31 additions & 16 deletions js/wtracks.js
Original file line number Diff line number Diff line change
Expand Up @@ -1368,6 +1368,11 @@ $(function(){
var params = "";
if (isChecked("#wtshare-map")) {
params += "&map=" + encodeURIComponent(baseLayer);
overlays = []
objectForEach(overlaysOn, function(oname, oon) {
if (oon) overlays.push(oname);
});
params += "&overlays=" + encodeURIComponent(overlays.join(','));
}
if (isChecked("#wtshare-enc")) {
var pwd = Math.random().toString(36).substring(2);
Expand Down Expand Up @@ -1687,7 +1692,7 @@ $(function(){
} else {
input = undefined;
}
if (!input || (prunedist === undefined) || isNaN(prunedist)) {
if (!input || (prunedist === undefined) || isNaN(prunedist)) {
alert("Enter distance in meters");
prunedistelt.focus();
return;
Expand Down Expand Up @@ -2059,8 +2064,11 @@ $(function(){
// Add maps and overlays
var baseLayers = {};
var overlays = {};
var baseLayer = getVal("wt.baseLayer", config.display.map);
var requestedMap = getParameterByName("map")
var requestedOverlays = (getParameterByName("overlays") || "").split(',')
mapsForEach(function(name, props) {
if (props.on) {
if (props.on || name == baseLayer || name === requestedMap || requestedOverlays.includes(name)) {
var inList = props.in == MAP_MY ? mymaps : config.maps;
var tile = getProvider(inList[name]);
if (tile) {
Expand All @@ -2080,7 +2088,6 @@ $(function(){

// ----------------------

var baseLayer = getVal("wt.baseLayer", config.display.map);
var initialLayer = baseLayers[baseLayer] || baseLayers[config.display.map];
if (!initialLayer) {
//var availableLayerNames = "";
Expand Down Expand Up @@ -2175,17 +2182,26 @@ $(function(){
.remove()
}

objectForEach(overlaysOn, function(oname, oon) {
var ovl = overlays[oname];
if (ovl) {
if (oon) {
if (requestedOverlays) {
requestedOverlays.forEach(function(oname) {
var ovl = overlays[oname];
if (ovl) {
map.addLayer(ovl);
}
} else {
// doesn't exist anymore, delete it
setOverlay(oname, undefined);
}
});
});
} else {
objectForEach(overlaysOn, function(oname, oon) {
var ovl = overlays[oname];
if (ovl) {
if (oon) {
map.addLayer(ovl);
}
} else {
// doesn't exist anymore, delete it
setOverlay(oname, undefined);
}
});
}

map.on("overlayadd", function(e) {
ga('send', 'event', 'map', 'overlay', e.name);
Expand Down Expand Up @@ -2890,7 +2906,7 @@ $(function(){
setStatus("Loading..", { spinner: true });
$("#edit-tools").hide();
var bounds;
var merge = loadCount > 0 ||  isChecked("#merge");
var merge = loadCount > 0 || isChecked("#merge");
loadCount++;
if (!merge) {
newTrack();
Expand Down Expand Up @@ -3954,10 +3970,9 @@ $(function(){
newTrack();

// map parameter
var mapname = getParameterByName("map");
if (mapname) {
if (requestedMap) {
ga('send', 'event', 'file', 'load-mapparam');
changeBaseLayer(mapname);
changeBaseLayer(requestedMap);
}

var url = getParameterByName("url");
Expand Down