@raruto/leaflet-elevation 1.9.1 → 1.9.4

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" />
@@ -248,6 +239,7 @@ var map = L.map('map', {
248
239
  - https://wordpress.org/plugins/os-datahub-maps/
249
240
  - https://wordpress.org/plugins/extensions-leaflet-map/
250
241
  - https://github.com/der-stefan/OpenTopoMap
242
+ - https://gpx.n-peloton.fr/
251
243
 
252
244
  </details>
253
245
 
@@ -256,7 +248,7 @@ _Related: [Leaflet-UI presets](https://github.com/raruto/leaflet-ui), [QGIS Inte
256
248
  ---
257
249
 
258
250
  **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)
251
+ [![Leaflet 1.x compatible!](https://img.shields.io/badge/Leaflet-1.7.0-1EB300.svg?style=flat)](http://leafletjs.com/reference.html)
260
252
  [![d3.js v6 compatibile!](https://img.shields.io/badge/d3.js-6.5-1EB300.svg?style=flat)](https://www.npmjs.com/package/d3)
261
253
  [![@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
254
 
@@ -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
 
@@ -1706,7 +1707,11 @@
1706
1707
  collapsed: false,
1707
1708
  detached: true,
1708
1709
  distance: true,
1709
- distanceMarkers: false,
1710
+ distanceMarkers: {
1711
+ lazy: true,
1712
+ distance: true,
1713
+ arrow: false
1714
+ },
1710
1715
  decimalsX: 2,
1711
1716
  decimalsY: 0,
1712
1717
  dragging: !L.Browser.mobile,
@@ -1766,7 +1771,7 @@
1766
1771
  wptIcons: {
1767
1772
  '': L.divIcon({
1768
1773
  className: 'elevation-waypoint-marker',
1769
- html: '<i class="elevation-waypoint-icon"></i>',
1774
+ html: '<i class="elevation-waypoint-icon default"></i>',
1770
1775
  iconSize: [30, 30],
1771
1776
  iconAnchor: [8, 30]
1772
1777
  })
@@ -1793,7 +1798,7 @@
1793
1798
  __TOGEOJSON: 'https://unpkg.com/@tmcw/togeojson@4.5.0/dist/togeojson.umd.js',
1794
1799
  __LGEOMUTIL: 'https://unpkg.com/leaflet-geometryutil@0.9.3/src/leaflet.geometryutil.js',
1795
1800
  __LALMOSTOVER: 'https://unpkg.com/leaflet-almostover@1.0.1/src/leaflet.almostover.js',
1796
- __LDISTANCEM: 'https://unpkg.com/@raruto/leaflet-elevation@1.9.1/libs/leaflet-distance-marker.min.js',
1801
+ __LDISTANCEM: 'https://unpkg.com/@raruto/leaflet-elevation@1.9.4/libs/leaflet-distance-marker.min.js',
1797
1802
 
1798
1803
  /*
1799
1804
  * Add data to the diagram either from GPX or GeoJSON and update the axis domain and data
@@ -1958,9 +1963,7 @@
1958
1963
  if (this.options.legend) this.options.margins.bottom += 30;
1959
1964
  if (this.options.theme) this.options.polylineSegments.className += ' ' + this.options.theme;
1960
1965
  if (this.options.wptIcons === true) this.options.wptIcons = Options.wptIcons;
1961
- if (this.options.distanceMarkers === true) this.options.distanceMarkers = {
1962
- lazy: true
1963
- };
1966
+ if (this.options.distanceMarkers === true) this.options.distanceMarkers = Options.distanceMarkers;
1964
1967
 
1965
1968
  this._markedSegments.setStyle(this.options.polylineSegments); // Leaflet canvas renderer colors
1966
1969
 
@@ -2225,23 +2228,6 @@
2225
2228
  _addMarker: function _addMarker(marker) {
2226
2229
  if (marker) this._markers.addLayer(marker);
2227
2230
  },
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
2231
 
2246
2232
  /**
2247
2233
  * Initialize "L.AlmostOver" integration
@@ -2616,13 +2602,21 @@
2616
2602
  });
2617
2603
 
2618
2604
  if ([true, 'markers'].includes(wptLabels) && (name || desc)) {
2619
- marker.bindPopup("<b>" + name + "</b>" + (desc.length > 0 ? '<br>' + desc : '')).openPopup();
2605
+ var content = decodeURI("<b>" + name + "</b>" + (desc.length > 0 ? '<br>' + desc : ''));
2606
+ marker.bindPopup(content, {
2607
+ className: 'elevation-popup',
2608
+ keepInView: true
2609
+ }).openPopup();
2610
+ marker.bindTooltip(content, {
2611
+ className: 'elevation-tooltip',
2612
+ direction: 'auto',
2613
+ sticky: true,
2614
+ opacity: 1
2615
+ }).openTooltip();
2620
2616
  }
2621
2617
 
2622
2618
  control._addMarker(marker);
2623
2619
 
2624
- control._bindPopup(marker);
2625
-
2626
2620
  control.fire('waypoint_added', {
2627
2621
  point: marker,
2628
2622
  element: latlng,