refs #6 possible to choose any symbol as waypoint default style

merge-requests/1/head
Julien Veyssier 2016-12-07 15:12:29 +01:00
parent a768cac73a
commit 6bc8905482
2 changed files with 19 additions and 55 deletions

View File

@ -11,6 +11,10 @@ var gpxedit = {
}; };
var symbolIcons = { var symbolIcons = {
'marker': L.divIcon({
className: 'leaflet-marker-blue',
iconAnchor: [12, 41]
}),
'Dot, White': L.divIcon({ 'Dot, White': L.divIcon({
iconSize:L.point(7,7), iconSize:L.point(7,7),
}), }),
@ -330,8 +334,10 @@ function onCreated(type, layer){
popupTxt = popupTxt + '<tr><td>Symbol</td><td><select class="symbol">'; popupTxt = popupTxt + '<tr><td>Symbol</td><td><select class="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){
if (cl !== 'marker'){
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></table>';
popupTxt = popupTxt + '<button class="popupOkButton" layerid="'+gpxedit.id+'">OK</button>'; popupTxt = popupTxt + '<button class="popupOkButton" layerid="'+gpxedit.id+'">OK</button>';
@ -458,19 +464,8 @@ function drawMarker(latlng, name, desc, cmt, sym){
if (symboo && sym !== '' && symbolIcons.hasOwnProperty(sym)){ if (symboo && sym !== '' && symbolIcons.hasOwnProperty(sym)){
m.setIcon(symbolIcons[sym]); m.setIcon(symbolIcons[sym]);
} }
else if (wst === 'p'){ else{
m.setIcon(L.divIcon({ m.setIcon(symbolIcons[wst]);
className: 'leaflet-div-icon2',
iconAnchor: [5, 30]
}));
}
else if (wst === 's'){
m.setIcon(L.divIcon({
iconSize:L.point(6,6),
html:'<div></div>'
}));
}
else if (wst === 'm'){
} }
var layer = onCreated('marker', m); var layer = onCreated('marker', m);
if (name !== ''){ if (name !== ''){
@ -698,25 +693,7 @@ function addTileServer(){
function updateLeafletDrawMarkerStyle(){ function updateLeafletDrawMarkerStyle(){
var wst = $('#markerstyleselect').val(); var wst = $('#markerstyleselect').val();
var tst = $('#tooltipstyleselect').val(); var tst = $('#tooltipstyleselect').val();
var theicon; var theicon = symbolIcons[wst];
if (wst === 'p'){
theicon = L.divIcon({
className: 'leaflet-div-icon2',
iconAnchor: [5, 30]
});
}
else if (wst === 's'){
theicon = L.divIcon({
iconSize:L.point(6,6),
html:'<div></div>'
});
}
else if (wst === 'm'){
theicon = L.divIcon({
className: 'leaflet-marker-blue',
iconAnchor: [12, 41]
});
}
gpxedit.drawControl.setDrawingOptions({ gpxedit.drawControl.setDrawingOptions({
marker: { marker: {
@ -804,10 +781,18 @@ function saveOptions(){
}); });
} }
function fillWaypointStyles(){
for (var st in symbolIcons){
$('select#markerstyleselect').append('<option value="'+st+'">'+st+'</option>');
}
$('select#markerstyleselect').val('marker');
}
$(document).ready(function(){ $(document).ready(function(){
gpxedit.username = $('p#username').html(); gpxedit.username = $('p#username').html();
load_map(); load_map();
document.onkeydown = checkKey; document.onkeydown = checkKey;
fillWaypointStyles();
restoreOptions(); restoreOptions();
$('select#markerstyleselect').change(function(e){ $('select#markerstyleselect').change(function(e){
@ -847,25 +832,7 @@ $(document).ready(function(){
gpxedit.layersData[id].layer.setIcon(symbolIcons[symbol]) gpxedit.layersData[id].layer.setIcon(symbolIcons[symbol])
} }
else{ else{
var theicon; var theicon = symbolIcons[wst];
if (wst === 'p'){
theicon = L.divIcon({
className: 'leaflet-div-icon2',
iconAnchor: [5, 30]
});
}
else if (wst === 's'){
theicon = L.divIcon({
iconSize:L.point(6,6),
html:'<div></div>'
});
}
else if (wst === 'm'){
theicon = L.divIcon({
className: 'leaflet-marker-blue',
iconAnchor: [12, 41]
});
}
gpxedit.layersData[id].layer.setIcon(theicon); gpxedit.layersData[id].layer.setIcon(theicon);
} }
} }

View File

@ -67,9 +67,6 @@ echo '</p>'."\n";
<br/> <br/>
<label>Waypoint style:</label> <label>Waypoint style:</label>
<select id="markerstyleselect"> <select id="markerstyleselect">
<option value="p"><?php p($l->t('pin')); ?></option>
<option value="s"><?php p($l->t('point')); ?></option>
<option value="m"><?php p($l->t('marker')); ?></option>
</select> </select>
<br/> <br/>
<label>Tooltip style:</label> <label>Tooltip style:</label>