@raruto/leaflet-elevation 1.9.0 → 1.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -17,38 +17,29 @@ _For a working example see one of the following demos:_
17
17
  - [loading .geojson file](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_geojson-data.html)
18
18
  - [loading .kml file](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_kml-data.html)
19
19
  - [loading .tcx file](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_tcx-data.html)
20
- - [loading strings](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_string-data.html)
21
- - [loading geojson group](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_geojson-group.html)
22
- - [loading local .gpx file](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_upload-gpx.html)
20
+ - [loading a local .gpx file](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_upload-gpx.html)
21
+ - [loading data from a textarea](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_string-data.html)
22
+ - [loading individual .geojson tracks](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_geojson-group.html)
23
+ - [loading individual .gpx tracks](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_toggable-tracks.html)
24
+ - [loading multiple .gpx tracks (hover to toggle)](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_hoverable-tracks.html)
25
+ - [loading multiple .gpx tracks (click to toggle)](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_toggable-charts.html)
26
+ - [loading heart rate data (coding a custom plugin)](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_extended-ui.html)
27
+ - [loading a dynamic runner (coding a custom plugin)](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_dynamic-runner.html)
28
+ - [snapping mouse over layer buffer (leaflet-almostover)](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_almost-over.html)
29
+ - [translating plugin labels (leaflet-i18n)](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_i18n-strings.html)
30
+ - [using .gpx waypoint icons](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_gpx-waypoints.html)
31
+ - [using .geojson waypoint icons](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_geojson-waypoints.html)
23
32
 
24
33
  <br/>
25
34
 
26
- - [custom chart](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_extended-ui.html)
35
+ - [autohide map](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_hidden-map.html)
36
+ - [autohide chart](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_hidden-chart.html)
37
+ - [collapsible button](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_close-button.html)
27
38
  - [custom colors](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_custom-theme.html)
28
39
  - [custom summary](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_custom-summary.html)
29
- - [close button](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_close-button.html)
40
+ - [follow marker](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_follow-marker.html)
30
41
  - [slope chart](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_slope-chart.html)
31
42
  - [speed chart](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_speed-chart.html)
32
- - [i18n strings](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_i18n-strings.html)
33
-
34
- <br/>
35
-
36
- - [hoverable chart / hidden map](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_hidden-map.html)
37
- - [hoverable chart / hidden chart](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_hidden-chart.html)
38
- - [hoverable tracks](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_hoverable-tracks.html)
39
- - [toggable tracks](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_toggable-tracks.html)
40
- - [toggable charts](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_toggable-charts.html)
41
-
42
- <br/>
43
-
44
- - [waypoint icons / gpx](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_gpx-waypoints.html)
45
- - [waypoint icons / geojson](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_geojson-waypoints.html)
46
-
47
- <br/>
48
-
49
- - [almost over](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_almost-over.html)
50
- - [follow marker](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_follow-marker.html)
51
- - [dynamic runner](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_dynamic-runner.html)
52
43
 
53
44
  ---
54
45
 
@@ -69,8 +60,8 @@ _For a working example see one of the following demos:_
69
60
  <style> html, body, #map, #elevation-div { height: 100%; width: 100%; padding: 0; margin: 0; } #map { height: 75%; } #elevation-div { height: 25%; font: 12px/1.5 "Helvetica Neue", Arial, Helvetica, sans-serif; } </style>
70
61
 
71
62
  <!-- leaflet-ui -->
72
- <script src="https://unpkg.com/leaflet@1.3.2/dist/leaflet.js"></script>
73
- <script src="https://unpkg.com/leaflet-ui@0.2.0/dist/leaflet-ui.js"></script>
63
+ <script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"></script>
64
+ <script src="https://unpkg.com/leaflet-ui@0.5.1/dist/leaflet-ui.js"></script>
74
65
 
75
66
  <!-- leaflet-elevation -->
76
67
  <link rel="stylesheet" href="https://unpkg.com/@raruto/leaflet-elevation/dist/leaflet-elevation.css" />
