Changeset 5f05e83 in OpenWorkouts-current for ow/static/js/ow.js


Ignore:
Timestamp:
Feb 5, 2019, 5:15:13 PM (5 years ago)
Author:
Borja Lopez <borja@…>
Branches:
current, feature/docs, master
Children:
3169fe4
Parents:
d52ba50
git-author:
Borja Lopez <borja@…> (02/05/19 16:50:41)
git-committer:
Borja Lopez <borja@…> (02/05/19 17:15:13)
Message:

Replaced Leaflet.Elevation with a newer, improved version (fork of the original)

Done some clean-up of the map javascript code, removed old tests and WIP code
that is not needed anymore.

IMPORTANT: After pulling this patch, run js_deps to install the new version of
leaflet elevation:

./bin/js_deps

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ow/static/js/ow.js

    rd52ba50 r5f05e83  
    3535    var gpx;
    3636    var elevation;
    37     var ow_charts;
    3837
    3938    var create_map = function create_map(latitude, longitude, zoom) {
     
    5251           This has to be called *after* create_map and *before* load_gpx.
    5352        */
     53
    5454        elevation = L.control.elevation({
    5555            position: "bottomright",
    56             theme: "steelblue-theme", //default: lime-theme
    57             width: 600,
    58             height: 125,
    59             margins: {
    60                 top: 10,
    61                 right: 20,
    62                 bottom: 30,
    63                 left: 50
    64             },
     56            theme: "openworkouts-theme",
    6557            useHeightIndicator: true, //if false a marker is drawn at map position
    66             interpolation: "linear", //see https://github.com/mbostock/d3/wiki/SVG-Shapes#wiki-area_interpolate
    67             hoverNumber: {
    68                 decimalsX: 3, //decimals on distance (always in km)
    69                 decimalsY: 0, //deciamls on height (always in m)
    70                 formatter: undefined //custom formatter function may be injected
    71             },
    72             xTicks: undefined, //number of ticks in x axis, calculated by default according to width
    73             yTicks: undefined, //number of ticks on y axis, calculated by default according to height
    74             collapsed: false    //collapsed mode, show chart on click or mouseover
    75         });
    76 
    77         var ele_container = elevation.addTo(map);
    78         /* document.getElementById('ow-analysis').appendChild(
    79             ele_container._container); */
     58            interpolation: d3.curveLinear,
     59            elevationDiv: "#elevation",
     60            detachedView: true,
     61            responsiveView: true,
     62            gpxOptions: {
     63                async: true,
     64                marker_options: {
     65                    startIconUrl: null,
     66                    endIconUrl: null,
     67                    shadowUrl: null,
     68                },
     69                polyline_options: {
     70                    color: '#EE4056',
     71                    opacity: 0.75,
     72                    weight: 5,
     73                    lineCap: 'round'
     74                },
     75            },
     76        });
     77        elevation.loadGPX(map, gpx_url);
     78        // var ele_container = elevation.addTo(map);
    8079    };
    8180
     
    101100            gpx.on("addline",function(e){
    102101                elevation.addData(e.line);
    103                 // ow_charts.addData(e.line);
    104102            });
    105103        };
     
    114112            add_elevation_chart();
    115113        }
    116         // add_ow_charts();
    117         load_gpx(gpx_url);
     114        // load_gpx(gpx_url);
    118115    };
    119116
Note: See TracChangeset for help on using the changeset viewer.