adding leaflet-hugo maps
This will hopefully allow me to create shortcode maps with osm and leaflet rather than google.
This commit is contained in:
		
							parent
							
								
									31bab3cf3b
								
							
						
					
					
						commit
						16bcf8b091
					
				
					 18 changed files with 2074 additions and 112 deletions
				
			
		
							
								
								
									
										8
									
								
								static/css/leaflet.extra-markers.min.css
									
										
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										8
									
								
								static/css/leaflet.extra-markers.min.css
									
										
									
									
										vendored
									
									
										Executable file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								static/img/markers_default.png
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								static/img/markers_default.png
									
										
									
									
									
										Executable file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 117 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								static/img/markers_default@2x.png
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								static/img/markers_default@2x.png
									
										
									
									
									
										Executable file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 248 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								static/img/markers_shadow.png
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								static/img/markers_shadow.png
									
										
									
									
									
										Executable file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 535 B  | 
							
								
								
									
										
											BIN
										
									
								
								static/img/markers_shadow@2x.png
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								static/img/markers_shadow@2x.png
									
										
									
									
									
										Executable file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 1.4 KiB  | 
							
								
								
									
										1660
									
								
								static/js/leaflet.elevation.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										1660
									
								
								static/js/leaflet.elevation.js
									
										
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							
							
								
								
									
										1
									
								
								static/js/leaflet.extra-markers.js.map
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										1
									
								
								static/js/leaflet.extra-markers.js.map
									
										
									
									
									
										Executable file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										10
									
								
								static/js/leaflet.extra-markers.min.js
									
										
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										10
									
								
								static/js/leaflet.extra-markers.min.js
									
										
									
									
										vendored
									
									
										Executable file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										108
									
								
								static/js/leaflet.hugo.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										108
									
								
								static/js/leaflet.hugo.js
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,108 @@
 | 
			
		|||
let leafletMapsObj = {};
 | 
			
		||||
let leafletMarkersObj = {};
 | 
			
		||||
 | 
			
		||||
function drawTrack(trackOpts, elevationOpts, markerOpts) {
 | 
			
		||||
    var opts = {
 | 
			
		||||
        elevationControl: {
 | 
			
		||||
            options: {
 | 
			
		||||
                position: elevationOpts.graphPosition,
 | 
			
		||||
                theme: elevationOpts.graphTheme,
 | 
			
		||||
                width: elevationOpts.graphWidth,
 | 
			
		||||
                height: elevationOpts.graphHeight,
 | 
			
		||||
                margins: {
 | 
			
		||||
                    top: 20,
 | 
			
		||||
                    right: 20,
 | 
			
		||||
                    bottom: 35,
 | 
			
		||||
                    left: 50
 | 
			
		||||
                },
 | 
			
		||||
                followMarker: elevationOpts.graphFollowMarker,
 | 
			
		||||
                collapsed: elevationOpts.graphCollapsed,
 | 
			
		||||
                detached: elevationOpts.graphDetached,
 | 
			
		||||
                legend: false,
 | 
			
		||||
                summary: false,
 | 
			
		||||
                downloadLink: '',
 | 
			
		||||
                gpxOptions: {
 | 
			
		||||
                    polyline_options: {
 | 
			
		||||
                        className: 'track-' + trackOpts.trackId + '-',
 | 
			
		||||
                        color: trackOpts.lineColor,
 | 
			
		||||
                        opacity: trackOpts.lineOpacity,
 | 
			
		||||
                        weight: trackOpts.lineWeight,
 | 
			
		||||
                    },
 | 
			
		||||
                    marker_options: {
 | 
			
		||||
                        startIcon: new L.ExtraMarkers.icon({
 | 
			
		||||
                            icon: markerOpts.iconStart,
 | 
			
		||||
                            markerColor: markerOpts.iconStartColor,
 | 
			
		||||
                            shape: markerOpts.iconStartShape,
 | 
			
		||||
                            prefix: 'fa',
 | 
			
		||||
                            extraClasses: markerOpts.iconStartClasses
 | 
			
		||||
                        }),
 | 
			
		||||
                        endIcon: new L.ExtraMarkers.icon({
 | 
			
		||||
                            icon: markerOpts.iconEnd,
 | 
			
		||||
                            markerColor: markerOpts.iconEndColor,
 | 
			
		||||
                            shape: markerOpts.iconEndShape,
 | 
			
		||||
                            prefix: 'fa',
 | 
			
		||||
                            extraClasses: markerOpts.iconEndClasses
 | 
			
		||||
                        }),
 | 
			
		||||
                        wptIcons: {
 | 
			
		||||
                            '': new L.ExtraMarkers.icon({
 | 
			
		||||
                                icon: markerOpts.icon,
 | 
			
		||||
                                markerColor: markerOpts.iconColor,
 | 
			
		||||
                                shape: markerOpts.iconShape,
 | 
			
		||||
                                prefix: 'fa',
 | 
			
		||||
                                extraClasses:  markerOpts.iconClasses,
 | 
			
		||||
                            })
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                },
 | 
			
		||||
 | 
			
		||||
            },
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    L.control.elevation(opts.elevationControl.options).addTo(leafletMapsObj[trackOpts.mapId]).load(trackOpts.trackPath);
 | 
			
		||||
 | 
			
		||||
    /*map.on('eledata_loaded', function(e) {
 | 
			
		||||
        track = e.track_info;
 | 
			
		||||
    });*/
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
window.downloadFile = function (sUrl) {
 | 
			
		||||
 | 
			
		||||
    //iOS devices do not support downloading. We have to inform user about this.
 | 
			
		||||
    if (/(iP)/g.test(navigator.userAgent)) {
 | 
			
		||||
        alert('Your device does not support files downloading. Please try again in desktop browser.');
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    //If in Chrome or Safari - download via virtual link click
 | 
			
		||||
    if (window.downloadFile.isChrome || window.downloadFile.isSafari) {
 | 
			
		||||
        //Creating new link node.
 | 
			
		||||
        var link = document.createElement('a');
 | 
			
		||||
        link.href = sUrl;
 | 
			
		||||
 | 
			
		||||
        if (link.download !== undefined) {
 | 
			
		||||
            //Set HTML5 download attribute. This will prevent file from opening if supported.
 | 
			
		||||
            var fileName = sUrl.substring(sUrl.lastIndexOf('/') + 1, sUrl.length);
 | 
			
		||||
            link.download = fileName;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //Dispatching click event.
 | 
			
		||||
        if (document.createEvent) {
 | 
			
		||||
            var e = document.createEvent('MouseEvents');
 | 
			
		||||
            e.initEvent('click', true, true);
 | 
			
		||||
            link.dispatchEvent(e);
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Force file download (whether supported by server).
 | 
			
		||||
    if (sUrl.indexOf('?') === -1) {
 | 
			
		||||
        sUrl += '?download';
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    window.open(sUrl, '_self');
 | 
			
		||||
    return true;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
window.downloadFile.isChrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
 | 
			
		||||
window.downloadFile.isSafari = navigator.userAgent.toLowerCase().indexOf('safari') > -1;
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue