refs #22 almost finished WMS support for user custom servers

merge-requests/2/head
Julien Veyssier 2017-06-13 16:46:37 +02:00
parent 8c76f7e3c3
commit 61d055d4bd
4 changed files with 115 additions and 85 deletions

View File

@ -872,26 +872,26 @@ div#ho button {
margin-top: 3px;
margin-bottom: 3px;
}
#overlayserveradd, #tileserveradd, #tileserverwmsadd, #overlayserverwmsadd {
#overlayserveradd, #tileserveradd, #tilewmsserveradd, #overlaywmsserveradd {
display: grid;
grid-template-columns: 35% 65%;
}
#tileserveradd p,
#tileserverwmsadd p,
#overlayserverwmsadd p,
#tilewmsserveradd p,
#overlaywmsserveradd p,
#overlayserveradd p{
margin-top: auto;
margin-bottom: auto;
}
#tileserveradd input[type=checkbox],
#tileserverwmsadd input[type=checkbox],
#overlayserverwmsadd input[type=checkbox],
#tilewmsserveradd input[type=checkbox],
#overlaywmsserveradd input[type=checkbox],
#overlayserveradd input[type=checkbox]{
margin-right: auto;
}
#tileserveradd input[type=text],
#tileserverwmsadd input[type=text],
#overlayserverwmsadd input[type=text],
#tilewmsserveradd input[type=text],
#overlaywmsserveradd input[type=text],
#overlayserveradd input[type=text]{
width:100%;
}

View File

