refs #6 symbol choice in popup only for markers

merge-requests/1/head
Julien Veyssier 2016-12-08 11:01:45 +01:00
parent b051fe1e40
commit a7f8d16242
1 changed files with 17 additions and 10 deletions

View File

@ -363,13 +363,16 @@ function load_map() {
// this is needed because popup content is created each time we open one // this is needed because popup content is created each time we open one
// so, the content is lost when it's closed // so, the content is lost when it's closed
gpxedit.map.on('popupopen', function(e){ gpxedit.map.on('popupopen', function(e){
var id = parseInt(e.popup.getContent().match(/layerid="(\d+)"/)[1]); var id = e.popup._source.gpxedit_id;
//var id = parseInt(e.popup.getContent().match(/layerid="(\d+)"/)[1]);
var buttonParent = $('button.popupOkButton[layerid='+id+']').parent(); var buttonParent = $('button.popupOkButton[layerid='+id+']').parent();
buttonParent.find('input.layerName').val(gpxedit.layersData[id].name); buttonParent.find('input.layerName').val(gpxedit.layersData[id].name);
buttonParent.find('textarea.layerDesc').val(gpxedit.layersData[id].description); buttonParent.find('textarea.layerDesc').val(gpxedit.layersData[id].description);
buttonParent.find('textarea.layerCmt').val(gpxedit.layersData[id].comment); buttonParent.find('textarea.layerCmt').val(gpxedit.layersData[id].comment);
if (gpxedit.layersData[id].layer.type === 'marker'){
buttonParent.find('select[role=symbol]').val(gpxedit.layersData[id].symbol); buttonParent.find('select[role=symbol]').val(gpxedit.layersData[id].symbol);
buttonParent.find('select[role=symbol]').change(); buttonParent.find('select[role=symbol]').change();
}
}); });
} }
@ -387,6 +390,7 @@ function onCreated(type, layer){
'<tr><td>Name</td><td><input class="layerName"></input></td></tr>'+ '<tr><td>Name</td><td><input class="layerName"></input></td></tr>'+
'<tr><td>Description</td><td><textarea class="layerDesc"></textarea></td></tr>'+ '<tr><td>Description</td><td><textarea class="layerDesc"></textarea></td></tr>'+
'<tr><td>Comment</td><td><textarea class="layerCmt"></textarea></td></tr>'; '<tr><td>Comment</td><td><textarea class="layerCmt"></textarea></td></tr>';
if (type === 'marker') {
popupTxt = popupTxt + '<tr><td>Symbol</td><td><select role="symbol">'; popupTxt = popupTxt + '<tr><td>Symbol</td><td><select role="symbol">';
popupTxt = popupTxt + '<option value="">No symbol</option>'; popupTxt = popupTxt + '<option value="">No symbol</option>';
for (var cl in symbolIcons){ for (var cl in symbolIcons){
@ -394,7 +398,9 @@ function onCreated(type, layer){
popupTxt = popupTxt + '<option value="'+cl+'">'+cl+'</option>'; popupTxt = popupTxt + '<option value="'+cl+'">'+cl+'</option>';
} }
} }
popupTxt = popupTxt + '</select></td></tr></table>'; popupTxt = popupTxt + '</select></td></tr>';
}
popupTxt = popupTxt + '</table>';
popupTxt = popupTxt + '<button class="popupOkButton" layerid="'+gpxedit.id+'">OK</button>'; popupTxt = popupTxt + '<button class="popupOkButton" layerid="'+gpxedit.id+'">OK</button>';
layer.bindPopup(popupTxt); layer.bindPopup(popupTxt);
@ -898,13 +904,14 @@ $(document).ready(function(){
var wst = $('#markerstyleselect').val(); var wst = $('#markerstyleselect').val();
var tst = $('#tooltipstyleselect').val(); var tst = $('#tooltipstyleselect').val();
var symboo = $('#symboloverwrite').is(':checked'); var symboo = $('#symboloverwrite').is(':checked');
var type = gpxedit.layersData[id].layer.type;
gpxedit.layersData[id].name = name; gpxedit.layersData[id].name = name;
gpxedit.layersData[id].description = description; gpxedit.layersData[id].description = description;
gpxedit.layersData[id].comment = comment; gpxedit.layersData[id].comment = comment;
gpxedit.layersData[id].symbol = symbol; gpxedit.layersData[id].symbol = symbol;
gpxedit.layersData[id].layer.unbindTooltip(); gpxedit.layersData[id].layer.unbindTooltip();
if (gpxedit.layersData[id].layer.type === 'marker'){ if (type === 'marker'){
if (symboo && symbol !== '' && symbolIcons.hasOwnProperty(symbol)){ if (symboo && symbol !== '' && symbolIcons.hasOwnProperty(symbol)){
gpxedit.layersData[id].layer.setIcon(symbolIcons[symbol]) gpxedit.layersData[id].layer.setIcon(symbolIcons[symbol])
} }