@raruto/leaflet-elevation 1.9.2 → 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.2",
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.2/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
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');