@@ -256,7 +247,7 @@ _Related: [Leaflet-UI presets](https://github.com/raruto/leaflet-ui), [QGIS Inte
256
247
  ---
257
248
 
258
249
  **Compatibile with:**
259
- [![Leaflet 1.x compatible!](https://img.shields.io/badge/Leaflet-1.6.0-1EB300.svg?style=flat)](http://leafletjs.com/reference.html)
250
+ [![Leaflet 1.x compatible!](https://img.shields.io/badge/Leaflet-1.7.0-1EB300.svg?style=flat)](http://leafletjs.com/reference.html)
260
251
  [![d3.js v6 compatibile!](https://img.shields.io/badge/d3.js-6.5-1EB300.svg?style=flat)](https://www.npmjs.com/package/d3)
261
252
  [![@tmcw/togeojson v4.5.0 compatibile!](https://img.shields.io/badge/@tmcw/togeojson-4.5-1EB300.svg?style=flat)](https://www.npmjs.com/package/@tmcw/togeojson)
262
253
 
@@ -394,6 +394,7 @@
394
394
  _ref4$length = _ref4.length,
395
395
  length = _ref4$length === void 0 ? 0 : _ref4$length;
396
396
  return function (g) {
397
+ g.attr("class", "height-focus-group");
397
398
  var line = g.select('.height-focus.line');
398
399
  var circle = g.select('.height-focus.circle-lower');
399
400
  var text = g.select('.height-focus-label');
@@ -1557,7 +1558,6 @@
1557
1558
  switch (this.options.marker) {
1558
1559
  case 'elevation-line':
1559
1560
  // this._container = d3.create("g").attr("class", "height-focus-group");
1560
- this._container = d3.select(map.getPane('elevationPane')).select("svg > g").attr("class", "height-focus-group");
1561
1561
  break;
1562
1562
 
1563
1563
  case 'position-marker':
@@ -1578,8 +1578,7 @@
1578
1578
 
1579
1579
  switch (this.options.marker) {
1580
1580
  case 'elevation-line':
1581
- this._container.call(PositionMarker({}));
1582
-
1581
+ this._container = d3.select(map.getPane('elevationPane')).select("svg > g").call(PositionMarker({}));
1583
1582
  break;
1584
1583
 
1585
1584
  case 'position-marker':
@@ -1605,21 +1604,23 @@
1605
1604
 
1606
1605
  switch (this.options.marker) {
1607
1606
  case 'elevation-line':
1608
- var point = this._map.latLngToLayerPoint(this._latlng);
1607
+ if (this._container) {
1608
+ var point = this._map.latLngToLayerPoint(this._latlng);
1609
1609
 
1610
- point = L.extend({}, props.item, this._map._rotate ? this._map.rotatedPointToMapPanePoint(point) : point);
1610
+ point = L.extend({}, props.item, this._map._rotate ? this._map.rotatedPointToMapPanePoint(point) : point);
1611
1611
 
1612
- this._container.classed("leaflet-hidden", false);
1612
+ this._container.classed("leaflet-hidden", false);
1613
1613
 
1614
- this._container.call(PositionMarker({
1615
- theme: this.options.theme,
1616
- xCoord: point.x,
1617
- yCoord: point.y,
1618
- length: point.y - this._height() / props.maxElevation * point.z,
1619
- // normalized Y
1620
- labels: this._labels,
1621
- item: point
1622
- }));
1614
+ this._container.call(PositionMarker({
1615
+ theme: this.options.theme,
1616
+ xCoord: point.x,
1617
+ yCoord: point.y,
1618
+ length: point.y - this._height() / props.maxElevation * point.z,
1619
+ // normalized Y
1620
+ labels: this._labels,
1621
+ item: point
1622
+ }));
1623
+ }
1623
1624
 
1624
1625
  break;
1625
1626
 
@@ -1766,7 +1767,7 @@
1766
1767
  wptIcons: {
1767
1768
  '': L.divIcon({
1768
1769
  className: 'elevation-waypoint-marker',
1769
- html: '<i class="elevation-waypoint-icon"></i>',
1770
+ html: '<i class="elevation-waypoint-icon default"></i>',
1770
1771
  iconSize: [30, 30],
1771
1772
  iconAnchor: [8, 30]
1772
1773
  })
@@ -1793,7 +1794,7 @@
1793
1794
  __TOGEOJSON: 'https://unpkg.com/@tmcw/togeojson@4.5.0/dist/togeojson.umd.js',
1794
1795
  __LGEOMUTIL: 'https://unpkg.com/leaflet-geometryutil@0.9.3/src/leaflet.geometryutil.js',
1795
1796
  __LALMOSTOVER: 'https://unpkg.com/leaflet-almostover@1.0.1/src/leaflet.almostover.js',
1796
- __LDISTANCEM: 'https://unpkg.com/@raruto/leaflet-elevation@1.9.0/libs/leaflet-distance-marker.min.js',
1797
+ __LDISTANCEM: 'https://unpkg.com/@raruto/leaflet-elevation@1.9.3/libs/leaflet-distance-marker.min.js',
1797
1798
 
1798
1799
  /*
1799
1800
  * Add data to the diagram either from GPX or GeoJSON and update the axis domain and data
@@ -2225,23 +2226,6 @@
2225
2226
  _addMarker: function _addMarker(marker) {
2226
2227
  if (marker) this._markers.addLayer(marker);
2227
2228
  },
2228
- _bindPopup: function _bindPopup(marker) {
2229
- var popup = marker._popup;
2230
-
2231
- if (popup) {
2232
- popup.options.className = 'elevation-popup';
2233
-
2234
- if (popup._content) {
2235
- popup._content = decodeURI(popup._content);
2236
- popup.bindTooltip(popup._content, {
2237
- direction: 'auto',
2238
- sticky: true,
2239
- opacity: 1,
2240
- className: 'elevation-tooltip'
2241
- }).openTooltip();
2242
- }
2243
- }
2244
- },
2245
2229
 
2246
2230
  /**
2247
2231
  * Initialize "L.AlmostOver" integration
@@ -2616,13 +2600,21 @@
2616
2600
  });
2617
2601
 
2618
2602
  if ([true, 'markers'].includes(wptLabels) && (name || desc)) {
2619
- marker.bindPopup("<b>" + name + "</b>" + (desc.length > 0 ? '<br>' + desc : '')).openPopup();
2603
+ var content = decodeURI("<b>" + name + "</b>" + (desc.length > 0 ? '<br>' + desc : ''));
2604
+ marker.bindPopup(content, {
2605
+ className: 'elevation-popup',
2606
+ keepInView: true
2607
+ }).openPopup();
2608
+ marker.bindTooltip(content, {
2609
+ className: 'elevation-tooltip',
2610
+ direction: 'auto',
2611
+ sticky: true,
2612
+ opacity: 1
2613
+ }).openTooltip();
2620
2614
  }
2621
2615
 
2622
2616
  control._addMarker(marker);
2623
2617
 
2624
- control._bindPopup(marker);
2625
-
2626
2618
  control.fire('waypoint_added', {
2627
2619
  point: marker,
2628
2620
  element: latlng,
@@ -3113,19 +3105,20 @@
3113
3105
 
3114
3106
  select('.download a', this._summary._container).onclick = function (e) {
3115
3107
  e.preventDefault();
3108
+ var event = {
3109
+ downloadLink: _this20.options.downloadLink,
3110
+ confirm: saveFile.bind(_this20, _this20._downloadURL)
3111
+ };
3116
3112
 
3117
- if (e.downloadLink == 'modal' && typeof CustomEvent === "function") {
3113
+ if (_this20.options.downloadLink == 'modal' && typeof CustomEvent === "function") {
3118
3114
  document.dispatchEvent(new CustomEvent("eletrack_download", {
3119
- detail: e
3115
+ detail: event
3120
3116
  }));
3121
- } else if (e.downloadLink == 'link' || e.downloadLink === true) {
3122
- e.confirm();
3117
+ } else if (_this20.options.downloadLink == 'link' || _this20.options.downloadLink === true) {
3118
+ event.confirm();
3123
3119
  }
3124
3120
 
3125
- _this20._fireEvt('eletrack_download', {
3126
- downloadLink: _this20.options.downloadLink,
3127
- confirm: saveFile.bind(_this20, _this20._downloadURL)
3128
- });
3121
+ _this20._fireEvt('eletrack_download', event);
3129
3122
  };
3130
3123
  }
3131
3124
  },