@ -237,23 +237,23 @@
// add custom layers
$('#tileserverlist li').each(function() {
var sname = $(this).attr('servername');
var surl = $(this).attr('title');
var surl = $(this).attr('url');
var sminzoom = $(this).attr('minzoom') || '1';
var smaxzoom = $(this).attr('maxzoom') || '20';
var sattrib = $(this).attr('attribution') || '';
baseLayers[sname] = new L.TileLayer(surl,
{minZoom: sminzoom, maxZoom: smaxzoom, attribution: sattrib});
});
$('#tileserverwmslist li').each(function() {
$('#tilewmsserverlist li').each(function() {
var sname = $(this).attr('servername');
var surl = $(this).attr('title');
var surl = $(this).attr('url');
var sminzoom = $(this).attr('minzoom') || '1';
var smaxzoom = $(this).attr('maxzoom') || '20';
var slayers = $(this).attr('layers') || '';
var sversion = $(this).attr('version') || '1.1.1';
var sformat = $(this).attr('format') || 'image/png';
var sattrib = $(this).attr('attribution') || '';
baseLayers[sname] = new L.tilelayer.wms(surl,
baseLayers[sname] = new L.tileLayer.wms(surl,
{format: sformat, version: sversion, layers: slayers, minZoom: sminzoom, maxZoom: smaxzoom, attribution: sattrib});
});
gpxedit.baseLayers = baseLayers;
@ -309,7 +309,7 @@
// add custom overlays
$('#overlayserverlist li').each(function() {
var sname = $(this).attr('servername');
var surl = $(this).attr('title');
var surl = $(this).attr('url');
var sminzoom = $(this).attr('minzoom') || '1';
var smaxzoom = $(this).attr('maxzoom') || '20';
var stransparent;
@ -330,9 +330,9 @@
baseOverlays[sname] = new L.TileLayer(surl,
{minZoom: sminzoom, maxZoom: smaxzoom, transparent: stransparent, opcacity: sopacity, attribution: sattrib});
});
$('#overlayserverwmslist li').each(function() {
$('#overlaywmsserverlist li').each(function() {
var sname = $(this).attr('servername');
var surl = $(this).attr('title');
var surl = $(this).attr('url');
var sminzoom = $(this).attr('minzoom') || '1';
var smaxzoom = $(this).attr('maxzoom') || '20';
var slayers = $(this).attr('layers') || '';
@ -461,6 +461,7 @@
// so, the content is lost when it's closed
gpxedit.map.on('popupopen', function(e) {
var id = e.popup._source.gpxedit_id;
if (id !== undefined && gpxedit.layersData.hasOwnProperty(id)) {
//var id = parseInt(e.popup.getContent().match(/layerid="(\d+)"/)[1]);
var buttonParent = $('button.popupOkButton[layerid=' + id + ']').parent();
buttonParent.find('input.layerName').val(gpxedit.layersData[id].name);
@ -481,6 +482,7 @@
buttonParent.find('input.layerLat').val(latlng.lat.toFixed(6));
buttonParent.find('input.layerLon').val(latlng.lng.toFixed(6));
}
}
});
gpxedit.map.on('baselayerchange',saveOptions);
@ -1208,7 +1210,7 @@
var surl = $('#'+type+'serverurl').val();
var sminzoom = $('#'+type+'minzoom').val();
var smaxzoom = $('#'+type+'maxzoom').val();
var stransparent = $('#'+type+'transparent').val() || '';
var stransparent = $('#'+type+'transparent').is(':checked');
var sopacity = $('#'+type+'opacity').val() || '';
var sformat = $('#'+type+'format').val() || '';
var sversion = $('#'+type+'version').val() || '';
@ -1260,14 +1262,28 @@
if (type === 'tile') {
// add tile server in leaflet control
var newlayer = new L.TileLayer(surl,
{maxZoom: 18, attribution: 'custom '+type+' server'});
{minZoom: sminzoom, maxZoom: smaxzoom, attribution: ''});
gpxedit.activeLayers.addBaseLayer(newlayer, sname);
gpxedit.baseLayers[sname] = newlayer;
}
else {
else if (type === 'tilewms'){
// add tile server in leaflet control
var newlayer = new L.tileLayer.wms(surl,
{format: sformat, version: sversion, layers: slayers, minZoom: sminzoom, maxZoom: smaxzoom, attribution: ''});
gpxedit.activeLayers.addBaseLayer(newlayer, sname);
gpxedit.overlayLayers[sname] = newlayer;
}
if (type === 'overlay') {
// add tile server in leaflet control
var newlayer = new L.TileLayer(surl,
{maxZoom: 18, attribution: 'custom '+type+' server'});
{minZoom: sminzoom, maxZoom: smaxzoom, transparent: stransparent, opcacity: sopacity, attribution: ''});
gpxedit.activeLayers.addOverlay(newlayer, sname);
gpxedit.baseLayers[sname] = newlayer;
}
else if (type === 'overlaywms'){
// add tile server in leaflet control
var newlayer = new L.tileLayer.wms(surl,
{layers: slayers, version: sversion, transparent: stransparent, opacity: sopacity, format: sformat, attribution: '', minZoom: sminzoom, maxZoom: smaxzoom});
gpxedit.activeLayers.addOverlay(newlayer, sname);
gpxedit.overlayLayers[sname] = newlayer;
}
@ -1652,13 +1668,13 @@
addTileServer('overlay');
});
$('body').on('click', '#tileserverwmslist button', function(e) {
$('body').on('click', '#tilewmsserverlist button', function(e) {
deleteTileServer($(this).parent(), 'tilewms');
});
$('#addtileserverwms').click(function() {
addTileServer('tilewms');
});
$('body').on('click', '#overlayserverwmslist button', function(e) {
$('body').on('click', '#overlaywmsserverlist button', function(e) {
deleteTileServer($(this).parent(), 'overlaywms');
});
$('#addoverlayserverwms').click(function() {

View File

@ -28,12 +28,12 @@
"Use defined symbols instead of default symbol" : "Utilise les symboles définis au lieu du symbole par défaut",
"Use defined symbols" : "Utiliser les symboles définis",
"Custom tile servers" : "Serveurs de tuiles personnels",
"Custom overlay servers" : "Serveurs de revêtements personnels",
"Server name (for example 'my custom server')" : "Nom du serveur ('mon super serveur' par exemple)",
"Server url ('http://tile.server.org/cycle/{z}/{x}/{y}.png')" : "URL du serveur ('http://tile.server.org/cycle/{z}/{x}/{y}.png')",
"Server url ('http://overlay.server.org/cycle/{z}/{x}/{y}.png')" : "URL du serveur ('http://overlay.server.org/cycle/{z}/{x}/{y}.png')",
"Server name" : "Nom du serveur",
"For example : my custom server" : "Par exemple : mon super serveur",
"Server url" : "URL du serveur",
"For example : http://tile.server.org/cycle/{z}/{x}/{y}.png" : "Par exemple : http://tile.server.org/cycle/{z}/{x}/{y}.png",
"For example : http://overlay.server.org/cycle/{z}/{x}/{y}.png" : "Par exemple : http://overlay.server.org/cycle/{z}/{x}/{y}.png",
"Add" : "Ajouter",
"Your servers" : "Vos serveurs",
"Delete" : "Supprimer",
"Default symbol for waypoints when value is not set" : "Symbole par défaut pour les étapes si non défini",
"Clear map before loading" : "Vider la carte avant de charger",
@ -54,6 +54,20 @@
"Accepted image format : png" : "Format d'image accepté : png",
"New symbol name" : "Nom du nouveau symbole",
"Approximate new points elevations" : "Approximer l'altitude des nouveaux points",
"Min zoom (1-20)" : "Zoom mini (1-20)",
"Opacity (0.0-1.0)" : "Opacité (0.0-1.0)",
"Format" : "Format",
"Custom overlay tile servers" : "Serveurs de revêtement personnels",
"Your tile servers" : "Vos serveurs de tuiles personnels",
"WMS version" : "Version de WMS",
"Your WMS tile servers" : "Vos serveurs de tuiles WMS personnels",
"Max zoom (1-20)" : "Zoom maxi (1-20)",
"Custom WMS overlay servers" : "Serveurs de revêtement WMS",
"Layers to display" : "Layers à afficher",
"Custom WMS tile servers" : "Serveurs de tuiles WMS personnels",
"Your overlay tile servers" : "Vos serveurs de revêtements personnels",
"Your WMS overlay tile servers" : "Vos serveurs de revêtements WMS personnels",
"Transparent" : "Transparent",
"Upload new symbol image" : "Téléverser une nouvelle image de symbole"
},"pluralForm" :"nplurals=2; plural=(n > 1);"
}

View File

@ -121,10 +121,10 @@ echo '</ul>'."\n";
<hr/><br/>
<h3 class="sectiontitle"><?php p($l->t('Custom tile servers')); ?></h3>
<div id="tileserveradd">
<p><?php p($l->t('Server name (for example \'my custom server\')')); ?> :</p>
<input type="text" id="tileservername"/>
<p><?php p($l->t('Server url (\'http://tile.server.org/cycle/{z}/{x}/{y}.png\')')); ?> :</p>
<input type="text" id="tileserverurl"/>
<p><?php p($l->t('Server name')); ?> :</p>
<input type="text" id="tileservername" title="<?php p($l->t('For example : my custom server')); ?>"/>
<p><?php p($l->t('Server url')); ?> :</p>
<input type="text" id="tileserverurl" title="<?php p($l->t('For example : http://tile.server.org/cycle/{z}/{x}/{y}.png')); ?>"/>
<p><?php p($l->t('Min zoom (1-20)')); ?> :</p>
<input type="text" id="tileminzoom" value="1"/>
<p><?php p($l->t('Max zoom (1-20)')); ?> :</p>
@ -137,7 +137,7 @@ echo '</ul>'."\n";
<?php
if (count($_['usertileservers']) > 0){
foreach($_['usertileservers'] as $ts){
echo '<li';
echo '<li title="'.$ts['url'].'"';
foreach (Array('servername', 'type', 'url', 'layers', 'version', 'format', 'opacity', 'transparent', 'minzoom', 'maxzoom', 'attribution') as $field) {
if (array_key_exists($field, $ts)) {
echo ' '.$field.'="';
@ -158,18 +158,18 @@ if (count($_['usertileservers']) > 0){
<hr/><br/>
<h3 class="sectiontitle"><?php p($l->t('Custom overlay tile servers')); ?></h3>
<div id="overlayserveradd">
<p><?php p($l->t('Server name (for example \'my custom server\')')); ?> :</p>
<input type="text" id="overlayservername">
<p><?php p($l->t('Server url (\'http://overlay.server.org/cycle/{z}/{x}/{y}.png\')')); ?> :</p>
<input type="text" id="overlayserverurl">
<p><?php p($l->t('Server name')); ?> :</p>
<input type="text" id="overlayservername" title="<?php p($l->t('For example : my custom server')); ?>"/>
<p><?php p($l->t('Server url')); ?> :</p>
<input type="text" id="overlayserverurl" title="<?php p($l->t('For example : http://overlay.server.org/cycle/{z}/{x}/{y}.png')); ?>"/>
<p><?php p($l->t('Min zoom (1-20)')); ?> :</p>
<input type="text" id="overlayminzoom" value="1">
<input type="text" id="overlayminzoom" value="1"/>
<p><?php p($l->t('Max zoom (1-20)')); ?> :</p>
<input type="text" id="overlaymaxzoom" value="18">
<input type="text" id="overlaymaxzoom" value="18"/>
<label for="overlaytransparent"><?php p($l->t('Transparent')); ?> :</label>
<input type="checkbox" id="overlaytransparent" checked>
<p><?php p($l->t('Opacity (0.0-1.1)')); ?> :</p>
<input type="text" id="overlayopacity" value="0.4">
<input type="checkbox" id="overlaytransparent" checked/>
<p><?php p($l->t('Opacity (0.0-1.0)')); ?> :</p>
<input type="text" id="overlayopacity" value="0.4"/>
<button id="addoverlayserver"><i class="fa fa-plus-circle" aria-hidden="true" style="color:green;"></i> <?php p($l->t('Add')); ?></button>
</div>
<div id="overlayserverlist">
@ -178,7 +178,7 @@ if (count($_['usertileservers']) > 0){
<?php
if (count($_['useroverlayservers']) > 0){
foreach($_['useroverlayservers'] as $ts){
echo '<li';
echo '<li title="'.$ts['url'].'"';
foreach (Array('servername', 'type', 'url', 'layers', 'version', 'format', 'opacity', 'transparent', 'minzoom', 'maxzoom', 'attribution') as $field) {
if (array_key_exists($field, $ts)) {
echo ' '.$field.'="';
@ -198,30 +198,30 @@ if (count($_['useroverlayservers']) > 0){
</div>
<hr/><br/>
<h3 class="sectiontitle"><?php p($l->t('Custom WMS tile servers')); ?></h3>
<div id="tileserverwmsadd">
<p><?php p($l->t('Server name (for example \'my custom server\')')); ?> :</p>
<input type="text" id="tilewmsservername">
<p><?php p($l->t('Server url (\'http://tile.server.org/cycle/{z}/{x}/{y}.png\')')); ?> :</p>
<input type="text" id="tilewmsserverurl">
<div id="tilewmsserveradd">
<p><?php p($l->t('Server name')); ?> :</p>
<input type="text" id="tilewmsservername" title="<?php p($l->t('For example : my custom server')); ?>"/>
<p><?php p($l->t('Server url')); ?> :</p>
<input type="text" id="tilewmsserverurl" title="<?php p($l->t('For example : http://tile.server.org/cycle/{z}/{x}/{y}.png')); ?>"/>
<p><?php p($l->t('Min zoom (1-20)')); ?> :</p>
<input type="text" id="tilewmsminzoom" value="1">
<input type="text" id="tilewmsminzoom" value="1"/>
<p><?php p($l->t('Max zoom (1-20)')); ?> :</p>
<input type="text" id="tilewmsmaxzoom" value="18">
<input type="text" id="tilewmsmaxzoom" value="18"/>
<p><?php p($l->t('Format')); ?> :</p>
<input type="text" id="tilewmsformat" value="image/jpeg">
<input type="text" id="tilewmsformat" value="image/jpeg"/>
<p><?php p($l->t('WMS version')); ?> :</p>
<input type="text" id="tilewmsversion" value="1.1.1">
<input type="text" id="tilewmsversion" value="1.1.1"/>
<p><?php p($l->t('Layers to display')); ?> :</p>
<input type="text" id="tilewmslayers" value="">
<input type="text" id="tilewmslayers" value=""/>
<button id="addtileserverwms"><i class="fa fa-plus-circle" aria-hidden="true" style="color:green;"></i> <?php p($l->t('Add')); ?></button>
</div>
<div id="tileserverwmslist">
<div id="tilewmsserverlist">
<h3><?php p($l->t('Your WMS tile servers')); ?></h3>
<ul class="disclist">
<?php
if (count($_['usertileserverswms']) > 0){
foreach($_['usertileserverswms'] as $ts){
echo '<li';
echo '<li title="'.$ts['url'].'"';
foreach (Array('servername', 'type', 'url', 'layers', 'version', 'format', 'opacity', 'transparent', 'minzoom', 'maxzoom', 'attribution') as $field) {
if (array_key_exists($field, $ts)) {
echo ' '.$field.'="';
@ -241,34 +241,34 @@ if (count($_['usertileserverswms']) > 0){
</div>
<hr/><br/>
<h3 class="sectiontitle"><?php p($l->t('Custom WMS overlay servers')); ?></h3>
<div id="overlayserverwmsadd">
<p><?php p($l->t('Server name (for example \'my custom server\')')); ?> :</p>
<input type="text" id="overlaywmsservername">
<p><?php p($l->t('Server url (\'http://overlay.server.org/cycle/{z}/{x}/{y}.png\')')); ?> :</p>
<input type="text" id="overlaywmsserverurl">
<div id="overlaywmsserveradd">
<p><?php p($l->t('Server name')); ?> :</p>
<input type="text" id="overlaywmsservername" title="<?php p($l->t('For example : my custom server')); ?>"/>
<p><?php p($l->t('Server url')); ?> :</p>
<input type="text" id="overlaywmsserverurl" title="<?php p($l->t('For example : http://overlay.server.org/cycle/{z}/{x}/{y}.png')); ?>"/>
<p><?php p($l->t('Min zoom (1-20)')); ?> :</p>
<input type="text" id="overlaywmsminzoom" value="1">
<input type="text" id="overlaywmsminzoom" value="1"/>
<p><?php p($l->t('Max zoom (1-20)')); ?> :</p>
<input type="text" id="overlaywmsmaxzoom" value="18">
<input type="text" id="overlaywmsmaxzoom" value="18"/>
<label for="overlaywmstransparent"><?php p($l->t('Transparent')); ?> :</label>
<input type="checkbox" id="overlaywmstransparent" checked>
<p><?php p($l->t('Opacity (0.0-1.1)')); ?> :</p>
<input type="text" id="overlaywmsopacity" value="0.4">
<input type="checkbox" id="overlaywmstransparent" checked/>
<p><?php p($l->t('Opacity (0.0-1.0)')); ?> :</p>
<input type="text" id="overlaywmsopacity" value="0.4"/>
<p><?php p($l->t('Format')); ?> :</p>
<input type="text" id="overlaywmsformat" value="image/jpeg">
<input type="text" id="overlaywmsformat" value="image/jpeg"/>
<p><?php p($l->t('WMS version')); ?> :</p>
<input type="text" id="overlaywmsversion" value="1.1.1">
<input type="text" id="overlaywmsversion" value="1.1.1"/>
<p><?php p($l->t('Layers to display')); ?> :</p>
<input type="text" id="overlaywmslayers" value="">
<input type="text" id="overlaywmslayers" value=""/>
<button id="addoverlayserverwms"><i class="fa fa-plus-circle" aria-hidden="true" style="color:green;"></i> <?php p($l->t('Add')); ?></button>
</div>
<div id="overlayserverwmslist">
<div id="overlaywmsserverlist">
<h3><?php p($l->t('Your WMS overlay tile servers')); ?></h3>
<ul class="disclist">
<?php
if (count($_['useroverlayserverswms']) > 0){
foreach($_['useroverlayserverswms'] as $ts){
echo '<li';
echo '<li title="'.$ts['url'].'"';
foreach (Array('servername', 'type', 'url', 'layers', 'version', 'format', 'opacity', 'transparent', 'minzoom', 'maxzoom', 'attribution') as $field) {
if (array_key_exists($field, $ts)) {
echo ' '.$field.'="';