Changeset c6219ed in OpenWorkouts-current for ow/static/js/ow.js


Ignore:
Timestamp:
Jan 22, 2019, 12:21:51 AM (5 years ago)
Author:
Borja Lopez <borja@…>
Branches:
current, feature/docs, master
Children:
26220ba, 2d2eb0d
Parents:
02048a6 (diff), be40b02 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merged patches from darcs

File:
1 edited

Legend:

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

    r02048a6 rc6219ed  
    1616
    1717    // parameters provided when creating an "instance" of a map
     18    var map_id = spec.map_id;
    1819    var latitude = spec.latitude;
    1920    var longitude = spec.longitude;
     
    2324    var end_icon = spec.end_icon;
    2425    var shadow = spec.shadow;
     26    var elevation = spec.elevation;
     27    var zoom_control = spec.zoom_control;
    2528
    2629    // OpenStreetMap urls and references
    27     var openstreetmap_url = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'
    28     var openstreetmap_attr = 'Map data &copy; <a href="http://www.osm.org">OpenStreetMap</a>'
     30    var openstreetmap_url = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
     31    var openstreetmap_attr = 'Map data &copy; <a href="http://www.osm.org">OpenStreetMap</a>';
    2932
    3033    // Some constants reused through the code
     
    3639    var create_map = function create_map(latitude, longitude, zoom) {
    3740        /* Create a Leaflet map, set center point and add tiles */
    38         map = L.map('map');
     41        map = L.map(map_id, {zoomControl: zoom_control});
    3942        map.setView([latitude, longitude], zoom);
    4043        var tile_layer = L.tileLayer(openstreetmap_url, {
     
    9093            },
    9194        });
    92         gpx.on("addline",function(e){
    93             elevation.addData(e.line);
    94             // ow_charts.addData(e.line);
    95         });
     95
     96        gpx.on('loaded', function(e) {
     97            map.fitBounds(e.target.getBounds());
     98        });
     99
     100        if (elevation) {
     101            gpx.on("addline",function(e){
     102                elevation.addData(e.line);
     103                // ow_charts.addData(e.line);
     104            });
     105        };
     106
    96107        gpx.addTo(map);
    97108    };
     
    100111        // create the map, add elevation, load gpx
    101112        create_map(latitude, longitude, zoom);
    102         add_elevation_chart();
     113        if (elevation) {
     114            add_elevation_chart();
     115        }
    103116        // add_ow_charts();
    104117        load_gpx(gpx_url);
Note: See TracChangeset for help on using the changeset viewer.