@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raruto/leaflet-elevation",
3
- "version": "1.9.0",
3
+ "version": "1.9.3",
4
4
  "description": "A Leaflet plugin that allows to add elevation profiles using d3js",
5
5
  "main": "dist/leaflet-elevation.min.js",
6
6
  "module": "src/index.js",
package/src/components.js CHANGED
@@ -116,9 +116,11 @@ export const PositionMarker = ({
116
116
  }) => {
117
117
  return g => {
118
118
 
119
- let line = g.select('.height-focus.line');
119
+ g.attr("class", "height-focus-group");
120
+
121
+ let line = g.select('.height-focus.line');
120
122
  let circle = g.select('.height-focus.circle-lower');
121
- let text = g.select('.height-focus-label');
123
+ let text = g.select('.height-focus-label');
122
124
 
123
125
  if (!line.node()) line = g.append('svg:line');
124
126
  if (!circle.node()) circle = g.append('svg:circle');
package/src/control.js CHANGED
@@ -17,7 +17,7 @@ export const Elevation = L.Control.Elevation = L.Control.extend({
17
17
  __TOGEOJSON: 'https://unpkg.com/@tmcw/togeojson@4.5.0/dist/togeojson.umd.js',
18
18
  __LGEOMUTIL: 'https://unpkg.com/leaflet-geometryutil@0.9.3/src/leaflet.geometryutil.js',
19
19
  __LALMOSTOVER: 'https://unpkg.com/leaflet-almostover@1.0.1/src/leaflet.almostover.js',
20
- __LDISTANCEM: 'https://unpkg.com/@raruto/leaflet-elevation@1.9.0/libs/leaflet-distance-marker.min.js',
20
+ __LDISTANCEM: 'https://unpkg.com/@raruto/leaflet-elevation@1.9.3/libs/leaflet-distance-marker.min.js',
21
21
 
22
22
  /*
23
23
  * Add data to the diagram either from GPX or GeoJSON and update the axis domain and data
@@ -400,17 +400,6 @@ export const Elevation = L.Control.Elevation = L.Control.extend({
400
400
  if (marker) this._markers.addLayer(marker)
401
401
  },
402
402
 
403
- _bindPopup: function(marker) {
404
- let popup = marker._popup;
405
- if (popup) {
406
- popup.options.className = 'elevation-popup';
407
- if (popup._content) {
408
- popup._content = decodeURI(popup._content);
409
- popup.bindTooltip(popup._content, { direction: 'auto', sticky: true, opacity: 1, className: 'elevation-tooltip' }).openTooltip();
410
- }
411
- }
412
- },
413
-
414
403
  /**
415
404
  * Initialize "L.AlmostOver" integration
416
405
  */
@@ -754,10 +743,11 @@ export const Elevation = L.Control.Elevation = L.Control.extend({
754
743
  }
755
744
  let marker = L.marker(latlng, { icon: wptIcons[sym] });
756
745
  if ([true, 'markers'].includes(wptLabels) && (name || desc)) {
757
- marker.bindPopup("<b>" + name + "</b>" + (desc.length > 0 ? '<br>' + desc : '')).openPopup();
746
+ let content = decodeURI("<b>" + name + "</b>" + (desc.length > 0 ? '<br>' + desc : ''));
747
+ marker.bindPopup(content, { className: 'elevation-popup', keepInView: true }).openPopup();
748
+ marker.bindTooltip(content, { className: 'elevation-tooltip', direction: 'auto', sticky: true, opacity: 1 }).openTooltip();
758
749
  }
759
750
  control._addMarker(marker);
760
- control._bindPopup(marker);
761
751
  control.fire('waypoint_added', { point: marker, element: latlng, properties: prop });
762
752
  return marker;
763
753
  }
@@ -1147,12 +1137,13 @@ export const Elevation = L.Control.Elevation = L.Control.extend({
1147
1137
  this._summary._container.innerHTML += '<span class="download"><a href="#">' + L._('Download') + '</a></span>'
1148
1138
  _.select('.download a', this._summary._container).onclick = (e) => {
1149
1139
  e.preventDefault();
1150
- if (e.downloadLink == 'modal' && typeof CustomEvent === "function") {
1151
- document.dispatchEvent(new CustomEvent("eletrack_download", { detail: e }));
1152
- } else if (e.downloadLink == 'link' || e.downloadLink === true) {
1153
- e.confirm();
1140
+ let event = { downloadLink: this.options.downloadLink, confirm: _.saveFile.bind(this, this._downloadURL) };
1141
+ if (this.options.downloadLink == 'modal' && typeof CustomEvent === "function") {
1142
+ document.dispatchEvent(new CustomEvent("eletrack_download", { detail: event }));
1143
+ } else if (this.options.downloadLink == 'link' || this.options.downloadLink === true) {
1144
+ event.confirm();
1154
1145
  }
1155
- this._fireEvt('eletrack_download', { downloadLink: this.options.downloadLink, confirm: _.saveFile.bind(this, this._downloadURL) });
1146
+ this._fireEvt('eletrack_download', event);
1156
1147
  };
1157
1148
  };
1158
1149
  },
package/src/marker.js CHANGED
@@ -10,8 +10,6 @@ export var Marker = L.Class.extend({
10
10
  switch(this.options.marker) {
11
11
  case 'elevation-line':
12
12
  // this._container = d3.create("g").attr("class", "height-focus-group");
13
- this._container = d3.select(map.getPane('elevationPane')).select("svg > g")
14
- .attr("class", "height-focus-group");
15
13
  break;
16
14
  case 'position-marker':
17
15
  // this._marker = L.circleMarker([0, 0], { pane: 'overlayPane', radius: 6, fillColor: '#fff', fillOpacity:1, color: '#000', weight:1, interactive: false });
@@ -27,7 +25,7 @@ export var Marker = L.Class.extend({
27
25
  addTo: function(map) {
28
26
  this._map = map;
29
27
  switch(this.options.marker) {
30
- case 'elevation-line': this._container.call(D3.PositionMarker({})); break;
28
+ case 'elevation-line': this._container = d3.select(map.getPane('elevationPane')).select("svg > g").call(D3.PositionMarker({})); break;
31
29
  case 'position-marker': this._marker.addTo(map, { pane: 'overlayPane' }); break;
32
30
  }
33
31
  return this;
@@ -49,18 +47,20 @@ export var Marker = L.Class.extend({
49
47
 
50
48
  switch(this.options.marker) {
51
49
  case 'elevation-line':
52
- let point = this._map.latLngToLayerPoint(this._latlng);
53
- point = L.extend({}, props.item, this._map._rotate ? this._map.rotatedPointToMapPanePoint(point) : point);
54
-
55
- this._container.classed("leaflet-hidden", false);
56
- this._container.call(D3.PositionMarker({
57
- theme : this.options.theme,
58
- xCoord: point.x,
59
- yCoord: point.y,
60
- length: point.y - (this._height() / props.maxElevation * point.z), // normalized Y
61
- labels: this._labels,
62
- item: point
63
- }));
50
+ if (this._container) {
51
+ let point = this._map.latLngToLayerPoint(this._latlng);
52
+ point = L.extend({}, props.item, this._map._rotate ? this._map.rotatedPointToMapPanePoint(point) : point);
53
+
54
+ this._container.classed("leaflet-hidden", false);
55
+ this._container.call(D3.PositionMarker({
56
+ theme : this.options.theme,
57
+ xCoord: point.x,
58
+ yCoord: point.y,
59
+ length: point.y - (this._height() / props.maxElevation * point.z), // normalized Y
60
+ labels: this._labels,
61
+ item: point
62
+ }));
63
+ }
64
64
  break;
65
65
  case 'position-marker':
66
66
  _.removeClass(this._marker.getElement(), 'leaflet-hidden');
package/src/options.js CHANGED
@@ -69,7 +69,7 @@ export var Options = {
69
69
  wptIcons: {
70
70
  '': L.divIcon({
71
71
  className: 'elevation-waypoint-marker',
72
- html: '<i class="elevation-waypoint-icon"></i>',
72
+ html: '<i class="elevation-waypoint-icon default"></i>',
73
73
  iconSize: [30, 30],
74
74
  iconAnchor: [8, 30],
75
75
  }),