From 067148195b3767921c9cd1f3489b4823f35ce355 Mon Sep 17 00:00:00 2001 From: Julien Veyssier Date: Wed, 14 Jun 2017 19:12:42 +0200 Subject: [PATCH] refs #22 fix default transparency and opacity for all tile server types --- controller/tileservers.php | 1 + js/gpxedit.js | 46 +++++++++----------------------------- 2 files changed, 12 insertions(+), 35 deletions(-) diff --git a/controller/tileservers.php b/controller/tileservers.php index 32935d7..4d75348 100644 --- a/controller/tileservers.php +++ b/controller/tileservers.php @@ -136,6 +136,7 @@ $baseTileServers = [ 'type' => 'overlay', 'url' => 'http://{s}.tile.openstreetmap.fr/route500/{z}/{x}/{y}.png', 'attribution' => '©, Tiles © OpenStreetMap France', + 'opacity' => '0.5', 'minzoom' => '1', 'maxzoom' => '20', ), diff --git a/js/gpxedit.js b/js/gpxedit.js index 77a164b..ce09b20 100644 --- a/js/gpxedit.js +++ b/js/gpxedit.js @@ -209,7 +209,7 @@ var sattrib = $(this).attr('attribution'); var stransparent = ($(this).attr('transparent') === 'true'); var sopacity = $(this).attr('opacity'); - if (sopacity !== '') { + if (typeof sopacity !== typeof undefined && sopacity !== false && sopacity !== '') { sopacity = parseFloat(sopacity); } else { @@ -225,7 +225,7 @@ var stransparent = ($(this).attr('transparent') === 'true'); var sformat = $(this).attr('format') || 'image/png'; var sopacity = $(this).attr('opacity'); - if (sopacity !== '') { + if (typeof sopacity !== typeof undefined && sopacity !== false && sopacity !== '') { sopacity = parseFloat(sopacity); } else { @@ -267,15 +267,9 @@ var minz = parseInt($(this).attr('minzoom')); var maxz = parseInt($(this).attr('maxzoom')); var sattrib = $(this).attr('attribution'); - var stransparent; - if ($(this).attr('transparent') !== '') { - stransparent = ($(this).attr('transparent') === 'true'); - } - else { - stransparent = true; - } + var stransparent = ($(this).attr('transparent') === 'true'); var sopacity = $(this).attr('opacity'); - if (sopacity !== '') { + if (typeof sopacity !== typeof undefined && sopacity !== false && sopacity !== '') { sopacity = parseFloat(sopacity); } else { @@ -288,21 +282,15 @@ var surl = $(this).attr('url'); var slayers = $(this).attr('layers') || ''; var sversion = $(this).attr('version') || '1.1.1'; - var stransparent; - if ($(this).attr('transparent') !== '') { - stransparent = ($(this).attr('transparent') === 'true'); - } - else { - stransparent = true; - } - var sformat = $(this).attr('format') || 'image/png'; + var stransparent = ($(this).attr('transparent') === 'true'); var sopacity = $(this).attr('opacity'); - if (sopacity !== '') { + if (typeof sopacity !== typeof undefined && sopacity !== false && sopacity !== '') { sopacity = parseFloat(sopacity); } else { sopacity = 0.4; } + var sformat = $(this).attr('format') || 'image/png'; var sattrib = $(this).attr('attribution') || ''; baseOverlays[sname] = new L.tileLayer.wms(surl, {layers: slayers, version: sversion, transparent: stransparent, opacity: sopacity, format: sformat, attribution: sattrib}); }); @@ -312,15 +300,9 @@ var surl = $(this).attr('url'); var sminzoom = $(this).attr('minzoom') || '1'; var smaxzoom = $(this).attr('maxzoom') || '20'; - var stransparent; - if ($(this).attr('transparent') !== '') { - stransparent = ($(this).attr('transparent') === 'true'); - } - else { - stransparent = true; - } + var stransparent = ($(this).attr('transparent') === 'true'); var sopacity = $(this).attr('opacity'); - if (sopacity !== '') { + if (typeof sopacity !== typeof undefined && sopacity !== false && sopacity !== '') { sopacity = parseFloat(sopacity); } else { @@ -337,16 +319,10 @@ var smaxzoom = $(this).attr('maxzoom') || '20'; var slayers = $(this).attr('layers') || ''; var sversion = $(this).attr('version') || '1.1.1'; - var stransparent; - if ($(this).attr('transparent') !== '') { - stransparent = ($(this).attr('transparent') === 'true'); - } - else { - stransparent = true; - } var sformat = $(this).attr('format') || 'image/png'; + var stransparent = ($(this).attr('transparent') === 'true'); var sopacity = $(this).attr('opacity'); - if (sopacity !== '') { + if (typeof sopacity !== typeof undefined && sopacity !== false && sopacity !== '') { sopacity = parseFloat(sopacity); } else {