diff --git a/js/gpxedit.js b/js/gpxedit.js index 773cc1a..954664a 100644 --- a/js/gpxedit.js +++ b/js/gpxedit.js @@ -325,10 +325,7 @@ function load_map() { circle: false, rectangle:false, marker: { - icon: L.divIcon({ - className: 'leaflet-div-icon2', - iconAnchor: [5, 30] - }) + icon: symbolIcons['marker'] } }, edit: { @@ -381,36 +378,46 @@ function load_map() { // it generates the popup content and initializes the layer's data // it returns the layer in case we want to set the layer's data manually (when loading a gpx) function onCreated(type, layer){ - var popupTitle = 'Track'; - if (type === 'marker') { - popupTitle = 'Waypoint'; - } + var popupTitle; + var layerType; + if (type === 'polyline' || type === 'track'){ + popupTitle = 'Track'; + layerType = 'track'; + } + else if (type === 'route') { + popupTitle = 'Route'; + layerType = 'route'; + } + else if (type === 'marker') { + popupTitle = 'Waypoint'; + layerType = 'marker'; + } - var popupTxt = '

'+popupTitle+'

'+ - ''+ - ''+ - ''; - if (type === 'marker') { - popupTxt = popupTxt + ''; - } - popupTxt = popupTxt + '
Name
Description
Comment
Symbol
'; - popupTxt = popupTxt + ''; + var popupTxt = '

'+popupTitle+'

'+ + ''+ + ''+ + ''; + if (type === 'marker') { + popupTxt = popupTxt + ''; + } + popupTxt = popupTxt + '
Name
Description
Comment
Symbol
'; + popupTxt = popupTxt + ''; - layer.bindPopup(popupTxt); + layer.bindPopup(popupTxt); - layer.gpxedit_id = gpxedit.id; - layer.type = type; - gpxedit.layersData[gpxedit.id] = {name:'', description:'', comment:'', symbol:'', layer: layer}; - gpxedit.editableLayers.addLayer(layer); - gpxedit.id++; - return layer; + layer.gpxedit_id = gpxedit.id; + layer.type = layerType; + gpxedit.layersData[gpxedit.id] = {name:'', description:'', comment:'', symbol:'', layer: layer}; + gpxedit.editableLayers.addLayer(layer); + gpxedit.id++; + return layer; } function getUrlParameter(sParam) @@ -485,7 +492,7 @@ function generateGpx(){ } gpxText = gpxText + ' \n'; } - else{ + else if(layer.type === 'track'){ gpxText = gpxText + ' \n'; if (name){ gpxText = gpxText + ' '+name+'\n'; @@ -512,6 +519,32 @@ function generateGpx(){ } gpxText = gpxText + ' \n \n'; } + else if(layer.type === 'route'){ + gpxText = gpxText + ' \n'; + if (name){ + gpxText = gpxText + ' '+name+'\n'; + } + else{ + gpxText = gpxText + ' unnamed\n'; + } + if (comment){ + gpxText = gpxText + ' '+comment+'\n'; + } + if (description){ + gpxText = gpxText + ' '+description+'\n'; + } + for (var i=0; i\n'; + if (alt !== undefined){ + gpxText = gpxText + ' '+alt+'\n'; + } + gpxText = gpxText + ' \n'; + } + gpxText = gpxText + ' \n'; + } }); gpxText = gpxText + ' \n'; return gpxText; @@ -545,14 +578,14 @@ function drawMarker(latlng, name, desc, cmt, sym){ } // adds a polyline and initialize its data -function drawLine(latlngs, name, desc, cmt){ +function drawLine(latlngs, name, desc, cmt, gpxtype){ var wst = $('#markerstyleselect').val(); var tst = $('#tooltipstyleselect').val(); var p = L.polyline(latlngs, { color: '#f357a1', weight: 7 }); - var layer = onCreated('polyline', p); + var layer = onCreated(gpxtype, p); if (name !== ''){ if (tst === 'p'){ p.bindTooltip(name, {permanent:true}); @@ -603,7 +636,7 @@ function parseGpx(xml){ } }); }); - drawLine(latlngs, name, desc, cmt); + drawLine(latlngs, name, desc, cmt, 'track'); }); dom.find('rte').each(function(){ var latlngs = []; @@ -621,7 +654,7 @@ function parseGpx(xml){ latlngs.push([lat,lon]); } }); - drawLine(latlngs, name, desc, cmt); + drawLine(latlngs, name, desc, cmt, 'route'); }); }