refs #22 support transparent and opacity fields for all tile server types in tileservers.php

merge-requests/2/head
Julien Veyssier 2017-06-12 18:46:16 +02:00
parent 17effd1d77
commit 8fbb3c9fc7
3 changed files with 47 additions and 29 deletions

View File

@ -7,7 +7,9 @@ $baseTileServers = [
// 'url' => '',
// 'attribution' => '',
// 'minzoom' => '',
// 'maxzoom' => ''
// 'maxzoom' => '',
// 'opacity' => '0-1',
// 'transparent' => 'true|false'
//),
//Array(
// 'name' => 'tilewms',
@ -135,7 +137,9 @@ $baseTileServers = [
'url' => 'http://{s}.tile.openstreetmap.fr/route500/{z}/{x}/{y}.png',
'attribution' => '&copy, Tiles © <a href="http://www.openstreetmap.fr">OpenStreetMap France</a>',
'minzoom' => '1',
'maxzoom' => '20'
'maxzoom' => '20',
'transparent' => 'true',
'opacity' => '0.5'
),
];
?>

View File

@ -207,7 +207,15 @@
var minz = parseInt($(this).attr('minzoom'));
var maxz = parseInt($(this).attr('maxzoom'));
var sattrib = $(this).attr('attribution');
baseLayers[sname] = new L.TileLayer(surl, {minZoom: minz, maxZoom: maxz, attribution: sattrib});
var stransparent = ($(this).attr('transparent') === 'true');
var sopacity = $(this).attr('opacity');
if (sopacity !== '') {
sopacity = parseFloat(sopacity);
}
else {
sopacity = 1;
}
baseLayers[sname] = new L.TileLayer(surl, {minZoom: minz, maxZoom: maxz, attribution: sattrib, opacity: sopacity, transparent: stransparent});
});
$('#basetileservers li[type=tilewms]').each(function() {
var sname = $(this).attr('name');
@ -216,7 +224,13 @@
var sversion = $(this).attr('version') || '1.1.1';
var stransparent = ($(this).attr('transparent') === 'true');
var sformat = $(this).attr('format') || 'image/png';
var sopacity = $(this).attr('opacity') || 1;
var sopacity = $(this).attr('opacity');
if (sopacity !== '') {
sopacity = parseFloat(sopacity);
}
else {
sopacity = 1;
}
var sattrib = $(this).attr('attribution') || '';
baseLayers[sname] = new L.tileLayer.wms(surl, {layers: slayers, version: sversion, transparent: stransparent, opacity: sopacity, format: sformat, attribution: sattrib});
});
@ -238,7 +252,15 @@
var minz = parseInt($(this).attr('minzoom'));
var maxz = parseInt($(this).attr('maxzoom'));
var sattrib = $(this).attr('attribution');
baseOverlays[sname] = new L.TileLayer(surl, {minZoom: minz, maxZoom: maxz, attribution: sattrib});
var stransparent = ($(this).attr('transparent') === 'true');
var sopacity = $(this).attr('opacity');
if (sopacity !== '') {
sopacity = parseFloat(sopacity);
}
else {
sopacity = 1;
}
baseOverlays[sname] = new L.TileLayer(surl, {minZoom: minz, maxZoom: maxz, attribution: sattrib, opacity: sopacity, transparent: stransparent});
});
$('#basetileservers li[type=overlaywms]').each(function() {
var sname = $(this).attr('name');
@ -247,7 +269,13 @@
var sversion = $(this).attr('version') || '1.1.1';
var stransparent = ($(this).attr('transparent') === 'true');
var sformat = $(this).attr('format') || 'image/png';
var sopacity = $(this).attr('opacity') || 1;
var sopacity = $(this).attr('opacity');
if (sopacity !== '') {
sopacity = parseFloat(sopacity);
}
else {
sopacity = 1;
}
var sattrib = $(this).attr('attribution') || '';
baseOverlays[sname] = new L.tileLayer.wms(surl, {layers: slayers, version: sversion, transparent: stransparent, opacity: sopacity, format: sformat, attribution: sattrib});
});

View File

@ -81,29 +81,15 @@ foreach($_['extrasymbols'] as $symbol){
echo '</ul>'."\n";
echo '<ul id="basetileservers" style="display:none">';
foreach($_['basetileservers'] as $ts){
echo '<li name="';
p($ts['name']);
echo '" type="';
p($ts['type']);
echo '" url="';
p($ts['url']);
echo '" layers="';
p($ts['layers']);
echo '" version="';
p($ts['version']);
echo '" format="';
p($ts['format']);
echo '" opacity="';
p($ts['opacity']);
echo '" transparent="';
p($ts['transparent']);
echo '" minzoom="';
p($ts['minzoom']);
echo '" maxzoom="';
p($ts['maxzoom']);
echo '" attribution="';
p($ts['attribution']);
echo '"></li>';
echo '<li';
foreach (Array('name', 'type', 'url', 'layers', 'version', 'format', 'opacity', 'transparent', 'minzoom', 'maxzoom', 'attribution') as $field) {
if (array_key_exists($field, $ts)) {
echo ' '.$field.'="';
p($ts[$field]);
echo '"';
}
}
echo '></li>';
}
echo '</ul>'."\n";