leaflet-hexbin 0.1.3 → 0.1.5

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/dist/index.es.js CHANGED
@@ -1,47 +1,47 @@
1
1
  import * as f from "d3";
2
2
  import { scaleLinear as y, dispatch as R, select as L, extent as T } from "d3";
3
3
  import { hexbin as w } from "d3-hexbin";
4
- import * as u from "leaflet";
4
+ import * as c from "leaflet";
5
5
  var v;
6
6
  ((r) => {
7
7
  function o() {
8
8
  return {
9
- mouseover: function(c, i, a, p) {
10
- f.select(c.parentElement).select("path.hexbin-hexagon").transition().duration(i.options.duration).attr("d", function(h) {
11
- return i._hexLayout.hexagon(i.options.radius);
9
+ mouseover: function(u, n, a, p) {
10
+ f.select(u.parentElement).select("path.hexbin-hexagon").transition().duration(n.options.duration).attr("d", function(h) {
11
+ return n._hexLayout.hexagon(n.options.radius);
12
12
  });
13
13
  },
14
- mouseout: function(c, i, a, p) {
15
- f.select(c.parentElement).select("path.hexbin-hexagon").transition().duration(i.options.duration).attr("d", function(h) {
16
- return i._hexLayout.hexagon(i.radiusScale()(i.radiusValue()(h)));
14
+ mouseout: function(u, n, a, p) {
15
+ f.select(u.parentElement).select("path.hexbin-hexagon").transition().duration(n.options.duration).attr("d", function(h) {
16
+ return n._hexLayout.hexagon(n.radiusScale()(n.radiusValue()(h)));
17
17
  });
18
18
  }
19
19
  };
20
20
  }
21
21
  r.resizeFill = o;
22
- function e(c = 1.5) {
22
+ function i(u = 1.5) {
23
23
  return {
24
- mouseover: function(i, a, p, d) {
25
- f.select(i.parentElement).select("path.hexbin-hexagon").transition().duration(a.options.duration).attr("d", function() {
26
- return a._hexLayout.hexagon(a.radiusScale().range()[1] * c);
24
+ mouseover: function(n, a, p, d) {
25
+ f.select(n.parentElement).select("path.hexbin-hexagon").transition().duration(a.options.duration).attr("d", function() {
26
+ return a._hexLayout.hexagon(a.radiusScale().range()[1] * u);
27
27
  });
28
28
  },
29
- mouseout: function(i, a, p, d) {
30
- f.select(i.parentElement).select("path.hexbin-hexagon").transition().duration(a.options.duration).attr("d", (g) => a._hexLayout.hexagon(a.radiusScale()(a.radiusValue()(g))));
29
+ mouseout: function(n, a, p, d) {
30
+ f.select(n.parentElement).select("path.hexbin-hexagon").transition().duration(a.options.duration).attr("d", (m) => a._hexLayout.hexagon(a.radiusScale()(a.radiusValue()(m))));
31
31
  }
32
32
  };
33
33
  }
34
- r.resizeScale = e;
35
- function t(c = [l()]) {
34
+ r.resizeScale = i;
35
+ function t(u = [l()]) {
36
36
  return {
37
- mouseover: function(i, a, p, d) {
38
- c.forEach((h) => {
39
- h.mouseover(i, a, p, d);
37
+ mouseover: function(n, a, p, d) {
38
+ u.forEach((h) => {
39
+ h.mouseover(n, a, p, d);
40
40
  });
41
41
  },
42
- mouseout: function(i, a, p, d) {
43
- c.forEach((h) => {
44
- h.mouseout(i, a, p, d);
42
+ mouseout: function(n, a, p, d) {
43
+ u.forEach((h) => {
44
+ h.mouseout(n, a, p, d);
45
45
  });
46
46
  }
47
47
  };
@@ -59,9 +59,17 @@ var v;
59
59
  })(v || (v = {}));
60
60
  const V = v;
61
61
  function O(r) {
62
- return r instanceof u.LatLng || typeof r == "object" && "lat" in r && "lng" in r || Array.isArray(r) && r.length === 2 && typeof r[0] == "number" && typeof r[1] == "number";
62
+ return r instanceof c.LatLng || typeof r == "object" && "lat" in r && "lng" in r || Array.isArray(r) && r.length === 2 && typeof r[0] == "number" && typeof r[1] == "number";
63
63
  }
64
- class C extends u.SVG {
64
+ const C = (r, o) => {
65
+ let i;
66
+ return function(...t) {
67
+ clearTimeout(i), i = setTimeout(() => {
68
+ r(...t);
69
+ }, o);
70
+ };
71
+ };
72
+ class H extends c.SVG {
65
73
  constructor(o) {
66
74
  super(), this.options = {
67
75
  radius: 12,
@@ -78,21 +86,21 @@ class C extends u.SVG {
78
86
  noRedraw: !1,
79
87
  // Handle parent default options
80
88
  // ...L.SVG.prototype.options,
81
- ...u.Renderer.prototype.options,
82
- ...u.Layer.prototype.options
89
+ ...c.Renderer.prototype.options,
90
+ ...c.Layer.prototype.options
83
91
  }, this._fn = {
84
- colorValue: (e) => e.length,
85
- radiusValue: (e) => e.length,
86
- opacityValue: (e) => e.length,
87
- fill: (e) => {
88
- const t = this._fn.colorValue(e);
92
+ colorValue: (i) => i.length,
93
+ radiusValue: (i) => i.length,
94
+ opacityValue: (i) => i.length,
95
+ fill: (i) => {
96
+ const t = this._fn.colorValue(i);
89
97
  return t != null ? this._scale.color(t) : "none";
90
98
  }
91
99
  }, this._scale = {
92
100
  color: y(),
93
101
  radius: y(),
94
102
  opacity: y()
95
- }, this._dispatch = R("mouseover", "mouseout", "click"), this._hoverHandler = V.none(), this._hexLayout = w().radius(this.options.radius).x(({ point: { x: e } }) => e).y(({ point: { y: e } }) => e), this._data = Array(), this._tooltipOptions = {}, this.options = { ...this.options, ...o }, this._scale.color.range(this.options.colorRange).clamp(!0), this._scale.radius.range(this.options.radiusRange ?? [this.options.radius, this.options.radius]).clamp(!0), this._scale.opacity.range(
103
+ }, this._dispatch = R("mouseover", "mouseout", "click"), this._hoverHandler = V.none(), this._hexLayout = w().radius(this.options.radius).x(({ point: { x: i } }) => i).y(({ point: { y: i } }) => i), this._data = Array(), this._tooltipOptions = {}, this.options = { ...this.options, ...o }, this._scale.color.range(this.options.colorRange).clamp(!0), this._scale.radius.range(this.options.radiusRange ?? [this.options.radius, this.options.radius]).clamp(!0), this._scale.opacity.range(
96
104
  typeof this.options.opacity == "number" ? [this.options.opacity, this.options.opacity] : this.options.opacity
97
105
  ).clamp(!0);
98
106
  }
@@ -111,8 +119,8 @@ class C extends u.SVG {
111
119
  * @param map Reference to the map to which this layer has been added
112
120
  */
113
121
  onAdd(o) {
114
- var e;
115
- return super.onAdd(o), this._map = o, (e = this._tooltip) == null || e.setLatLng([0, 0]).addTo(o), o.on("moveend", this.redraw, this), this.redraw(), this;
122
+ var i;
123
+ return super.onAdd(o), this._map = o, (i = this._tooltip) == null || i.setLatLng([0, 0]).addTo(o), o.on("moveend", C(() => this.redraw(), 100)), this.redraw(), this;
116
124
  }
117
125
  /**
118
126
  * Callback made by Leaflet when the layer is removed from the map
@@ -133,53 +141,53 @@ class C extends u.SVG {
133
141
  redraw() {
134
142
  const o = this;
135
143
  if (!o._map) return;
136
- const e = o._data.map((i) => {
137
- const a = o._accessor(i), p = o._map.latLngToLayerPoint(a);
138
- return { coord: a, point: p, data: i };
139
- }), t = this._d3Container.selectAll("g.hexbin").data([this._map.getZoom()], (i) => i), c = t.enter().append("g").attr("class", function(i) {
140
- return "hexbin zoom-" + i;
144
+ const i = o._data.map((n) => {
145
+ const a = o._accessor(n), p = o._map.latLngToLayerPoint(a);
146
+ return { coord: a, point: p, data: n };
147
+ }), t = this._d3Container.selectAll("g.hexbin").data([this._map.getZoom()], (n) => n), u = t.enter().append("g").attr("class", function(n) {
148
+ return "hexbin zoom-" + n;
141
149
  }).merge(t);
142
- t.exit().remove(), this._createHexagons(c, e);
150
+ t.exit().remove(), this._createHexagons(u, i);
143
151
  }
144
- _linearlySpace(o, e, t) {
145
- const l = (e - o) / Math.max(t - 1, 1);
146
- return Array.from({ length: t }, (c, i) => o + i * l);
152
+ _linearlySpace(o, i, t) {
153
+ const l = (i - o) / Math.max(t - 1, 1);
154
+ return Array.from({ length: t }, (u, n) => o + n * l);
147
155
  }
148
- _createHexagons(o, e) {
149
- const t = this, l = t._map.getSize(), c = t._map.getBounds().pad(t.options.radius * 2 / Math.max(l.x, l.y)), i = t._hexLayout(e).filter(
150
- ({ x: n, y: s }) => c.contains(t._map.layerPointToLatLng(u.point(n, s)))
151
- ), a = t._getExtent(i, t._fn.colorValue, t.options.colorScaleExtent), p = t._getExtent(i, t._fn.radiusValue, t.options.radiusScaleExtent), d = t._getExtent(i, t._fn.opacityValue, t.options.opacityScaleExtent), h = this.options.colorDomain ?? t._linearlySpace(
156
+ _createHexagons(o, i) {
157
+ const t = this, l = t._map.getSize(), u = t._map.getBounds().pad(t.options.radius * 2 / Math.max(l.x, l.y)), n = t._hexLayout.radius(this.options.radius)(i).filter(
158
+ ({ x: e, y: s }) => u.contains(t._map.layerPointToLatLng(c.point(e, s)))
159
+ ), a = t._getExtent(n, t._fn.colorValue, t.options.colorScaleExtent), p = t._getExtent(n, t._fn.radiusValue, t.options.radiusScaleExtent), d = t._getExtent(n, t._fn.opacityValue, t.options.opacityScaleExtent), h = this.options.colorDomain ?? t._linearlySpace(
152
160
  a[0],
153
161
  a[1],
154
162
  t._scale.color.range().length
155
- ), g = this.options.radiusDomain || p;
156
- t._scale.color.domain(h), t._scale.radius.domain(g), t._scale.opacity.domain(d);
157
- const m = o.selectAll("g.hexbin-container").data(i, ({ x: n, y: s }) => `${n}:${s}`);
158
- m.select("path.hexbin-hexagon").transition().duration(t.options.duration).attr("fill", t._fn.fill.bind(t)).attr("fill-opacity", (n) => t._scale.opacity(t._fn.opacityValue.call(t, n))).attr("stroke-opacity", (n) => t._scale.opacity(t._fn.opacityValue.call(t, n))).attr("d", (n) => t._hexLayout.hexagon(t._scale.radius(t._fn.radiusValue.call(t, n))));
159
- const x = m.enter().append("g").attr("class", "hexbin-container").style("pointer-events", t.options.pointerEvents);
160
- x.on("mouseover", function(n, s) {
163
+ ), m = this.options.radiusDomain || p;
164
+ t._scale.color.domain(h), t._scale.radius.domain(m), t._scale.opacity.domain(d);
165
+ const g = o.selectAll("g.hexbin-container").data(n, ({ x: e, y: s }) => `${e}:${s}`);
166
+ g.select("path.hexbin-hexagon").transition().duration(t.options.duration).attr("fill", t._fn.fill.bind(t)).attr("fill-opacity", (e) => t._scale.opacity(t._fn.opacityValue.call(t, e))).attr("stroke-opacity", (e) => t._scale.opacity(t._fn.opacityValue.call(t, e))).attr("d", (e) => t._hexLayout.hexagon(t._scale.radius(t._fn.radiusValue.call(t, e))));
167
+ const x = g.enter().append("g").attr("class", "hexbin-container").style("pointer-events", t.options.pointerEvents);
168
+ x.on("mouseover", function(e, s) {
161
169
  L(this).raise();
162
170
  });
163
- const b = x.append("path").attr("class", "hexbin-hexagon").attr("transform", ({ x: n, y: s }) => `translate(${n},${s})`).attr("d", () => t._hexLayout.hexagon(t._scale.radius.range()[0])).attr("fill", t._fn.fill.bind(t)).attr("fill-opacity", 0.01).attr("stroke-opacity", 0.01).style("pointer-events", "all");
164
- b.transition().duration(t.options.duration).attr("fill-opacity", (n) => t._scale.opacity(t._fn.opacityValue.call(t, n))).attr("stroke-opacity", (n) => t._scale.opacity(t._fn.opacityValue.call(t, n))).attr("d", (n) => t._hexLayout.hexagon(t._scale.radius(t._fn.radiusValue.call(t, n)))).style("pointer-events", "all"), x.append("path").attr("class", "hexbin-grid").attr("transform", ({ x: n, y: s }) => `translate(${n},${s})`).attr("d", () => t._hexLayout.hexagon(t.options.radius)).attr("fill", "none").attr("stroke", "none"), b.on("mouseover", function(n, s) {
171
+ const b = x.append("path").attr("class", "hexbin-hexagon").attr("transform", ({ x: e, y: s }) => `translate(${e},${s})`).attr("d", () => t._hexLayout.hexagon(t._scale.radius.range()[0])).attr("fill", t._fn.fill.bind(t)).attr("fill-opacity", 0.01).attr("stroke-opacity", 0.01).style("pointer-events", "all");
172
+ b.transition().duration(t.options.duration).attr("fill-opacity", (e) => t._scale.opacity(t._fn.opacityValue.call(t, e))).attr("stroke-opacity", (e) => t._scale.opacity(t._fn.opacityValue.call(t, e))).attr("d", (e) => t._hexLayout.hexagon(t._scale.radius(t._fn.radiusValue.call(t, e)))).style("pointer-events", "all"), x.append("path").attr("class", "hexbin-grid").attr("transform", ({ x: e, y: s }) => `translate(${e},${s})`).attr("d", () => t._hexLayout.hexagon(t.options.radius)).attr("fill", "none").attr("stroke", "none"), b.on("mouseover", function(e, s) {
165
173
  var _, S;
166
174
  (_ = t._tooltipOptions) != null && _.content && ((S = t._tooltip) == null || S.setContent(
167
175
  typeof t._tooltipOptions.content == "function" ? t._tooltipOptions.content(s) : t._tooltipOptions.content
168
176
  ).setLatLng(
169
- t._map.layerPointToLatLng(u.point(s.x, s.y))
170
- ).openOn(t._map)), t._hoverHandler.mouseover(this, t, n, s), t._dispatch.call("mouseover", this, s, t, n), this.classList.add("hover");
171
- }).on("mouseout", function(n, s) {
177
+ t._map.layerPointToLatLng(c.point(s.x, s.y))
178
+ ).openOn(t._map)), t._hoverHandler.mouseover(this, t, e, s), t._dispatch.call("mouseover", this, s, t, e), this.classList.add("hover");
179
+ }).on("mouseout", function(e, s) {
172
180
  var _;
173
- (_ = t._tooltip) == null || _.close(), t._hoverHandler.mouseout(this, t, n, s), t._dispatch.call("mouseout", this, s, t, n), this.classList.remove("hover");
174
- }).on("click", function(n, s) {
175
- const _ = t._map.layerPointToLatLng(u.point(s.x, s.y));
176
- t._dispatch.call("click", this, s, _, t, n), n.stopPropagation();
181
+ (_ = t._tooltip) == null || _.close(), t._hoverHandler.mouseout(this, t, e, s), t._dispatch.call("mouseout", this, s, t, e), this.classList.remove("hover");
182
+ }).on("click", function(e, s) {
183
+ const _ = t._map.layerPointToLatLng(c.point(s.x, s.y));
184
+ t._dispatch.call("click", this, s, _, t, e), e.stopPropagation();
177
185
  });
178
- const E = m.exit();
179
- E.select("path.hexbin-hexagon").transition().duration(t.options.duration).attr("fill-opacity", 0).attr("stroke-opacity", 0).attr("d", (n) => t._hexLayout.hexagon(0)), E.transition().duration(t.options.duration).remove();
186
+ const E = g.exit();
187
+ E.select("path.hexbin-hexagon").transition().duration(t.options.duration).attr("fill-opacity", 0).attr("stroke-opacity", 0).attr("d", (e) => t._hexLayout.hexagon(0)), E.transition().duration(t.options.duration).remove();
180
188
  }
181
- _getExtent(o, e, t) {
182
- let l = T(o, e.bind(this));
189
+ _getExtent(o, i, t) {
190
+ let l = T(o, i.bind(this));
183
191
  return (l[0] === void 0 || l[1] === void 0) && (l = [0, 0]), t[0] != null && (l[0] = t[0]), t[1] != null && (l[1] = t[1]), l;
184
192
  }
185
193
  radius(o) {
@@ -222,8 +230,8 @@ class C extends u.SVG {
222
230
  return o === void 0 ? this._fn.fill : (this._fn.fill = o, this);
223
231
  }
224
232
  // Implementation
225
- data(o, e) {
226
- return o === void 0 ? this._data : (!O(o[0]) && !e && console.error("Leaflet hexbin: data does not appear to be an array of L.LatLngExpression. You must provide an accessor function to convert the data to L.LatLngExpression"), this._data = o ?? [], this._accessor = e ?? ((t) => t), this.options.noRedraw || this.redraw(), this);
233
+ data(o, i) {
234
+ return o === void 0 ? this._data : (!O(o[0]) && !i && console.error("Leaflet hexbin: data does not appear to be an array of L.LatLngExpression. You must provide an accessor function to convert the data to L.LatLngExpression"), this._data = o ?? [], this._accessor = i ?? ((t) => t), this.options.noRedraw || this.redraw(), this);
227
235
  }
228
236
  accessor() {
229
237
  return this._accessor;
@@ -242,7 +250,7 @@ class C extends u.SVG {
242
250
  */
243
251
  // Cannot overload bindTooltip() with data dependant content
244
252
  tooltip(o) {
245
- return this._tooltipOptions = o, this._tooltip ? this._tooltip.options = o.options ?? {} : this._tooltip = u.tooltip(o.options), this;
253
+ return this._tooltipOptions = o, this._tooltip ? this._tooltip.options = o.options ?? {} : this._tooltip = c.tooltip(o.options), this;
246
254
  }
247
255
  /**
248
256
  * Get the tooltip instance attached to the hexbin layer
@@ -254,8 +262,8 @@ class C extends u.SVG {
254
262
  * Bind a tooltip to the hexbin layer with the provided content and options.
255
263
  * Useful to bind an existing tooltip instance to the hexbin layer.
256
264
  */
257
- bindTooltip(o, e) {
258
- return o instanceof u.Tooltip ? (this._tooltip = o, this._map && this._tooltip.setLatLng([0, 0]).addTo(this._map)) : this._tooltip = u.tooltip(e).setContent(o), this;
265
+ bindTooltip(o, i) {
266
+ return o instanceof c.Tooltip ? (this._tooltip = o, this._map && this._tooltip.setLatLng([0, 0]).addTo(this._map)) : this._tooltip = c.tooltip(i).setContent(o), this;
259
267
  }
260
268
  /**
261
269
  * Unbind the tooltip from the hexbin layer
@@ -268,24 +276,24 @@ class C extends u.SVG {
268
276
  * Returns an array of the points in the path, or nested arrays of points in case of multi-polyline.
269
277
  */
270
278
  getLatLngs() {
271
- return this._data.map((o) => u.latLng(this._accessor(o)));
279
+ return this._data.map((o) => c.latLng(this._accessor(o)));
272
280
  }
273
281
  /*
274
282
  * Get path geometry as GeoJSON
275
283
  */
276
284
  toGeoJSON() {
277
- return u.GeoJSON.getFeature(this, {
285
+ return c.GeoJSON.getFeature(this, {
278
286
  type: "MultiPoint",
279
- coordinates: u.GeoJSON.latLngsToCoords(this.getLatLngs(), 0)
287
+ coordinates: c.GeoJSON.latLngsToCoords(this.getLatLngs(), 0)
280
288
  });
281
289
  }
282
290
  }
283
- function A(r) {
284
- return new C(r);
291
+ function z(r) {
292
+ return new H(r);
285
293
  }
286
294
  export {
287
295
  V as HexbinHoverHandler,
288
- C as HexbinLayer,
289
- A as hexbinLayer
296
+ H as HexbinLayer,
297
+ z as hexbinLayer
290
298
  };
291
299
  //# sourceMappingURL=index.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.es.js","sources":["../src/HexbinHoverHandler.ts","../src/HexbinLayer.ts"],"sourcesContent":["import * as d3 from 'd3';\nimport type { HexbinData } from './HexbinLayer';\nimport { type HexbinLayer } from './HexbinLayer';\n\n/**\n * Interface for handling hover events on hexbins.\n */\nexport interface HexbinHoverHandler<Data> {\n mouseover(svg: SVGPathElement, hexLayer: HexbinLayer<Data>, event: MouseEvent, data: HexbinData<Data>[]): void;\n mouseout(svg: SVGPathElement, hexLayer: HexbinLayer<Data>, event: MouseEvent, data: HexbinData<Data>[]): void;\n}\n\n/**\n * Built-in hover handlers for hexbins.\n */\nexport namespace HexbinHoverHandler {\n /**\n * Resize the hexbin to fill the hexagon grid cell on hover.\n */\n export function resizeFill(): HexbinHoverHandler<any> {\n return {\n mouseover: function (svg: SVGPathElement, hexLayer: HexbinLayer<any>, event: MouseEvent, data: HexbinData<any>[]) {\n const o = d3.select<HTMLElement | null, HexbinData<any>[]>(svg.parentElement);\n o.select('path.hexbin-hexagon')\n .transition().duration(hexLayer.options.duration)\n .attr('d', function (d) {\n return hexLayer._hexLayout.hexagon(hexLayer.options.radius);\n });\n },\n mouseout: function (svg: SVGPathElement, hexLayer: HexbinLayer<any>, event: MouseEvent, data: HexbinData<any>[]) {\n const o = d3.select<HTMLElement | null, HexbinData<any>[]>(svg.parentElement);\n o.select<SVGPathElement>('path.hexbin-hexagon')\n .transition().duration(hexLayer.options.duration)\n .attr('d', function (d) {\n return hexLayer._hexLayout.hexagon(hexLayer.radiusScale()(hexLayer.radiusValue()(d)));\n });\n }\n };\n\n }\n\n /**\n * Resize the hexbin by a scaling factor on hover.\n */\n export function resizeScale(radiusScale: number = 1.5): HexbinHoverHandler<any> {\n\n // return the handler instance\n return {\n mouseover: function (svg, hexLayer, event, data) {\n const o = d3.select<HTMLElement | null, HexbinData<any>[]>(svg.parentElement);\n o.select('path.hexbin-hexagon')\n .transition().duration(hexLayer.options.duration)\n .attr('d', function () {\n return hexLayer._hexLayout.hexagon(hexLayer.radiusScale().range()[1] * (radiusScale));\n });\n },\n mouseout: function (svg, hexLayer, event, data) {\n const o = d3.select<HTMLElement | null, HexbinData<any>[]>(svg.parentElement!);\n o.select('path.hexbin-hexagon')\n .transition().duration(hexLayer.options.duration)\n .attr('d', (d) => {\n return hexLayer._hexLayout.hexagon(hexLayer.radiusScale()(hexLayer.radiusValue()(d)));\n });\n }\n };\n }\n\n /**\n * Compound multiple hover handlers into a single handler.\n */\n export function compound<Data>(handlers: HexbinHoverHandler<Data>[] = [none()]): HexbinHoverHandler<Data> {\n return {\n mouseover: function (svg, hexLayer, event, data) {\n handlers!.forEach((h) => { h.mouseover(svg, hexLayer, event, data); });\n },\n mouseout: function (svg, hexLayer, event, data) {\n handlers!.forEach((h) => { h.mouseout(svg, hexLayer, event, data); });\n }\n };\n }\n\n /**\n * No hover handler.\n * @deprecated Will be removed in future versions\n */\n export function none(): HexbinHoverHandler<any> {\n return {\n mouseover: function () { },\n mouseout: function () { }\n };\n }\n\n}\nexport default HexbinHoverHandler\n","import { scaleLinear, dispatch, select, extent } from 'd3';\nimport { hexbin, type HexbinBin } from 'd3-hexbin';\nimport * as L from 'leaflet';\nimport HexbinHoverHandler from './HexbinHoverHandler';\n\n/**\n * @notExported\n */\nL.SVG\n\n// Need to expose some methods from L.SVG\ndeclare module 'leaflet' {\n interface SVG {\n _initContainer(): void;\n _container: SVGElementTagNameMap['svg']\n }\n}\n\n/**\n * Tooltip definition for the hexbin layer.\n * This can be used to generate a tooltip for each hexbin, if an external tooltip was not provided using bindTooltip()\n */\nexport type TooltipOptions<Data> = {\n options?: L.TooltipOptions,\n content?: L.Content | ((d: HexbinData<Data>[]) => L.Content)\n}\n\n/**\n * Hexbin layer configuration options this can be provided when instantiating a new hexbin layer.\n */\nexport interface HexbinLayerConfig {\n /**\n * Hex grid cell radius in pixels.\n * This value should be a positive number.\n * This radius controls the radius of the hexagons used to bin the data\n * but not necessarily to draw each individual hexbin.\n * @default 12\n */\n radius?: number,\n /**\n * Sets the opacity on the hexbin layer.\n * This value should be a number between 0 and 1.\n * If an array is provided, the first element is the minimum opacity and the second is the maximum.\n * @default 0.6\n */\n opacity?: number | [number, number],\n /**\n * Opacity scale extent: [min, max] domain for opacity interpolation.\n * @default [1, undefined]\n */\n opacityScaleExtent?: [number, number | undefined],\n /**\n * Duration of transition in milliseconds.\n * @default 200\n */\n duration?: number,\n\n /**\n * Color scale extent: [min, max] domain for color interpolation.\n * @default [1, undefined]\n */\n colorScaleExtent?: [number, number | undefined],\n /**\n * This is used to override the default behavior, which is to derive the color domain from the data.\n * Normally, you can tweak the generation of the color domain using the colorScaleExtent option.\n * However, if you want to set a completely custom domain, you can provide it as an array of values with this option.\n * The array of values will be passed directly into the domain of the color scale before rendering.\n * @default null\n */\n colorDomain?: number[] | null\n /**\n * Color range used to fill the hexbins.\n * @default ['#f7fbff', '#08306b']\n */\n colorRange?: string[],\n\n /**\n * Radius scale extent: [min, max] domain for radius interpolation.\n * @default [1, undefined]\n */\n radiusScaleExtent?: [number, number | undefined],\n /**\n * This is used to override the default behavior, which is to derive the radius domain from the data.\n * Normally, you can tweak the generation of the radius domain using the radiusScaleExtent option.\n * However, if you want to set a completely custom domain, you can provide it as an array of values with this option.\n * The array of values will be passed directly into the domain of the radius scale before rendering.\n * @default null\n */\n radiusDomain?: number[] | null\n /**\n * Sets the range of the radius scale used to size the hexbins.\n * @default hex grid cell radius\n */\n radiusRange?: [number, number] | null,\n\n /**\n * You should only modify this config option if you want to change the mouse event behavior on hexbins. This will modify when the events are propagated based on the visibility state and/or part of the hexbin being hovered.\n * @default 'all'\n */\n pointerEvents?: string\n\n /**\n * If true, the layer will not be redrawn after data changes and hover handler binding.\n * @default false\n */\n noRedraw?: boolean\n}\n\n/**\n * Hexbin data attached to each hexagon, once binned.\n */\nexport type HexbinData<Data> = {\n data: Data;\n coord: L.LatLngExpression;\n point: Readonly<L.Point>;\n}\n\n\nfunction isLatLngExpression(d: any): d is L.LatLngExpression {\n return (\n d instanceof L.LatLng ||\n (typeof d === 'object' && \"lat\" in d && \"lng\" in d) ||\n (Array.isArray(d) && d.length === 2 && typeof d[0] === 'number' && typeof d[1] === 'number')\n )\n}\n\n/**\n * A layer for displaying binned data in a hexagon grid on a Leaflet map.\n * Extends L.SVG to take advantage of built-in zoom animations.\n */\nexport class HexbinLayer<Data = L.LatLngExpression> extends L.SVG {\n /**\n * Default options for the hexbin layer\n */\n options: Required<HexbinLayerConfig> & L.RendererOptions = {\n radius: 12,\n opacity: 0.6,\n duration: 200,\n\n colorScaleExtent: [1, undefined],\n radiusScaleExtent: [1, undefined],\n opacityScaleExtent: [1, undefined],\n colorDomain: null,\n radiusDomain: null,\n colorRange: ['#f7fbff', '#08306b'],\n radiusRange: null,\n\n pointerEvents: 'all',\n noRedraw: false,\n // Handle parent default options\n // ...L.SVG.prototype.options,\n ...L.Renderer.prototype.options,\n ...L.Layer.prototype.options\n }\n\n /**\n * Internal functions to access the data\n */\n protected _fn = {\n colorValue: (d: HexbinData<Data>[]) => d.length,\n radiusValue: (d: HexbinData<Data>[]) => d.length,\n opacityValue: (d: HexbinData<Data>[]) => d.length,\n fill: (d: HexbinData<Data>[]) => {\n const val = this._fn.colorValue(d);\n return (null != val) ? this._scale.color(val) : 'none';\n }\n }\n /**\n * D3 scales used for the hexbin layer\n */\n _scale = {\n color: scaleLinear<string, string>(),\n radius: scaleLinear(),\n opacity: scaleLinear()\n };\n\n // Set up the Dispatcher for managing events and callbacks\n protected _dispatch = dispatch<SVGPathElement>('mouseover', 'mouseout', 'click');\n\n // Set up the default hover handler\n protected _hoverHandler: HexbinHoverHandler<Data> = HexbinHoverHandler.none();\n\n // Create the hex layout\n _hexLayout = hexbin<HexbinData<Data>>()\n .radius(this.options.radius)\n .x(({ point: { x } }) => x)\n .y(({ point: { y } }) => y);\n\n // Initialize the data array to be empty\n protected _data = Array<Data>()\n\n\n declare protected _map: L.Map;\n\n protected _tooltipOptions: TooltipOptions<Data> = {};\n declare protected _tooltip: L.Tooltip | undefined;\n\n // declare _container: SVGElementTagNameMap['svg'];\n\n // declare _container: HTMLElement;\n declare protected _d3Container: d3.Selection<SVGGElement, unknown, null, undefined>;\n\n public constructor(options?: HexbinLayerConfig) {\n super()\n // L.SVG.prototype.initialize.call(this, options);\n this.options = { ...this.options, ...options };\n this._scale.color\n .range(this.options.colorRange)\n .clamp(true);\n\n this._scale.radius\n .range(this.options.radiusRange ?? [this.options.radius, this.options.radius])\n .clamp(true);\n\n this._scale.opacity\n .range(\n typeof this.options.opacity === 'number'\n ? [this.options.opacity, this.options.opacity]\n : this.options.opacity\n ).clamp(true);\n\n };\n\n protected _accessor(d: Data) {\n return d as L.LatLngExpression;\n }\n\n /**\n * Create the SVG container for the hexbins\n * @private\n */\n _initContainer() {\n super._initContainer();\n this._d3Container = select(this._container).select<SVGElementTagNameMap['g']>('g');\n }\n /**\n * Callback made by Leaflet when the layer is added to the map\n * @param map Reference to the map to which this layer has been added\n */\n onAdd(map: L.Map): this {\n // Call super.onAdd to properly initialize the SVG pane\n super.onAdd(map)\n\n // Store a reference to the map for later use\n this._map = map;\n this._tooltip?.setLatLng([0, 0]).addTo(map);\n // Redraw on moveend\n map.on('moveend', this.redraw, this);\n // Initial draw\n this.redraw();\n return this\n }\n\n /**\n * Callback made by Leaflet when the layer is removed from the map\n * @param map Reference to the map from which this layer is being removed\n */\n onRemove(map: L.Map): this {\n // Destroy the svg container\n this._destroyContainer();\n // Remove events\n map.off('moveend', this.redraw, this);\n return this\n }\n\n /**\n * Clean up the svg container\n */\n protected _destroyContainer() {\n select(this._container).remove();\n }\n\n /**\n * (Re)draws the hexbins data on the container\n */\n public redraw() {\n const that = this;\n\n if (!that._map) return\n\n // Generate the mapped version of the data\n const data = that._data.map<HexbinData<Data>>((d: Data) => {\n const coord = that._accessor(d)\n const point = that._map.latLngToLayerPoint(coord);\n return { coord: coord, point, data: d };\n });\n\n // Select the hex group for the current zoom level. This has\n // the effect of recreating the group if the zoom level has changed\n const join = this._d3Container.selectAll<SVGGElement, number>('g.hexbin')\n .data<number>([this._map.getZoom()], (d) => d);\n\n // enter\n const enter = join.enter().append('g')\n .attr('class', function (d) { return 'hexbin zoom-' + d; });\n\n // enter + update\n const enterUpdate = enter.merge(join);\n\n // exit\n join.exit().remove();\n\n // add the hexagons to the select\n this._createHexagons(enterUpdate, data);\n\n }\n\n protected _linearlySpace(from: number, to: number, length: number): number[] {\n const step = (to - from) / Math.max(length - 1, 1);\n return Array.from({ length }, (_, i) => from + (i * step));\n }\n\n _createHexagons(g: d3.Selection<SVGGElement, number, SVGGElement, unknown>, data: HexbinData<Data>[]) {\n const thisLayer = this;\n\n // Create the bins using the hexbin layout\n\n // Generate the map bounds (to be used to filter the hexes to what is visible)\n const size = thisLayer._map.getSize();\n const bounds = thisLayer._map.getBounds().pad(thisLayer.options.radius * 2 / Math.max(size.x, size.y));\n\n const bins = thisLayer._hexLayout(data).filter(\n ({ x, y }) => bounds.contains(thisLayer._map.layerPointToLatLng(L.point(x, y)))\n );\n\n // Derive the extents of the data values for each dimension\n const colorExtent = thisLayer._getExtent(bins, thisLayer._fn.colorValue, thisLayer.options.colorScaleExtent);\n const radiusExtent = thisLayer._getExtent(bins, thisLayer._fn.radiusValue, thisLayer.options.radiusScaleExtent);\n const opacityExtent = thisLayer._getExtent(bins, thisLayer._fn.opacityValue, thisLayer.options.opacityScaleExtent);\n\n // Match the domain cardinality to that of the color range, to allow for a polylinear scale\n const colorDomain = this.options.colorDomain\n ?? thisLayer._linearlySpace(\n colorExtent[0],\n colorExtent[1],\n thisLayer._scale.color.range().length\n );\n const radiusDomain = this.options.radiusDomain || radiusExtent;\n\n // Set the scale domains\n thisLayer._scale.color.domain(colorDomain);\n thisLayer._scale.radius.domain(radiusDomain);\n thisLayer._scale.opacity.domain(opacityExtent);\n\n\n /*\n * Join\n * Join the Hexagons to the data\n * Use a deterministic id for tracking bins based on position\n */\n const join = g.selectAll<SVGGElement, HexbinBin<HexbinData<Data>>>('g.hexbin-container')\n .data(bins, ({ x, y }) => `${x}:${y}`);\n\n\n /*\n * Update\n * Set the fill and opacity on a transition\n * opacity is re-applied in case the enter transition was cancelled\n * the path is applied as well to resize the bins\n */\n join.select<SVGPathElement>('path.hexbin-hexagon')\n .transition().duration(thisLayer.options.duration)\n .attr('fill', thisLayer._fn.fill.bind(thisLayer))\n .attr('fill-opacity', (d) => thisLayer._scale.opacity(thisLayer._fn.opacityValue.call(thisLayer, d)))\n .attr('stroke-opacity', (d) => thisLayer._scale.opacity(thisLayer._fn.opacityValue.call(thisLayer, d)))\n .attr('d', (d) => {\n return thisLayer._hexLayout.hexagon(thisLayer._scale.radius(thisLayer._fn.radiusValue.call(thisLayer, d)));\n });\n\n\n /*\n * Enter\n * Establish the path, size, fill, and the initial opacity\n * Transition to the final opacity and size\n */\n const container = join.enter().append('g').attr('class', 'hexbin-container')\n .style('pointer-events', thisLayer.options.pointerEvents);\n\n\n container.on('mouseover', function (this: SVGGElement, d: MouseEvent, i) {\n // Bring container to foreground by re-appending it to the DOM\n select<SVGGElement, HexbinBin<HexbinData<Data>>>(this).raise();\n })\n\n const hexagons = container.append('path').attr('class', 'hexbin-hexagon')\n .attr('transform', ({ x, y }) => `translate(${x},${y})`)\n .attr('d', () => thisLayer._hexLayout.hexagon(thisLayer._scale.radius.range()[0]))\n // .attr('d', (data, length) => thisLayer._hexLayout.hexagon(thisLayer._scale.radius(data.length)))\n .attr('fill', thisLayer._fn.fill.bind(thisLayer))\n .attr('fill-opacity', 0.01)\n .attr('stroke-opacity', 0.01)\n .style('pointer-events', 'all');\n\n hexagons.transition().duration(thisLayer.options.duration)\n .attr('fill-opacity', (d) => thisLayer._scale.opacity(thisLayer._fn.opacityValue.call(thisLayer, d)))\n .attr('stroke-opacity', (d) => thisLayer._scale.opacity(thisLayer._fn.opacityValue.call(thisLayer, d)))\n .attr('d', (d) => thisLayer._hexLayout.hexagon(thisLayer._scale.radius(thisLayer._fn.radiusValue.call(thisLayer, d))))\n .style('pointer-events', 'all');\n\n // Grid\n const gridEnter = container.append('path').attr('class', 'hexbin-grid')\n .attr('transform', ({ x, y }) => `translate(${x},${y})`)\n .attr('d', () => thisLayer._hexLayout.hexagon(thisLayer.options.radius))\n .attr('fill', 'none')\n .attr('stroke', 'none')\n\n\n // Grid enter-update\n hexagons.on('mouseover', function (this: SVGPathElement, ev: MouseEvent, data) {\n if (thisLayer._tooltipOptions?.content) {\n thisLayer._tooltip\n ?.setContent(\n typeof thisLayer._tooltipOptions.content === \"function\"\n ? thisLayer._tooltipOptions.content(data)\n : thisLayer._tooltipOptions.content\n )\n .setLatLng(\n thisLayer._map.layerPointToLatLng(L.point(data.x, data.y))\n )\n .openOn(thisLayer._map);\n }\n thisLayer._hoverHandler.mouseover(this, thisLayer, ev, data);\n thisLayer._dispatch.call('mouseover', this, data, thisLayer, ev);\n this.classList.add('hover')\n })\n .on('mouseout', function (this: SVGPathElement, ev: MouseEvent, data) {\n thisLayer._tooltip?.close()\n thisLayer._hoverHandler.mouseout(this, thisLayer, ev, data);\n thisLayer._dispatch.call('mouseout', this, data, thisLayer, ev);\n this.classList.remove('hover')\n })\n .on('click', function (this, ev: MouseEvent, data) {\n const latLng = thisLayer._map.layerPointToLatLng(L.point(data.x, data.y));\n thisLayer._dispatch.call('click', this, data, latLng, thisLayer, ev);\n ev.stopPropagation()\n });\n\n\n // Exit\n const exit = join.exit();\n\n exit.select('path.hexbin-hexagon')\n .transition().duration(thisLayer.options.duration)\n .attr('fill-opacity', 0)\n .attr('stroke-opacity', 0)\n .attr('d', (d) => thisLayer._hexLayout.hexagon(0));\n\n exit.transition().duration(thisLayer.options.duration).remove();\n\n }\n\n _getExtent(\n bins: HexbinBin<HexbinData<Data>>[],\n valueFn: (d: HexbinBin<HexbinData<Data>>) => number,\n scaleExtent: [number, number | undefined]\n ): [number, number] {\n\n // Determine the extent of the values\n let ext = extent<HexbinBin<HexbinData<Data>>, number>(bins, valueFn.bind(this));\n // If either's null, initialize them to 0\n if (ext[0] === undefined || ext[1] === undefined) {\n ext = [0, 0]\n }\n\n // Now apply the optional clipping of the extent\n if (undefined != scaleExtent[0]) ext[0] = scaleExtent[0];\n if (undefined != scaleExtent[1]) ext[1] = scaleExtent[1];\n\n return ext as [number, number]\n }\n\n // ------------------------------------\n // Public API\n // ------------------------------------\n\n /**\n * Get or set the radius of the hexagon grid cells\n */\n radius(): number;\n radius(v: number): this;\n radius(v?: number): this | number {\n if (v === undefined) return this.options.radius;\n\n this.options.radius = v;\n this._hexLayout.radius(v);\n\n if (null == this.options.radiusRange) {\n this._scale.radius.range([this.options.radius, this.options.radius]).clamp(true);\n }\n\n return this;\n }\n\n\n /**\n * Get or set the opacity of the hexbin layer\n * @param v The opacity value to set. If an array is provided, the first element is the minimum opacity and the second is the maximum.\n */\n opacity(): number | [number, number];\n opacity(v: number | [number, number]): this;\n opacity(v?: number | [number, number]): this | number | [number, number] {\n if (v === undefined) return this.options.opacity\n this.options.opacity = v;\n this._scale.opacity.range(typeof v === 'number' ? [v, v] : v).clamp(true);\n\n return this;\n }\n\n /**\n * Get or set the duration of transition animations\n */\n duration(): number;\n duration(v: number): this;\n duration(v?: number): this | number {\n if (v === undefined) return this.options.duration\n this.options.duration = v\n\n return this;\n }\n\n /**\n * Get or set the color scale domain extent\n * @param v The color scale extent to set. If an array is provided, the first element is the minimum extent and the second is the maximum. This means that for the purpose of color interpolation, the domain will be clipped to this extent, i.e. values below the minimum will be treated as the minimum, and values above the maximum will be treated as the maximum.\n */\n colorScaleExtent(): [number, number | undefined];\n colorScaleExtent(v: [number, number | undefined]): this;\n colorScaleExtent(v?: [number, number | undefined]): this | [number, number | undefined] {\n if (v === undefined) { return this.options.colorScaleExtent; }\n this.options.colorScaleExtent = v;\n\n return this;\n }\n\n /**\n * Get or set the radius scale domain extent\n * @param v The radius scale extent to set. If an array is provided, the first element is the minimum extent and the second is the maximum. This means that for the purpose of radius interpolation, the domain will be clipped to this extent, i.e. values below the minimum will be treated as the minimum, and values above the maximum will be treated as the maximum.\n */\n radiusScaleExtent(): [number, number | undefined];\n radiusScaleExtent(v: [number, number | undefined]): this;\n radiusScaleExtent(v?: [number, number | undefined]): this | [number, number | undefined] {\n if (v === undefined) { return this.options.radiusScaleExtent; }\n this.options.radiusScaleExtent = v;\n\n return this;\n }\n\n /**\n * Get or set the opacity scale domain extent\n * @param v The opacity scale extent to set. If an array is provided, the first element is the minimum extent and the second is the maximum. This means that for the purpose of opacity interpolation, the domain will be clipped to this extent, i.e. values below the minimum will be treated as the minimum, and values above the maximum will be treated as the maximum.\n */\n opacityScaleExtent(): [number, number | undefined];\n opacityScaleExtent(v: [number, number | undefined]): this;\n opacityScaleExtent(v?: [number, number | undefined]): this | [number, number | undefined] {\n if (v === undefined) { return this.options.opacityScaleExtent; }\n this.options.opacityScaleExtent = v;\n\n return this;\n }\n\n\n /**\n * Get or set the color scale range\n * @param v The color range to set. Colors will be interpolated between all provided colors.\n */\n colorRange(): string[];\n colorRange(v: string[]): this;\n colorRange(v?: string[]): this | string[] {\n if (v === undefined) { return this.options.colorRange; }\n this.options.colorRange = v;\n this._scale.color.range(v);\n\n return this;\n }\n\n /**\n * Get or set the radius scale range\n * @param v The min and max radius range to set. If null, the range will be set to the hexagon grid cell radius value.\n */\n radiusRange(): [number, number] | null;\n radiusRange(v: [number, number] | null): this;\n radiusRange(v?: [number, number] | null): this | [number, number] | null {\n if (v === undefined) { return this.options.radiusRange; }\n this.options.radiusRange = v;\n this._scale.radius.range(this.options.radiusRange ?? [this.options.radius, this.options.radius]).clamp(true);\n\n return this;\n }\n\n /**\n * Get or set the color scale domain\n */\n colorScale(): d3.ScaleLinear<string, string>;\n colorScale(v: d3.ScaleLinear<string, string>): this;\n colorScale(v?: d3.ScaleLinear<string, string>) {\n if (v === undefined) return this._scale.color;\n this._scale.color = v;\n return this;\n }\n\n /**\n * Get or set the radius scale domain\n */\n radiusScale(): d3.ScaleLinear<number, number>;\n radiusScale(v: d3.ScaleLinear<number, number>): this;\n radiusScale(v?: d3.ScaleLinear<number, number>): this | d3.ScaleLinear<number, number> {\n if (v === undefined) return this._scale.radius\n this._scale.radius = v;\n return this;\n }\n\n /**\n * Get or set the value mapper for the color scale\n * @param v The value mapper to set. This function should accept an array of hexbin data and return a number to be used for color interpolation.\n * @default the length of the data in the hexbin\n */\n colorValue(): (d: HexbinData<Data>[]) => number;\n colorValue(v: (d: HexbinData<Data>[]) => number): this;\n colorValue(v?: (d: HexbinData<Data>[]) => number) {\n if (v === undefined) { return this._fn.colorValue; }\n this._fn.colorValue = v;\n\n return this;\n }\n\n /**\n * Get or set the value mapper for the radius scale\n * @param v The value mapper to set. This function should return a number for each bin, which will be used to determine the radius of the hexagon.\n * @default the length of the data in the hexbin\n */\n radiusValue(): (d: HexbinData<Data>[]) => number;\n radiusValue(v: (d: HexbinData<Data>[]) => number): this;\n radiusValue(v?: (d: HexbinData<Data>[]) => number) {\n if (v === undefined) { return this._fn.radiusValue; }\n this._fn.radiusValue = v;\n\n return this;\n }\n\n /**\n * Get or set the value mapper for the fill color of the hexbins\n * @param v The value mapper to set. This function should return a string to be used as the fill color for the hexbin.\n * @default a color interpolated from the color scale based on the value returned by the colorValue function\n */\n fill(): (d: HexbinData<Data>[]) => string;\n fill(v: (d: HexbinData<Data>[]) => string): this;\n fill(v?: (d: HexbinData<Data>[]) => string) {\n if (v === undefined) { return this._fn.fill; }\n this._fn.fill = v;\n\n return this;\n }\n\n /**\n * Get or set the data to be binned by the hexbin layer.\n * Triggers a redraw of the hexbins when set.\n * @param v The data to set. This should be an array of data to be binned.\n * @param accessor An optional function to convert the data into a LatLngExpression. If not provided, the data is assumed to be an array of LatLngExpressions.\n */\n data(): Data[];\n data(v: Data extends L.LatLngExpression ? Data[] : never): this;\n data(v: Data[], accessor?: (d: Data) => L.LatLngExpression): this;\n\n // Implementation\n data(v?: Data[] | L.LatLngExpression[], accessor?: (d: Data) => L.LatLngExpression): this | Data[] {\n if (v === undefined) {\n return this._data;\n }\n\n if (!isLatLngExpression(v[0]) && !accessor) {\n console.error(\"Leaflet hexbin: data does not appear to be an array of L.LatLngExpression. You must provide an accessor function to convert the data to L.LatLngExpression\");\n }\n\n this._data = v as Data[] ?? []\n this._accessor = accessor ?? ((d: Data) => d as L.LatLngExpression)\n\n if (!this.options.noRedraw) this.redraw();\n return this;\n }\n\n accessor(): (d: Data) => L.LatLngExpression {\n return this._accessor;\n }\n\n /*\n * Getter for the D3 event dispatcher\n */\n dispatch() { return this._dispatch }\n\n /**\n * Get or set the hover handler for the hexbin layer.\n */\n hoverHandler(): HexbinHoverHandler<Data>;\n hoverHandler(v: HexbinHoverHandler<Data>): this;\n hoverHandler(v?: HexbinHoverHandler<Data>): this | HexbinHoverHandler<Data> {\n if (v === undefined) { return this._hoverHandler; }\n this._hoverHandler = (null != v) ? v : HexbinHoverHandler.none();\n\n if (!this.options.noRedraw) this.redraw();\n\n return this;\n }\n\n /**\n * Get or set the tooltip content and options for the hexbin layer.\n */\n // Cannot overload bindTooltip() with data dependant content\n tooltip(tooltip: TooltipOptions<Data>): this {\n this._tooltipOptions = tooltip;\n if (this._tooltip)\n this._tooltip.options = tooltip.options ?? {};\n else {\n this._tooltip = L.tooltip(tooltip.options)\n }\n return this\n }\n\n /**\n * Get the tooltip instance attached to the hexbin layer\n */\n getTooltip(): L.Tooltip | undefined {\n return this._tooltip\n }\n\n /**\n * Bind a tooltip to the hexbin layer with the provided content and options.\n * Useful to bind an existing tooltip instance to the hexbin layer.\n */\n bindTooltip(content: L.Tooltip | L.Content, options?: L.TooltipOptions): this {\n if (content instanceof L.Tooltip) {\n this._tooltip = content;\n // FIXME: weird bug likely coming from vue-leaflet were tooltip is not properly positioned\n // this._tooltip.options.offset[0] -= 5;\n if (this._map) {\n this._tooltip.setLatLng([0, 0]).addTo(this._map)\n }\n } else {\n this._tooltip = L.tooltip(options).setContent(content);\n }\n return this\n }\n\n /**\n * Unbind the tooltip from the hexbin layer\n */\n unbindTooltip(): this {\n this._tooltip?.remove();\n this._tooltip = undefined;\n return this\n }\n\n /*\n * Returns an array of the points in the path, or nested arrays of points in case of multi-polyline.\n */\n getLatLngs() {\n // Map the data into an array of latLngs using the configured lat/lng accessors\n return this._data.map((d) => {\n return L.latLng(this._accessor(d));\n });\n }\n /*\n * Get path geometry as GeoJSON\n */\n toGeoJSON(): GeoJSON.Feature<GeoJSON.MultiPoint, L.LatLng> {\n return L.GeoJSON.getFeature<L.LatLng, GeoJSON.MultiPoint>(this, {\n type: 'MultiPoint',\n coordinates: L.GeoJSON.latLngsToCoords(this.getLatLngs(), 0)\n });\n }\n}\n\n/**\n * Factory function to instanciate a new hexbin layer\n */\nexport function hexbinLayer<Data = L.LatLngExpression>(options?: HexbinLayerConfig) {\n return new HexbinLayer<Data>(options);\n}\n\n\n"],"names":["HexbinHoverHandler","resizeFill","svg","hexLayer","event","data","d3","d","resizeScale","radiusScale","compound","handlers","none","HexbinHoverHandler$1","isLatLngExpression","L","HexbinLayer","options","val","scaleLinear","dispatch","hexbin","x","y","select","map","_a","that","coord","point","join","enterUpdate","from","to","length","step","_","g","thisLayer","size","bounds","bins","colorExtent","radiusExtent","opacityExtent","colorDomain","radiusDomain","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index.es.js","sources":["../src/HexbinHoverHandler.ts","../src/HexbinLayer.ts"],"sourcesContent":["import * as d3 from 'd3';\nimport type { HexbinData } from './HexbinLayer';\nimport { type HexbinLayer } from './HexbinLayer';\n\n/**\n * Interface for handling hover events on hexbins.\n */\nexport interface HexbinHoverHandler<Data> {\n mouseover(svg: SVGPathElement, hexLayer: HexbinLayer<Data>, event: MouseEvent, data: HexbinData<Data>[]): void;\n mouseout(svg: SVGPathElement, hexLayer: HexbinLayer<Data>, event: MouseEvent, data: HexbinData<Data>[]): void;\n}\n\n/**\n * Built-in hover handlers for hexbins.\n */\nexport namespace HexbinHoverHandler {\n /**\n * Resize the hexbin to fill the hexagon grid cell on hover.\n */\n export function resizeFill(): HexbinHoverHandler<any> {\n return {\n mouseover: function (svg: SVGPathElement, hexLayer: HexbinLayer<any>, event: MouseEvent, data: HexbinData<any>[]) {\n const o = d3.select<HTMLElement | null, HexbinData<any>[]>(svg.parentElement);\n o.select('path.hexbin-hexagon')\n .transition().duration(hexLayer.options.duration)\n .attr('d', function (d) {\n return hexLayer._hexLayout.hexagon(hexLayer.options.radius);\n });\n },\n mouseout: function (svg: SVGPathElement, hexLayer: HexbinLayer<any>, event: MouseEvent, data: HexbinData<any>[]) {\n const o = d3.select<HTMLElement | null, HexbinData<any>[]>(svg.parentElement);\n o.select<SVGPathElement>('path.hexbin-hexagon')\n .transition().duration(hexLayer.options.duration)\n .attr('d', function (d) {\n return hexLayer._hexLayout.hexagon(hexLayer.radiusScale()(hexLayer.radiusValue()(d)));\n });\n }\n };\n\n }\n\n /**\n * Resize the hexbin by a scaling factor applied to the maximum hex radius.\n * Use a scaling factor of 1 to grow/shrink the hexbin to the edge of the cell.\n */\n export function resizeScale(radiusScale: number = 1.5): HexbinHoverHandler<any> {\n\n // return the handler instance\n return {\n mouseover: function (svg, hexLayer, event, data) {\n const o = d3.select<HTMLElement | null, HexbinData<any>[]>(svg.parentElement);\n o.select('path.hexbin-hexagon')\n .transition().duration(hexLayer.options.duration)\n .attr('d', function () {\n return hexLayer._hexLayout.hexagon(hexLayer.radiusScale().range()[1] * (radiusScale));\n });\n },\n mouseout: function (svg, hexLayer, event, data) {\n const o = d3.select<HTMLElement | null, HexbinData<any>[]>(svg.parentElement!);\n o.select('path.hexbin-hexagon')\n .transition().duration(hexLayer.options.duration)\n .attr('d', (d) => {\n return hexLayer._hexLayout.hexagon(hexLayer.radiusScale()(hexLayer.radiusValue()(d)));\n });\n }\n };\n }\n\n /**\n * Compound multiple hover handlers into a single handler.\n */\n export function compound<Data>(handlers: HexbinHoverHandler<Data>[] = [none()]): HexbinHoverHandler<Data> {\n return {\n mouseover: function (svg, hexLayer, event, data) {\n handlers!.forEach((h) => { h.mouseover(svg, hexLayer, event, data); });\n },\n mouseout: function (svg, hexLayer, event, data) {\n handlers!.forEach((h) => { h.mouseout(svg, hexLayer, event, data); });\n }\n };\n }\n\n /**\n * No hover handler.\n * @deprecated Will be removed in future versions\n */\n export function none(): HexbinHoverHandler<any> {\n return {\n mouseover: function () { },\n mouseout: function () { }\n };\n }\n\n}\nexport default HexbinHoverHandler\n","import { scaleLinear, dispatch, select, extent } from 'd3';\nimport { hexbin, type HexbinBin } from 'd3-hexbin';\nimport * as L from 'leaflet';\nimport HexbinHoverHandler from './HexbinHoverHandler';\n\n/**\n * @notExported\n */\nL.SVG\n\n// Need to expose some methods from L.SVG\ndeclare module 'leaflet' {\n interface SVG {\n _initContainer(): void;\n _container: SVGElementTagNameMap['svg']\n }\n}\n\n/**\n * Tooltip definition for the hexbin layer.\n * This can be used to generate a tooltip for each hexbin, if an external tooltip was not provided using bindTooltip()\n */\nexport type TooltipOptions<Data> = {\n options?: L.TooltipOptions,\n content?: L.Content | ((d: HexbinData<Data>[]) => L.Content)\n}\n\n/**\n * Hexbin layer configuration options this can be provided when instantiating a new hexbin layer.\n */\nexport interface HexbinLayerConfig {\n /**\n * Hex grid cell radius in pixels.\n * This value should be a positive number.\n * This radius controls the radius of the hexagons used to bin the data\n * but not necessarily to draw each individual hexbin.\n * @default 12\n */\n radius?: number,\n /**\n * Sets the opacity on the hexbin layer.\n * This value should be a number between 0 and 1.\n * If an array is provided, the first element is the minimum opacity and the second is the maximum.\n * @default 0.6\n */\n opacity?: number | [number, number],\n /**\n * Opacity scale extent: [min, max] domain for opacity interpolation.\n * @default [1, undefined]\n */\n opacityScaleExtent?: [number, number | undefined],\n /**\n * Duration of transition in milliseconds.\n * @default 200\n */\n duration?: number,\n\n /**\n * Color scale extent: [min, max] domain for color interpolation.\n * @default [1, undefined]\n */\n colorScaleExtent?: [number, number | undefined],\n /**\n * This is used to override the default behavior, which is to derive the color domain from the data.\n * Normally, you can tweak the generation of the color domain using the colorScaleExtent option.\n * However, if you want to set a completely custom domain, you can provide it as an array of values with this option.\n * The array of values will be passed directly into the domain of the color scale before rendering.\n * @default null\n */\n colorDomain?: number[] | null\n /**\n * Color range used to fill the hexbins.\n * @default ['#f7fbff', '#08306b']\n */\n colorRange?: string[],\n\n /**\n * Radius scale extent: [min, max] domain for radius interpolation.\n * @default [1, undefined]\n */\n radiusScaleExtent?: [number, number | undefined],\n /**\n * This is used to override the default behavior, which is to derive the radius domain from the data.\n * Normally, you can tweak the generation of the radius domain using the radiusScaleExtent option.\n * However, if you want to set a completely custom domain, you can provide it as an array of values with this option.\n * The array of values will be passed directly into the domain of the radius scale before rendering.\n * @default null\n */\n radiusDomain?: number[] | null\n /**\n * Sets the range of the radius scale used to size the hexbins.\n * @default hex grid cell radius\n */\n radiusRange?: [number, number] | null,\n\n /**\n * You should only modify this config option if you want to change the mouse event behavior on hexbins. This will modify when the events are propagated based on the visibility state and/or part of the hexbin being hovered.\n * @default 'all'\n */\n pointerEvents?: string\n\n /**\n * If true, the layer will not be redrawn after data changes and hover handler binding.\n * @default false\n */\n noRedraw?: boolean\n}\n\n/**\n * Hexbin data attached to each hexagon, once binned.\n */\nexport type HexbinData<Data> = {\n data: Data;\n coord: L.LatLngExpression;\n point: Readonly<L.Point>;\n}\n\n\nfunction isLatLngExpression(d: any): d is L.LatLngExpression {\n return (\n d instanceof L.LatLng ||\n (typeof d === 'object' && \"lat\" in d && \"lng\" in d) ||\n (Array.isArray(d) && d.length === 2 && typeof d[0] === 'number' && typeof d[1] === 'number')\n )\n}\n\nconst debounce = <T extends unknown[]>(\n callback: (...args: T) => void,\n delay: number,\n) => {\n let timeoutTimer: ReturnType<typeof setTimeout>;\n\n return function (...args: T) {\n clearTimeout(timeoutTimer);\n\n timeoutTimer = setTimeout(() => {\n callback(...args);\n }, delay);\n };\n};\n\n\n/**\n * A layer for displaying binned data in a hexagon grid on a Leaflet map.\n * Extends L.SVG to take advantage of built-in zoom animations.\n */\nexport class HexbinLayer<Data = L.LatLngExpression> extends L.SVG {\n /**\n * Default options for the hexbin layer\n */\n options: Required<HexbinLayerConfig> & L.RendererOptions = {\n radius: 12,\n opacity: 0.6,\n duration: 200,\n\n colorScaleExtent: [1, undefined],\n radiusScaleExtent: [1, undefined],\n opacityScaleExtent: [1, undefined],\n colorDomain: null,\n radiusDomain: null,\n colorRange: ['#f7fbff', '#08306b'],\n radiusRange: null,\n\n pointerEvents: 'all',\n noRedraw: false,\n // Handle parent default options\n // ...L.SVG.prototype.options,\n ...L.Renderer.prototype.options,\n ...L.Layer.prototype.options\n }\n\n /**\n * Internal functions to access the data\n */\n protected _fn = {\n colorValue: (d: HexbinData<Data>[]) => d.length,\n radiusValue: (d: HexbinData<Data>[]) => d.length,\n opacityValue: (d: HexbinData<Data>[]) => d.length,\n fill: (d: HexbinData<Data>[]) => {\n const val = this._fn.colorValue(d);\n return (null != val) ? this._scale.color(val) : 'none';\n }\n }\n /**\n * D3 scales used for the hexbin layer\n */\n _scale = {\n color: scaleLinear<string, string>(),\n radius: scaleLinear(),\n opacity: scaleLinear()\n };\n\n // Set up the Dispatcher for managing events and callbacks\n protected _dispatch = dispatch<SVGPathElement>('mouseover', 'mouseout', 'click');\n\n // Set up the default hover handler\n protected _hoverHandler: HexbinHoverHandler<Data> = HexbinHoverHandler.none();\n\n // Create the hex layout\n _hexLayout = hexbin<HexbinData<Data>>()\n .radius(this.options.radius)\n .x(({ point: { x } }) => x)\n .y(({ point: { y } }) => y);\n\n // Initialize the data array to be empty\n protected _data = Array<Data>()\n\n\n declare protected _map: L.Map;\n\n protected _tooltipOptions: TooltipOptions<Data> = {};\n declare protected _tooltip: L.Tooltip | undefined;\n\n // declare _container: SVGElementTagNameMap['svg'];\n\n // declare _container: HTMLElement;\n declare protected _d3Container: d3.Selection<SVGGElement, unknown, null, undefined>;\n\n public constructor(options?: HexbinLayerConfig) {\n super()\n // L.SVG.prototype.initialize.call(this, options);\n this.options = { ...this.options, ...options };\n this._scale.color\n .range(this.options.colorRange)\n .clamp(true);\n\n this._scale.radius\n .range(this.options.radiusRange ?? [this.options.radius, this.options.radius])\n .clamp(true);\n\n this._scale.opacity\n .range(\n typeof this.options.opacity === 'number'\n ? [this.options.opacity, this.options.opacity]\n : this.options.opacity\n ).clamp(true);\n\n };\n\n protected _accessor(d: Data) {\n return d as L.LatLngExpression;\n }\n\n /**\n * Create the SVG container for the hexbins\n * @private\n */\n _initContainer() {\n super._initContainer();\n this._d3Container = select(this._container).select<SVGElementTagNameMap['g']>('g');\n }\n /**\n * Callback made by Leaflet when the layer is added to the map\n * @param map Reference to the map to which this layer has been added\n */\n onAdd(map: L.Map): this {\n // Call super.onAdd to properly initialize the SVG pane\n super.onAdd(map)\n\n // Store a reference to the map for later use\n this._map = map;\n this._tooltip?.setLatLng([0, 0]).addTo(map);\n // Redraw on moveend\n map.on('moveend', debounce(() => this.redraw(), 100));\n // Initial draw\n this.redraw();\n return this\n }\n\n /**\n * Callback made by Leaflet when the layer is removed from the map\n * @param map Reference to the map from which this layer is being removed\n */\n onRemove(map: L.Map): this {\n // Destroy the svg container\n this._destroyContainer();\n // Remove events\n map.off('moveend', this.redraw, this);\n return this\n }\n\n /**\n * Clean up the svg container\n */\n protected _destroyContainer() {\n select(this._container).remove();\n }\n\n /**\n * (Re)draws the hexbins data on the container\n */\n public redraw() {\n const that = this;\n\n if (!that._map) return\n\n // Generate the mapped version of the data\n const data = that._data.map<HexbinData<Data>>((d: Data) => {\n const coord = that._accessor(d)\n const point = that._map.latLngToLayerPoint(coord);\n return { coord: coord, point, data: d };\n });\n\n // Select the hex group for the current zoom level. This has\n // the effect of recreating the group if the zoom level has changed\n const join = this._d3Container.selectAll<SVGGElement, number>('g.hexbin')\n .data<number>([this._map.getZoom()], (d) => d);\n\n // enter\n const enter = join.enter().append('g')\n .attr('class', function (d) { return 'hexbin zoom-' + d; });\n\n // enter + update\n const enterUpdate = enter.merge(join);\n\n // exit\n join.exit().remove();\n\n // add the hexagons to the select\n this._createHexagons(enterUpdate, data);\n\n }\n\n protected _linearlySpace(from: number, to: number, length: number): number[] {\n const step = (to - from) / Math.max(length - 1, 1);\n return Array.from({ length }, (_, i) => from + (i * step));\n }\n\n _createHexagons(g: d3.Selection<SVGGElement, number, SVGGElement, unknown>, data: HexbinData<Data>[]) {\n const thisLayer = this;\n\n // Create the bins using the hexbin layout\n\n // Generate the map bounds (to be used to filter the hexes to what is visible)\n const size = thisLayer._map.getSize();\n const bounds = thisLayer._map.getBounds().pad(thisLayer.options.radius * 2 / Math.max(size.x, size.y));\n\n const bins = thisLayer._hexLayout.radius(this.options.radius)(data).filter(\n ({ x, y }) => bounds.contains(thisLayer._map.layerPointToLatLng(L.point(x, y)))\n );\n\n // Derive the extents of the data values for each dimension\n const colorExtent = thisLayer._getExtent(bins, thisLayer._fn.colorValue, thisLayer.options.colorScaleExtent);\n const radiusExtent = thisLayer._getExtent(bins, thisLayer._fn.radiusValue, thisLayer.options.radiusScaleExtent);\n const opacityExtent = thisLayer._getExtent(bins, thisLayer._fn.opacityValue, thisLayer.options.opacityScaleExtent);\n\n // Match the domain cardinality to that of the color range, to allow for a polylinear scale\n const colorDomain = this.options.colorDomain\n ?? thisLayer._linearlySpace(\n colorExtent[0],\n colorExtent[1],\n thisLayer._scale.color.range().length\n );\n const radiusDomain = this.options.radiusDomain || radiusExtent;\n\n // Set the scale domains\n thisLayer._scale.color.domain(colorDomain);\n thisLayer._scale.radius.domain(radiusDomain);\n thisLayer._scale.opacity.domain(opacityExtent);\n\n\n /*\n * Join\n * Join the Hexagons to the data\n * Use a deterministic id for tracking bins based on position\n */\n const join = g.selectAll<SVGGElement, HexbinBin<HexbinData<Data>>>('g.hexbin-container')\n .data(bins, ({ x, y }) => `${x}:${y}`);\n\n\n /*\n * Update\n * Set the fill and opacity on a transition\n * opacity is re-applied in case the enter transition was cancelled\n * the path is applied as well to resize the bins\n */\n join.select<SVGPathElement>('path.hexbin-hexagon')\n .transition().duration(thisLayer.options.duration)\n .attr('fill', thisLayer._fn.fill.bind(thisLayer))\n .attr('fill-opacity', (d) => thisLayer._scale.opacity(thisLayer._fn.opacityValue.call(thisLayer, d)))\n .attr('stroke-opacity', (d) => thisLayer._scale.opacity(thisLayer._fn.opacityValue.call(thisLayer, d)))\n .attr('d', (d) => {\n return thisLayer._hexLayout.hexagon(thisLayer._scale.radius(thisLayer._fn.radiusValue.call(thisLayer, d)));\n });\n\n\n /*\n * Enter\n * Establish the path, size, fill, and the initial opacity\n * Transition to the final opacity and size\n */\n const container = join.enter().append('g').attr('class', 'hexbin-container')\n .style('pointer-events', thisLayer.options.pointerEvents);\n\n\n container.on('mouseover', function (this: SVGGElement, d: MouseEvent, i) {\n // Bring container to foreground by re-appending it to the DOM\n select<SVGGElement, HexbinBin<HexbinData<Data>>>(this).raise();\n })\n\n const hexagons = container.append('path').attr('class', 'hexbin-hexagon')\n .attr('transform', ({ x, y }) => `translate(${x},${y})`)\n .attr('d', () => thisLayer._hexLayout.hexagon(thisLayer._scale.radius.range()[0]))\n // .attr('d', (data, length) => thisLayer._hexLayout.hexagon(thisLayer._scale.radius(data.length)))\n .attr('fill', thisLayer._fn.fill.bind(thisLayer))\n .attr('fill-opacity', 0.01)\n .attr('stroke-opacity', 0.01)\n .style('pointer-events', 'all');\n\n hexagons.transition().duration(thisLayer.options.duration)\n .attr('fill-opacity', (d) => thisLayer._scale.opacity(thisLayer._fn.opacityValue.call(thisLayer, d)))\n .attr('stroke-opacity', (d) => thisLayer._scale.opacity(thisLayer._fn.opacityValue.call(thisLayer, d)))\n .attr('d', (d) => thisLayer._hexLayout.hexagon(thisLayer._scale.radius(thisLayer._fn.radiusValue.call(thisLayer, d))))\n .style('pointer-events', 'all');\n\n // Grid\n const gridEnter = container.append('path').attr('class', 'hexbin-grid')\n .attr('transform', ({ x, y }) => `translate(${x},${y})`)\n .attr('d', () => thisLayer._hexLayout.hexagon(thisLayer.options.radius))\n .attr('fill', 'none')\n .attr('stroke', 'none')\n\n\n // Grid enter-update\n hexagons.on('mouseover', function (this: SVGPathElement, ev: MouseEvent, data) {\n if (thisLayer._tooltipOptions?.content) {\n thisLayer._tooltip\n ?.setContent(\n typeof thisLayer._tooltipOptions.content === \"function\"\n ? thisLayer._tooltipOptions.content(data)\n : thisLayer._tooltipOptions.content\n )\n .setLatLng(\n thisLayer._map.layerPointToLatLng(L.point(data.x, data.y))\n )\n .openOn(thisLayer._map);\n }\n thisLayer._hoverHandler.mouseover(this, thisLayer, ev, data);\n thisLayer._dispatch.call('mouseover', this, data, thisLayer, ev);\n this.classList.add('hover')\n })\n .on('mouseout', function (this: SVGPathElement, ev: MouseEvent, data) {\n thisLayer._tooltip?.close()\n thisLayer._hoverHandler.mouseout(this, thisLayer, ev, data);\n thisLayer._dispatch.call('mouseout', this, data, thisLayer, ev);\n this.classList.remove('hover')\n })\n .on('click', function (this, ev: MouseEvent, data) {\n const latLng = thisLayer._map.layerPointToLatLng(L.point(data.x, data.y));\n thisLayer._dispatch.call('click', this, data, latLng, thisLayer, ev);\n ev.stopPropagation()\n });\n\n\n // Exit\n const exit = join.exit();\n\n exit.select('path.hexbin-hexagon')\n .transition().duration(thisLayer.options.duration)\n .attr('fill-opacity', 0)\n .attr('stroke-opacity', 0)\n .attr('d', (d) => thisLayer._hexLayout.hexagon(0));\n\n exit.transition().duration(thisLayer.options.duration).remove();\n\n }\n\n _getExtent(\n bins: HexbinBin<HexbinData<Data>>[],\n valueFn: (d: HexbinBin<HexbinData<Data>>) => number,\n scaleExtent: [number, number | undefined]\n ): [number, number] {\n\n // Determine the extent of the values\n let ext = extent<HexbinBin<HexbinData<Data>>, number>(bins, valueFn.bind(this));\n // If either's null, initialize them to 0\n if (ext[0] === undefined || ext[1] === undefined) {\n ext = [0, 0]\n }\n\n // Now apply the optional clipping of the extent\n if (undefined != scaleExtent[0]) ext[0] = scaleExtent[0];\n if (undefined != scaleExtent[1]) ext[1] = scaleExtent[1];\n\n return ext as [number, number]\n }\n\n // ------------------------------------\n // Public API\n // ------------------------------------\n\n /**\n * Get or set the radius of the hexagon grid cells\n */\n radius(): number;\n radius(v: number): this;\n radius(v?: number): this | number {\n if (v === undefined) return this.options.radius;\n\n this.options.radius = v;\n this._hexLayout.radius(v);\n\n if (null == this.options.radiusRange) {\n this._scale.radius.range([this.options.radius, this.options.radius]).clamp(true);\n }\n\n return this;\n }\n\n\n /**\n * Get or set the opacity of the hexbin layer\n * @param v The opacity value to set. If an array is provided, the first element is the minimum opacity and the second is the maximum.\n */\n opacity(): number | [number, number];\n opacity(v: number | [number, number]): this;\n opacity(v?: number | [number, number]): this | number | [number, number] {\n if (v === undefined) return this.options.opacity\n this.options.opacity = v;\n this._scale.opacity.range(typeof v === 'number' ? [v, v] : v).clamp(true);\n\n return this;\n }\n\n /**\n * Get or set the duration of transition animations\n */\n duration(): number;\n duration(v: number): this;\n duration(v?: number): this | number {\n if (v === undefined) return this.options.duration\n this.options.duration = v\n\n return this;\n }\n\n /**\n * Get or set the color scale domain extent\n * @param v The color scale extent to set. If an array is provided, the first element is the minimum extent and the second is the maximum. This means that for the purpose of color interpolation, the domain will be clipped to this extent, i.e. values below the minimum will be treated as the minimum, and values above the maximum will be treated as the maximum.\n */\n colorScaleExtent(): [number, number | undefined];\n colorScaleExtent(v: [number, number | undefined]): this;\n colorScaleExtent(v?: [number, number | undefined]): this | [number, number | undefined] {\n if (v === undefined) { return this.options.colorScaleExtent; }\n this.options.colorScaleExtent = v;\n\n return this;\n }\n\n /**\n * Get or set the radius scale domain extent\n * @param v The radius scale extent to set. If an array is provided, the first element is the minimum extent and the second is the maximum. This means that for the purpose of radius interpolation, the domain will be clipped to this extent, i.e. values below the minimum will be treated as the minimum, and values above the maximum will be treated as the maximum.\n */\n radiusScaleExtent(): [number, number | undefined];\n radiusScaleExtent(v: [number, number | undefined]): this;\n radiusScaleExtent(v?: [number, number | undefined]): this | [number, number | undefined] {\n if (v === undefined) { return this.options.radiusScaleExtent; }\n this.options.radiusScaleExtent = v;\n\n return this;\n }\n\n /**\n * Get or set the opacity scale domain extent\n * @param v The opacity scale extent to set. If an array is provided, the first element is the minimum extent and the second is the maximum. This means that for the purpose of opacity interpolation, the domain will be clipped to this extent, i.e. values below the minimum will be treated as the minimum, and values above the maximum will be treated as the maximum.\n */\n opacityScaleExtent(): [number, number | undefined];\n opacityScaleExtent(v: [number, number | undefined]): this;\n opacityScaleExtent(v?: [number, number | undefined]): this | [number, number | undefined] {\n if (v === undefined) { return this.options.opacityScaleExtent; }\n this.options.opacityScaleExtent = v;\n\n return this;\n }\n\n\n /**\n * Get or set the color scale range\n * @param v The color range to set. Colors will be interpolated between all provided colors.\n */\n colorRange(): string[];\n colorRange(v: string[]): this;\n colorRange(v?: string[]): this | string[] {\n if (v === undefined) { return this.options.colorRange; }\n this.options.colorRange = v;\n this._scale.color.range(v);\n\n return this;\n }\n\n /**\n * Get or set the radius scale range\n * @param v The min and max radius range to set. If null, the range will be set to the hexagon grid cell radius value.\n */\n radiusRange(): [number, number] | null;\n radiusRange(v: [number, number] | null): this;\n radiusRange(v?: [number, number] | null): this | [number, number] | null {\n if (v === undefined) { return this.options.radiusRange; }\n this.options.radiusRange = v;\n this._scale.radius.range(this.options.radiusRange ?? [this.options.radius, this.options.radius]).clamp(true);\n\n return this;\n }\n\n /**\n * Get or set the color scale domain\n */\n colorScale(): d3.ScaleLinear<string, string>;\n colorScale(v: d3.ScaleLinear<string, string>): this;\n colorScale(v?: d3.ScaleLinear<string, string>) {\n if (v === undefined) return this._scale.color;\n this._scale.color = v;\n return this;\n }\n\n /**\n * Get or set the radius scale domain\n */\n radiusScale(): d3.ScaleLinear<number, number>;\n radiusScale(v: d3.ScaleLinear<number, number>): this;\n radiusScale(v?: d3.ScaleLinear<number, number>): this | d3.ScaleLinear<number, number> {\n if (v === undefined) return this._scale.radius\n this._scale.radius = v;\n return this;\n }\n\n /**\n * Get or set the value mapper for the color scale\n * @param v The value mapper to set. This function should accept an array of hexbin data and return a number to be used for color interpolation.\n * @default the length of the data in the hexbin\n */\n colorValue(): (d: HexbinData<Data>[]) => number;\n colorValue(v: (d: HexbinData<Data>[]) => number): this;\n colorValue(v?: (d: HexbinData<Data>[]) => number) {\n if (v === undefined) { return this._fn.colorValue; }\n this._fn.colorValue = v;\n\n return this;\n }\n\n /**\n * Get or set the value mapper for the radius scale\n * @param v The value mapper to set. This function should return a number for each bin, which will be used to determine the radius of the hexagon.\n * @default the length of the data in the hexbin\n */\n radiusValue(): (d: HexbinData<Data>[]) => number;\n radiusValue(v: (d: HexbinData<Data>[]) => number): this;\n radiusValue(v?: (d: HexbinData<Data>[]) => number) {\n if (v === undefined) { return this._fn.radiusValue; }\n this._fn.radiusValue = v;\n\n return this;\n }\n\n /**\n * Get or set the value mapper for the fill color of the hexbins\n * @param v The value mapper to set. This function should return a string to be used as the fill color for the hexbin.\n * @default a color interpolated from the color scale based on the value returned by the colorValue function\n */\n fill(): (d: HexbinData<Data>[]) => string;\n fill(v: (d: HexbinData<Data>[]) => string): this;\n fill(v?: (d: HexbinData<Data>[]) => string) {\n if (v === undefined) { return this._fn.fill; }\n this._fn.fill = v;\n\n return this;\n }\n\n /**\n * Get or set the data to be binned by the hexbin layer.\n * Triggers a redraw of the hexbins when set.\n * @param v The data to set. This should be an array of data to be binned.\n * @param accessor An optional function to convert the data into a LatLngExpression. If not provided, the data is assumed to be an array of LatLngExpressions.\n */\n data(): Data[];\n data(v: Data extends L.LatLngExpression ? Data[] : never): this;\n data(v: Data[], accessor?: (d: Data) => L.LatLngExpression): this;\n\n // Implementation\n data(v?: Data[] | L.LatLngExpression[], accessor?: (d: Data) => L.LatLngExpression): this | Data[] {\n if (v === undefined) {\n return this._data;\n }\n\n if (!isLatLngExpression(v[0]) && !accessor) {\n console.error(\"Leaflet hexbin: data does not appear to be an array of L.LatLngExpression. You must provide an accessor function to convert the data to L.LatLngExpression\");\n }\n\n this._data = v as Data[] ?? []\n this._accessor = accessor ?? ((d: Data) => d as L.LatLngExpression)\n\n if (!this.options.noRedraw) this.redraw();\n return this;\n }\n\n accessor(): (d: Data) => L.LatLngExpression {\n return this._accessor;\n }\n\n /*\n * Getter for the D3 event dispatcher\n */\n dispatch() { return this._dispatch }\n\n /**\n * Get or set the hover handler for the hexbin layer.\n */\n hoverHandler(): HexbinHoverHandler<Data>;\n hoverHandler(v: HexbinHoverHandler<Data>): this;\n hoverHandler(v?: HexbinHoverHandler<Data>): this | HexbinHoverHandler<Data> {\n if (v === undefined) { return this._hoverHandler; }\n this._hoverHandler = (null != v) ? v : HexbinHoverHandler.none();\n\n if (!this.options.noRedraw) this.redraw();\n\n return this;\n }\n\n /**\n * Get or set the tooltip content and options for the hexbin layer.\n */\n // Cannot overload bindTooltip() with data dependant content\n tooltip(tooltip: TooltipOptions<Data>): this {\n this._tooltipOptions = tooltip;\n if (this._tooltip)\n this._tooltip.options = tooltip.options ?? {};\n else {\n this._tooltip = L.tooltip(tooltip.options)\n }\n return this\n }\n\n /**\n * Get the tooltip instance attached to the hexbin layer\n */\n getTooltip(): L.Tooltip | undefined {\n return this._tooltip\n }\n\n /**\n * Bind a tooltip to the hexbin layer with the provided content and options.\n * Useful to bind an existing tooltip instance to the hexbin layer.\n */\n bindTooltip(content: L.Tooltip | L.Content, options?: L.TooltipOptions): this {\n if (content instanceof L.Tooltip) {\n this._tooltip = content;\n // FIXME: weird bug likely coming from vue-leaflet were tooltip is not properly positioned\n // this._tooltip.options.offset[0] -= 5;\n if (this._map) {\n this._tooltip.setLatLng([0, 0]).addTo(this._map)\n }\n } else {\n this._tooltip = L.tooltip(options).setContent(content);\n }\n return this\n }\n\n /**\n * Unbind the tooltip from the hexbin layer\n */\n unbindTooltip(): this {\n this._tooltip?.remove();\n this._tooltip = undefined;\n return this\n }\n\n /*\n * Returns an array of the points in the path, or nested arrays of points in case of multi-polyline.\n */\n getLatLngs() {\n // Map the data into an array of latLngs using the configured lat/lng accessors\n return this._data.map((d) => {\n return L.latLng(this._accessor(d));\n });\n }\n /*\n * Get path geometry as GeoJSON\n */\n toGeoJSON(): GeoJSON.Feature<GeoJSON.MultiPoint, L.LatLng> {\n return L.GeoJSON.getFeature<L.LatLng, GeoJSON.MultiPoint>(this, {\n type: 'MultiPoint',\n coordinates: L.GeoJSON.latLngsToCoords(this.getLatLngs(), 0)\n });\n }\n}\n\n/**\n * Factory function to instanciate a new hexbin layer\n */\nexport function hexbinLayer<Data = L.LatLngExpression>(options?: HexbinLayerConfig) {\n return new HexbinLayer<Data>(options);\n}\n\n\n"],"names":["HexbinHoverHandler","resizeFill","svg","hexLayer","event","data","d3","d","resizeScale","radiusScale","compound","handlers","none","HexbinHoverHandler$1","isLatLngExpression","L","debounce","callback","delay","timeoutTimer","args","HexbinLayer","options","val","scaleLinear","dispatch","hexbin","x","y","select","map","_a","that","coord","point","join","enterUpdate","from","to","length","step","_","i","g","thisLayer","size","bounds","bins","colorExtent","radiusExtent","opacityExtent","colorDomain","radiusDomain","container","hexagons","ev","_b","latLng","exit","valueFn","scaleExtent","ext","extent","v","accessor","tooltip","content","hexbinLayer"],"mappings":";;;;AAeiB,IAAAA;AAAA,CAAV,CAAUA,MAAV;AAIE,WAASC,IAAsC;AAC7C,WAAA;AAAA,MACL,WAAW,SAAUC,GAAqBC,GAA4BC,GAAmBC,GAAyB;AAEhH,QADUC,EAAG,OAA8CJ,EAAI,aAAa,EAC1E,OAAO,qBAAqB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ports=="object"&&typeof module<"u"?c(exports,require("d3"),require("d3-hexbin"),require("leaflet")):typeof define=="function"&&define.amd?define(["exports","d3","d3-hexbin","leaflet"],c):(h=typeof globalThis<"u"?globalThis:h||self,c(h["leaflet-hexbin"]={},h.d3,h["d3-hexbin"],h.L))})(this,function(h,c,T,w){"use strict";function S(s){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const i in s)if(i!=="default"){const o=Object.getOwnPropertyDescriptor(s,i);Object.defineProperty(t,i,o.get?o:{enumerable:!0,get:()=>s[i]})}}return t.default=s,Object.freeze(t)}const y=S(c),u=S(w);var m;(s=>{function t(){return{mouseover:function(p,e,r,d){y.select(p.parentElement).select("path.hexbin-hexagon").transition().duration(e.options.duration).attr("d",function(f){return e._hexLayout.hexagon(e.options.radius)})},mouseout:function(p,e,r,d){y.select(p.parentElement).select("path.hexbin-hexagon").transition().duration(e.options.duration).attr("d",function(f){return e._hexLayout.hexagon(e.radiusScale()(e.radiusValue()(f)))})}}}s.resizeFill=t;function i(p=1.5){return{mouseover:function(e,r,d,_){y.select(e.parentElement).select("path.hexbin-hexagon").transition().duration(r.options.duration).attr("d",function(){return r._hexLayout.hexagon(r.radiusScale().range()[1]*p)})},mouseout:function(e,r,d,_){y.select(e.parentElement).select("path.hexbin-hexagon").transition().duration(r.options.duration).attr("d",L=>r._hexLayout.hexagon(r.radiusScale()(r.radiusValue()(L))))}}}s.resizeScale=i;function o(p=[l()]){return{mouseover:function(e,r,d,_){p.forEach(f=>{f.mouseover(e,r,d,_)})},mouseout:function(e,r,d,_){p.forEach(f=>{f.mouseout(e,r,d,_)})}}}s.compound=o;function l(){return{mouseover:function(){},mouseout:function(){}}}s.none=l})(m||(m={}));const x=m;function H(s){return s instanceof u.LatLng||typeof s=="object"&&"lat"in s&&"lng"in s||Array.isArray(s)&&s.length===2&&typeof s[0]=="number"&&typeof s[1]=="number"}class E extends u.SVG{constructor(t){super(),this.options={radius:12,opacity:.6,duration:200,colorScaleExtent:[1,void 0],radiusScaleExtent:[1,void 0],opacityScaleExtent:[1,void 0],colorDomain:null,radiusDomain:null,colorRange:["#f7fbff","#08306b"],radiusRange:null,pointerEvents:"all",noRedraw:!1,...u.Renderer.prototype.options,...u.Layer.prototype.options},this._fn={colorValue:i=>i.length,radiusValue:i=>i.length,opacityValue:i=>i.length,fill:i=>{const o=this._fn.colorValue(i);return o!=null?this._scale.color(o):"none"}},this._scale={color:c.scaleLinear(),radius:c.scaleLinear(),opacity:c.scaleLinear()},this._dispatch=c.dispatch("mouseover","mouseout","click"),this._hoverHandler=x.none(),this._hexLayout=T.hexbin().radius(this.options.radius).x(({point:{x:i}})=>i).y(({point:{y:i}})=>i),this._data=Array(),this._tooltipOptions={},this.options={...this.options,...t},this._scale.color.range(this.options.colorRange).clamp(!0),this._scale.radius.range(this.options.radiusRange??[this.options.radius,this.options.radius]).clamp(!0),this._scale.opacity.range(typeof this.options.opacity=="number"?[this.options.opacity,this.options.opacity]:this.options.opacity).clamp(!0)}_accessor(t){return t}_initContainer(){super._initContainer(),this._d3Container=c.select(this._container).select("g")}onAdd(t){var i;return super.onAdd(t),this._map=t,(i=this._tooltip)==null||i.setLatLng([0,0]).addTo(t),t.on("moveend",this.redraw,this),this.redraw(),this}onRemove(t){return this._destroyContainer(),t.off("moveend",this.redraw,this),this}_destroyContainer(){c.select(this._container).remove()}redraw(){const t=this;if(!t._map)return;const i=t._data.map(e=>{const r=t._accessor(e),d=t._map.latLngToLayerPoint(r);return{coord:r,point:d,data:e}}),o=this._d3Container.selectAll("g.hexbin").data([this._map.getZoom()],e=>e),p=o.enter().append("g").attr("class",function(e){return"hexbin zoom-"+e}).merge(o);o.exit().remove(),this._createHexagons(p,i)}_linearlySpace(t,i,o){const l=(i-t)/Math.max(o-1,1);return Array.from({length:o},(p,e)=>t+e*l)}_createHexagons(t,i){const o=this,l=o._map.getSize(),p=o._map.getBounds().pad(o.options.radius*2/Math.max(l.x,l.y)),e=o._hexLayout(i).filter(({x:n,y:a})=>p.contains(o._map.layerPointToLatLng(u.point(n,a)))),r=o._getExtent(e,o._fn.colorValue,o.options.colorScaleExtent),d=o._getExtent(e,o._fn.radiusValue,o.options.radiusScaleExtent),_=o._getExtent(e,o._fn.opacityValue,o.options.opacityScaleExtent),f=this.options.colorDomain??o._linearlySpace(r[0],r[1],o._scale.color.range().length),L=this.options.radiusDomain||d;o._scale.color.domain(f),o._scale.radius.domain(L),o._scale.opacity.domain(_);const b=t.selectAll("g.hexbin-container").data(e,({x:n,y:a})=>`${n}:${a}`);b.select("path.hexbin-hexagon").transition().duration(o.options.duration).attr("fill",o._fn.fill.bind(o)).attr("fill-opacity",n=>o._scale.opacity(o._fn.opacityValue.call(o,n))).attr("stroke-opacity",n=>o._scale.opacity(o._fn.opacityValue.call(o,n))).attr("d",n=>o._hexLayout.hexagon(o._scale.radius(o._fn.radiusValue.call(o,n))));const v=b.enter().append("g").attr("class","hexbin-container").style("pointer-events",o.options.pointerEvents);v.on("mouseover",function(n,a){c.select(this).raise()});const V=v.append("path").attr("class","hexbin-hexagon").attr("transform",({x:n,y:a})=>`translate(${n},${a})`).attr("d",()=>o._hexLayout.hexagon(o._scale.radius.range()[0])).attr("fill",o._fn.fill.bind(o)).attr("fill-opacity",.01).attr("stroke-opacity",.01).style("pointer-events","all");V.transition().duration(o.options.duration).attr("fill-opacity",n=>o._scale.opacity(o._fn.opacityValue.call(o,n))).attr("stroke-opacity",n=>o._scale.opacity(o._fn.opacityValue.call(o,n))).attr("d",n=>o._hexLayout.hexagon(o._scale.radius(o._fn.radiusValue.call(o,n)))).style("pointer-events","all"),v.append("path").attr("class","hexbin-grid").attr("transform",({x:n,y:a})=>`translate(${n},${a})`).attr("d",()=>o._hexLayout.hexagon(o.options.radius)).attr("fill","none").attr("stroke","none"),V.on("mouseover",function(n,a){var g,O;(g=o._tooltipOptions)!=null&&g.content&&((O=o._tooltip)==null||O.setContent(typeof o._tooltipOptions.content=="function"?o._tooltipOptions.content(a):o._tooltipOptions.content).setLatLng(o._map.layerPointToLatLng(u.point(a.x,a.y))).openOn(o._map)),o._hoverHandler.mouseover(this,o,n,a),o._dispatch.call("mouseover",this,a,o,n),this.classList.add("hover")}).on("mouseout",function(n,a){var g;(g=o._tooltip)==null||g.close(),o._hoverHandler.mouseout(this,o,n,a),o._dispatch.call("mouseout",this,a,o,n),this.classList.remove("hover")}).on("click",function(n,a){const g=o._map.layerPointToLatLng(u.point(a.x,a.y));o._dispatch.call("click",this,a,g,o,n),n.stopPropagation()});const R=b.exit();R.select("path.hexbin-hexagon").transition().duration(o.options.duration).attr("fill-opacity",0).attr("stroke-opacity",0).attr("d",n=>o._hexLayout.hexagon(0)),R.transition().duration(o.options.duration).remove()}_getExtent(t,i,o){let l=c.extent(t,i.bind(this));return(l[0]===void 0||l[1]===void 0)&&(l=[0,0]),o[0]!=null&&(l[0]=o[0]),o[1]!=null&&(l[1]=o[1]),l}radius(t){return t===void 0?this.options.radius:(this.options.radius=t,this._hexLayout.radius(t),this.options.radiusRange==null&&this._scale.radius.range([this.options.radius,this.options.radius]).clamp(!0),this)}opacity(t){return t===void 0?this.options.opacity:(this.options.opacity=t,this._scale.opacity.range(typeof t=="number"?[t,t]:t).clamp(!0),this)}duration(t){return t===void 0?this.options.duration:(this.options.duration=t,this)}colorScaleExtent(t){return t===void 0?this.options.colorScaleExtent:(this.options.colorScaleExtent=t,this)}radiusScaleExtent(t){return t===void 0?this.options.radiusScaleExtent:(this.options.radiusScaleExtent=t,this)}opacityScaleExtent(t){return t===void 0?this.options.opacityScaleExtent:(this.options.opacityScaleExtent=t,this)}colorRange(t){return t===void 0?this.options.colorRange:(this.options.colorRange=t,this._scale.color.range(t),this)}radiusRange(t){return t===void 0?this.options.radiusRange:(this.options.radiusRange=t,this._scale.radius.range(this.options.radiusRange??[this.options.radius,this.options.radius]).clamp(!0),this)}colorScale(t){return t===void 0?this._scale.color:(this._scale.color=t,this)}radiusScale(t){return t===void 0?this._scale.radius:(this._scale.radius=t,this)}colorValue(t){return t===void 0?this._fn.colorValue:(this._fn.colorValue=t,this)}radiusValue(t){return t===void 0?this._fn.radiusValue:(this._fn.radiusValue=t,this)}fill(t){return t===void 0?this._fn.fill:(this._fn.fill=t,this)}data(t,i){return t===void 0?this._data:(!H(t[0])&&!i&&console.error("Leaflet hexbin: data does not appear to be an array of L.LatLngExpression. You must provide an accessor function to convert the data to L.LatLngExpression"),this._data=t??[],this._accessor=i??(o=>o),this.options.noRedraw||this.redraw(),this)}accessor(){return this._accessor}dispatch(){return this._dispatch}hoverHandler(t){return t===void 0?this._hoverHandler:(this._hoverHandler=t??x.none(),this.options.noRedraw||this.redraw(),this)}tooltip(t){return this._tooltipOptions=t,this._tooltip?this._tooltip.options=t.options??{}:this._tooltip=u.tooltip(t.options),this}getTooltip(){return this._tooltip}bindTooltip(t,i){return t instanceof u.Tooltip?(this._tooltip=t,this._map&&this._tooltip.setLatLng([0,0]).addTo(this._map)):this._tooltip=u.tooltip(i).setContent(t),this}unbindTooltip(){var t;return(t=this._tooltip)==null||t.remove(),this._tooltip=void 0,this}getLatLngs(){return this._data.map(t=>u.latLng(this._accessor(t)))}toGeoJSON(){return u.GeoJSON.getFeature(this,{type:"MultiPoint",coordinates:u.GeoJSON.latLngsToCoords(this.getLatLngs(),0)})}}function j(s){return new E(s)}h.HexbinHoverHandler=x,h.HexbinLayer=E,h.hexbinLayer=j,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
1
+ (function(h,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("d3"),require("d3-hexbin"),require("leaflet")):typeof define=="function"&&define.amd?define(["exports","d3","d3-hexbin","leaflet"],u):(h=typeof globalThis<"u"?globalThis:h||self,u(h["leaflet-hexbin"]={},h.d3,h["d3-hexbin"],h.L))})(this,function(h,u,O,w){"use strict";function S(s){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const i in s)if(i!=="default"){const o=Object.getOwnPropertyDescriptor(s,i);Object.defineProperty(t,i,o.get?o:{enumerable:!0,get:()=>s[i]})}}return t.default=s,Object.freeze(t)}const m=S(u),c=S(w);var y;(s=>{function t(){return{mouseover:function(p,e,r,d){m.select(p.parentElement).select("path.hexbin-hexagon").transition().duration(e.options.duration).attr("d",function(f){return e._hexLayout.hexagon(e.options.radius)})},mouseout:function(p,e,r,d){m.select(p.parentElement).select("path.hexbin-hexagon").transition().duration(e.options.duration).attr("d",function(f){return e._hexLayout.hexagon(e.radiusScale()(e.radiusValue()(f)))})}}}s.resizeFill=t;function i(p=1.5){return{mouseover:function(e,r,d,_){m.select(e.parentElement).select("path.hexbin-hexagon").transition().duration(r.options.duration).attr("d",function(){return r._hexLayout.hexagon(r.radiusScale().range()[1]*p)})},mouseout:function(e,r,d,_){m.select(e.parentElement).select("path.hexbin-hexagon").transition().duration(r.options.duration).attr("d",L=>r._hexLayout.hexagon(r.radiusScale()(r.radiusValue()(L))))}}}s.resizeScale=i;function o(p=[l()]){return{mouseover:function(e,r,d,_){p.forEach(f=>{f.mouseover(e,r,d,_)})},mouseout:function(e,r,d,_){p.forEach(f=>{f.mouseout(e,r,d,_)})}}}s.compound=o;function l(){return{mouseover:function(){},mouseout:function(){}}}s.none=l})(y||(y={}));const x=y;function H(s){return s instanceof c.LatLng||typeof s=="object"&&"lat"in s&&"lng"in s||Array.isArray(s)&&s.length===2&&typeof s[0]=="number"&&typeof s[1]=="number"}const j=(s,t)=>{let i;return function(...o){clearTimeout(i),i=setTimeout(()=>{s(...o)},t)}};class E extends c.SVG{constructor(t){super(),this.options={radius:12,opacity:.6,duration:200,colorScaleExtent:[1,void 0],radiusScaleExtent:[1,void 0],opacityScaleExtent:[1,void 0],colorDomain:null,radiusDomain:null,colorRange:["#f7fbff","#08306b"],radiusRange:null,pointerEvents:"all",noRedraw:!1,...c.Renderer.prototype.options,...c.Layer.prototype.options},this._fn={colorValue:i=>i.length,radiusValue:i=>i.length,opacityValue:i=>i.length,fill:i=>{const o=this._fn.colorValue(i);return o!=null?this._scale.color(o):"none"}},this._scale={color:u.scaleLinear(),radius:u.scaleLinear(),opacity:u.scaleLinear()},this._dispatch=u.dispatch("mouseover","mouseout","click"),this._hoverHandler=x.none(),this._hexLayout=O.hexbin().radius(this.options.radius).x(({point:{x:i}})=>i).y(({point:{y:i}})=>i),this._data=Array(),this._tooltipOptions={},this.options={...this.options,...t},this._scale.color.range(this.options.colorRange).clamp(!0),this._scale.radius.range(this.options.radiusRange??[this.options.radius,this.options.radius]).clamp(!0),this._scale.opacity.range(typeof this.options.opacity=="number"?[this.options.opacity,this.options.opacity]:this.options.opacity).clamp(!0)}_accessor(t){return t}_initContainer(){super._initContainer(),this._d3Container=u.select(this._container).select("g")}onAdd(t){var i;return super.onAdd(t),this._map=t,(i=this._tooltip)==null||i.setLatLng([0,0]).addTo(t),t.on("moveend",j(()=>this.redraw(),100)),this.redraw(),this}onRemove(t){return this._destroyContainer(),t.off("moveend",this.redraw,this),this}_destroyContainer(){u.select(this._container).remove()}redraw(){const t=this;if(!t._map)return;const i=t._data.map(e=>{const r=t._accessor(e),d=t._map.latLngToLayerPoint(r);return{coord:r,point:d,data:e}}),o=this._d3Container.selectAll("g.hexbin").data([this._map.getZoom()],e=>e),p=o.enter().append("g").attr("class",function(e){return"hexbin zoom-"+e}).merge(o);o.exit().remove(),this._createHexagons(p,i)}_linearlySpace(t,i,o){const l=(i-t)/Math.max(o-1,1);return Array.from({length:o},(p,e)=>t+e*l)}_createHexagons(t,i){const o=this,l=o._map.getSize(),p=o._map.getBounds().pad(o.options.radius*2/Math.max(l.x,l.y)),e=o._hexLayout.radius(this.options.radius)(i).filter(({x:n,y:a})=>p.contains(o._map.layerPointToLatLng(c.point(n,a)))),r=o._getExtent(e,o._fn.colorValue,o.options.colorScaleExtent),d=o._getExtent(e,o._fn.radiusValue,o.options.radiusScaleExtent),_=o._getExtent(e,o._fn.opacityValue,o.options.opacityScaleExtent),f=this.options.colorDomain??o._linearlySpace(r[0],r[1],o._scale.color.range().length),L=this.options.radiusDomain||d;o._scale.color.domain(f),o._scale.radius.domain(L),o._scale.opacity.domain(_);const b=t.selectAll("g.hexbin-container").data(e,({x:n,y:a})=>`${n}:${a}`);b.select("path.hexbin-hexagon").transition().duration(o.options.duration).attr("fill",o._fn.fill.bind(o)).attr("fill-opacity",n=>o._scale.opacity(o._fn.opacityValue.call(o,n))).attr("stroke-opacity",n=>o._scale.opacity(o._fn.opacityValue.call(o,n))).attr("d",n=>o._hexLayout.hexagon(o._scale.radius(o._fn.radiusValue.call(o,n))));const v=b.enter().append("g").attr("class","hexbin-container").style("pointer-events",o.options.pointerEvents);v.on("mouseover",function(n,a){u.select(this).raise()});const V=v.append("path").attr("class","hexbin-hexagon").attr("transform",({x:n,y:a})=>`translate(${n},${a})`).attr("d",()=>o._hexLayout.hexagon(o._scale.radius.range()[0])).attr("fill",o._fn.fill.bind(o)).attr("fill-opacity",.01).attr("stroke-opacity",.01).style("pointer-events","all");V.transition().duration(o.options.duration).attr("fill-opacity",n=>o._scale.opacity(o._fn.opacityValue.call(o,n))).attr("stroke-opacity",n=>o._scale.opacity(o._fn.opacityValue.call(o,n))).attr("d",n=>o._hexLayout.hexagon(o._scale.radius(o._fn.radiusValue.call(o,n)))).style("pointer-events","all"),v.append("path").attr("class","hexbin-grid").attr("transform",({x:n,y:a})=>`translate(${n},${a})`).attr("d",()=>o._hexLayout.hexagon(o.options.radius)).attr("fill","none").attr("stroke","none"),V.on("mouseover",function(n,a){var g,R;(g=o._tooltipOptions)!=null&&g.content&&((R=o._tooltip)==null||R.setContent(typeof o._tooltipOptions.content=="function"?o._tooltipOptions.content(a):o._tooltipOptions.content).setLatLng(o._map.layerPointToLatLng(c.point(a.x,a.y))).openOn(o._map)),o._hoverHandler.mouseover(this,o,n,a),o._dispatch.call("mouseover",this,a,o,n),this.classList.add("hover")}).on("mouseout",function(n,a){var g;(g=o._tooltip)==null||g.close(),o._hoverHandler.mouseout(this,o,n,a),o._dispatch.call("mouseout",this,a,o,n),this.classList.remove("hover")}).on("click",function(n,a){const g=o._map.layerPointToLatLng(c.point(a.x,a.y));o._dispatch.call("click",this,a,g,o,n),n.stopPropagation()});const T=b.exit();T.select("path.hexbin-hexagon").transition().duration(o.options.duration).attr("fill-opacity",0).attr("stroke-opacity",0).attr("d",n=>o._hexLayout.hexagon(0)),T.transition().duration(o.options.duration).remove()}_getExtent(t,i,o){let l=u.extent(t,i.bind(this));return(l[0]===void 0||l[1]===void 0)&&(l=[0,0]),o[0]!=null&&(l[0]=o[0]),o[1]!=null&&(l[1]=o[1]),l}radius(t){return t===void 0?this.options.radius:(this.options.radius=t,this._hexLayout.radius(t),this.options.radiusRange==null&&this._scale.radius.range([this.options.radius,this.options.radius]).clamp(!0),this)}opacity(t){return t===void 0?this.options.opacity:(this.options.opacity=t,this._scale.opacity.range(typeof t=="number"?[t,t]:t).clamp(!0),this)}duration(t){return t===void 0?this.options.duration:(this.options.duration=t,this)}colorScaleExtent(t){return t===void 0?this.options.colorScaleExtent:(this.options.colorScaleExtent=t,this)}radiusScaleExtent(t){return t===void 0?this.options.radiusScaleExtent:(this.options.radiusScaleExtent=t,this)}opacityScaleExtent(t){return t===void 0?this.options.opacityScaleExtent:(this.options.opacityScaleExtent=t,this)}colorRange(t){return t===void 0?this.options.colorRange:(this.options.colorRange=t,this._scale.color.range(t),this)}radiusRange(t){return t===void 0?this.options.radiusRange:(this.options.radiusRange=t,this._scale.radius.range(this.options.radiusRange??[this.options.radius,this.options.radius]).clamp(!0),this)}colorScale(t){return t===void 0?this._scale.color:(this._scale.color=t,this)}radiusScale(t){return t===void 0?this._scale.radius:(this._scale.radius=t,this)}colorValue(t){return t===void 0?this._fn.colorValue:(this._fn.colorValue=t,this)}radiusValue(t){return t===void 0?this._fn.radiusValue:(this._fn.radiusValue=t,this)}fill(t){return t===void 0?this._fn.fill:(this._fn.fill=t,this)}data(t,i){return t===void 0?this._data:(!H(t[0])&&!i&&console.error("Leaflet hexbin: data does not appear to be an array of L.LatLngExpression. You must provide an accessor function to convert the data to L.LatLngExpression"),this._data=t??[],this._accessor=i??(o=>o),this.options.noRedraw||this.redraw(),this)}accessor(){return this._accessor}dispatch(){return this._dispatch}hoverHandler(t){return t===void 0?this._hoverHandler:(this._hoverHandler=t??x.none(),this.options.noRedraw||this.redraw(),this)}tooltip(t){return this._tooltipOptions=t,this._tooltip?this._tooltip.options=t.options??{}:this._tooltip=c.tooltip(t.options),this}getTooltip(){return this._tooltip}bindTooltip(t,i){return t instanceof c.Tooltip?(this._tooltip=t,this._map&&this._tooltip.setLatLng([0,0]).addTo(this._map)):this._tooltip=c.tooltip(i).setContent(t),this}unbindTooltip(){var t;return(t=this._tooltip)==null||t.remove(),this._tooltip=void 0,this}getLatLngs(){return this._data.map(t=>c.latLng(this._accessor(t)))}toGeoJSON(){return c.GeoJSON.getFeature(this,{type:"MultiPoint",coordinates:c.GeoJSON.latLngsToCoords(this.getLatLngs(),0)})}}function k(s){return new E(s)}h.HexbinHoverHandler=x,h.HexbinLayer=E,h.hexbinLayer=k,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});
2
2
  //# sourceMappingURL=index.umd.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.umd.js","sources":["../src/HexbinHoverHandler.ts","../src/HexbinLayer.ts"],"sourcesContent":["import * as d3 from 'd3';\nimport type { HexbinData } from './HexbinLayer';\nimport { type HexbinLayer } from './HexbinLayer';\n\n/**\n * Interface for handling hover events on hexbins.\n */\nexport interface HexbinHoverHandler<Data> {\n mouseover(svg: SVGPathElement, hexLayer: HexbinLayer<Data>, event: MouseEvent, data: HexbinData<Data>[]): void;\n mouseout(svg: SVGPathElement, hexLayer: HexbinLayer<Data>, event: MouseEvent, data: HexbinData<Data>[]): void;\n}\n\n/**\n * Built-in hover handlers for hexbins.\n */\nexport namespace HexbinHoverHandler {\n /**\n * Resize the hexbin to fill the hexagon grid cell on hover.\n */\n export function resizeFill(): HexbinHoverHandler<any> {\n return {\n mouseover: function (svg: SVGPathElement, hexLayer: HexbinLayer<any>, event: MouseEvent, data: HexbinData<any>[]) {\n const o = d3.select<HTMLElement | null, HexbinData<any>[]>(svg.parentElement);\n o.select('path.hexbin-hexagon')\n .transition().duration(hexLayer.options.duration)\n .attr('d', function (d) {\n return hexLayer._hexLayout.hexagon(hexLayer.options.radius);\n });\n },\n mouseout: function (svg: SVGPathElement, hexLayer: HexbinLayer<any>, event: MouseEvent, data: HexbinData<any>[]) {\n const o = d3.select<HTMLElement | null, HexbinData<any>[]>(svg.parentElement);\n o.select<SVGPathElement>('path.hexbin-hexagon')\n .transition().duration(hexLayer.options.duration)\n .attr('d', function (d) {\n return hexLayer._hexLayout.hexagon(hexLayer.radiusScale()(hexLayer.radiusValue()(d)));\n });\n }\n };\n\n }\n\n /**\n * Resize the hexbin by a scaling factor on hover.\n */\n export function resizeScale(radiusScale: number = 1.5): HexbinHoverHandler<any> {\n\n // return the handler instance\n return {\n mouseover: function (svg, hexLayer, event, data) {\n const o = d3.select<HTMLElement | null, HexbinData<any>[]>(svg.parentElement);\n o.select('path.hexbin-hexagon')\n .transition().duration(hexLayer.options.duration)\n .attr('d', function () {\n return hexLayer._hexLayout.hexagon(hexLayer.radiusScale().range()[1] * (radiusScale));\n });\n },\n mouseout: function (svg, hexLayer, event, data) {\n const o = d3.select<HTMLElement | null, HexbinData<any>[]>(svg.parentElement!);\n o.select('path.hexbin-hexagon')\n .transition().duration(hexLayer.options.duration)\n .attr('d', (d) => {\n return hexLayer._hexLayout.hexagon(hexLayer.radiusScale()(hexLayer.radiusValue()(d)));\n });\n }\n };\n }\n\n /**\n * Compound multiple hover handlers into a single handler.\n */\n export function compound<Data>(handlers: HexbinHoverHandler<Data>[] = [none()]): HexbinHoverHandler<Data> {\n return {\n mouseover: function (svg, hexLayer, event, data) {\n handlers!.forEach((h) => { h.mouseover(svg, hexLayer, event, data); });\n },\n mouseout: function (svg, hexLayer, event, data) {\n handlers!.forEach((h) => { h.mouseout(svg, hexLayer, event, data); });\n }\n };\n }\n\n /**\n * No hover handler.\n * @deprecated Will be removed in future versions\n */\n export function none(): HexbinHoverHandler<any> {\n return {\n mouseover: function () { },\n mouseout: function () { }\n };\n }\n\n}\nexport default HexbinHoverHandler\n","import { scaleLinear, dispatch, select, extent } from 'd3';\nimport { hexbin, type HexbinBin } from 'd3-hexbin';\nimport * as L from 'leaflet';\nimport HexbinHoverHandler from './HexbinHoverHandler';\n\n/**\n * @notExported\n */\nL.SVG\n\n// Need to expose some methods from L.SVG\ndeclare module 'leaflet' {\n interface SVG {\n _initContainer(): void;\n _container: SVGElementTagNameMap['svg']\n }\n}\n\n/**\n * Tooltip definition for the hexbin layer.\n * This can be used to generate a tooltip for each hexbin, if an external tooltip was not provided using bindTooltip()\n */\nexport type TooltipOptions<Data> = {\n options?: L.TooltipOptions,\n content?: L.Content | ((d: HexbinData<Data>[]) => L.Content)\n}\n\n/**\n * Hexbin layer configuration options this can be provided when instantiating a new hexbin layer.\n */\nexport interface HexbinLayerConfig {\n /**\n * Hex grid cell radius in pixels.\n * This value should be a positive number.\n * This radius controls the radius of the hexagons used to bin the data\n * but not necessarily to draw each individual hexbin.\n * @default 12\n */\n radius?: number,\n /**\n * Sets the opacity on the hexbin layer.\n * This value should be a number between 0 and 1.\n * If an array is provided, the first element is the minimum opacity and the second is the maximum.\n * @default 0.6\n */\n opacity?: number | [number, number],\n /**\n * Opacity scale extent: [min, max] domain for opacity interpolation.\n * @default [1, undefined]\n */\n opacityScaleExtent?: [number, number | undefined],\n /**\n * Duration of transition in milliseconds.\n * @default 200\n */\n duration?: number,\n\n /**\n * Color scale extent: [min, max] domain for color interpolation.\n * @default [1, undefined]\n */\n colorScaleExtent?: [number, number | undefined],\n /**\n * This is used to override the default behavior, which is to derive the color domain from the data.\n * Normally, you can tweak the generation of the color domain using the colorScaleExtent option.\n * However, if you want to set a completely custom domain, you can provide it as an array of values with this option.\n * The array of values will be passed directly into the domain of the color scale before rendering.\n * @default null\n */\n colorDomain?: number[] | null\n /**\n * Color range used to fill the hexbins.\n * @default ['#f7fbff', '#08306b']\n */\n colorRange?: string[],\n\n /**\n * Radius scale extent: [min, max] domain for radius interpolation.\n * @default [1, undefined]\n */\n radiusScaleExtent?: [number, number | undefined],\n /**\n * This is used to override the default behavior, which is to derive the radius domain from the data.\n * Normally, you can tweak the generation of the radius domain using the radiusScaleExtent option.\n * However, if you want to set a completely custom domain, you can provide it as an array of values with this option.\n * The array of values will be passed directly into the domain of the radius scale before rendering.\n * @default null\n */\n radiusDomain?: number[] | null\n /**\n * Sets the range of the radius scale used to size the hexbins.\n * @default hex grid cell radius\n */\n radiusRange?: [number, number] | null,\n\n /**\n * You should only modify this config option if you want to change the mouse event behavior on hexbins. This will modify when the events are propagated based on the visibility state and/or part of the hexbin being hovered.\n * @default 'all'\n */\n pointerEvents?: string\n\n /**\n * If true, the layer will not be redrawn after data changes and hover handler binding.\n * @default false\n */\n noRedraw?: boolean\n}\n\n/**\n * Hexbin data attached to each hexagon, once binned.\n */\nexport type HexbinData<Data> = {\n data: Data;\n coord: L.LatLngExpression;\n point: Readonly<L.Point>;\n}\n\n\nfunction isLatLngExpression(d: any): d is L.LatLngExpression {\n return (\n d instanceof L.LatLng ||\n (typeof d === 'object' && \"lat\" in d && \"lng\" in d) ||\n (Array.isArray(d) && d.length === 2 && typeof d[0] === 'number' && typeof d[1] === 'number')\n )\n}\n\n/**\n * A layer for displaying binned data in a hexagon grid on a Leaflet map.\n * Extends L.SVG to take advantage of built-in zoom animations.\n */\nexport class HexbinLayer<Data = L.LatLngExpression> extends L.SVG {\n /**\n * Default options for the hexbin layer\n */\n options: Required<HexbinLayerConfig> & L.RendererOptions = {\n radius: 12,\n opacity: 0.6,\n duration: 200,\n\n colorScaleExtent: [1, undefined],\n radiusScaleExtent: [1, undefined],\n opacityScaleExtent: [1, undefined],\n colorDomain: null,\n radiusDomain: null,\n colorRange: ['#f7fbff', '#08306b'],\n radiusRange: null,\n\n pointerEvents: 'all',\n noRedraw: false,\n // Handle parent default options\n // ...L.SVG.prototype.options,\n ...L.Renderer.prototype.options,\n ...L.Layer.prototype.options\n }\n\n /**\n * Internal functions to access the data\n */\n protected _fn = {\n colorValue: (d: HexbinData<Data>[]) => d.length,\n radiusValue: (d: HexbinData<Data>[]) => d.length,\n opacityValue: (d: HexbinData<Data>[]) => d.length,\n fill: (d: HexbinData<Data>[]) => {\n const val = this._fn.colorValue(d);\n return (null != val) ? this._scale.color(val) : 'none';\n }\n }\n /**\n * D3 scales used for the hexbin layer\n */\n _scale = {\n color: scaleLinear<string, string>(),\n radius: scaleLinear(),\n opacity: scaleLinear()\n };\n\n // Set up the Dispatcher for managing events and callbacks\n protected _dispatch = dispatch<SVGPathElement>('mouseover', 'mouseout', 'click');\n\n // Set up the default hover handler\n protected _hoverHandler: HexbinHoverHandler<Data> = HexbinHoverHandler.none();\n\n // Create the hex layout\n _hexLayout = hexbin<HexbinData<Data>>()\n .radius(this.options.radius)\n .x(({ point: { x } }) => x)\n .y(({ point: { y } }) => y);\n\n // Initialize the data array to be empty\n protected _data = Array<Data>()\n\n\n declare protected _map: L.Map;\n\n protected _tooltipOptions: TooltipOptions<Data> = {};\n declare protected _tooltip: L.Tooltip | undefined;\n\n // declare _container: SVGElementTagNameMap['svg'];\n\n // declare _container: HTMLElement;\n declare protected _d3Container: d3.Selection<SVGGElement, unknown, null, undefined>;\n\n public constructor(options?: HexbinLayerConfig) {\n super()\n // L.SVG.prototype.initialize.call(this, options);\n this.options = { ...this.options, ...options };\n this._scale.color\n .range(this.options.colorRange)\n .clamp(true);\n\n this._scale.radius\n .range(this.options.radiusRange ?? [this.options.radius, this.options.radius])\n .clamp(true);\n\n this._scale.opacity\n .range(\n typeof this.options.opacity === 'number'\n ? [this.options.opacity, this.options.opacity]\n : this.options.opacity\n ).clamp(true);\n\n };\n\n protected _accessor(d: Data) {\n return d as L.LatLngExpression;\n }\n\n /**\n * Create the SVG container for the hexbins\n * @private\n */\n _initContainer() {\n super._initContainer();\n this._d3Container = select(this._container).select<SVGElementTagNameMap['g']>('g');\n }\n /**\n * Callback made by Leaflet when the layer is added to the map\n * @param map Reference to the map to which this layer has been added\n */\n onAdd(map: L.Map): this {\n // Call super.onAdd to properly initialize the SVG pane\n super.onAdd(map)\n\n // Store a reference to the map for later use\n this._map = map;\n this._tooltip?.setLatLng([0, 0]).addTo(map);\n // Redraw on moveend\n map.on('moveend', this.redraw, this);\n // Initial draw\n this.redraw();\n return this\n }\n\n /**\n * Callback made by Leaflet when the layer is removed from the map\n * @param map Reference to the map from which this layer is being removed\n */\n onRemove(map: L.Map): this {\n // Destroy the svg container\n this._destroyContainer();\n // Remove events\n map.off('moveend', this.redraw, this);\n return this\n }\n\n /**\n * Clean up the svg container\n */\n protected _destroyContainer() {\n select(this._container).remove();\n }\n\n /**\n * (Re)draws the hexbins data on the container\n */\n public redraw() {\n const that = this;\n\n if (!that._map) return\n\n // Generate the mapped version of the data\n const data = that._data.map<HexbinData<Data>>((d: Data) => {\n const coord = that._accessor(d)\n const point = that._map.latLngToLayerPoint(coord);\n return { coord: coord, point, data: d };\n });\n\n // Select the hex group for the current zoom level. This has\n // the effect of recreating the group if the zoom level has changed\n const join = this._d3Container.selectAll<SVGGElement, number>('g.hexbin')\n .data<number>([this._map.getZoom()], (d) => d);\n\n // enter\n const enter = join.enter().append('g')\n .attr('class', function (d) { return 'hexbin zoom-' + d; });\n\n // enter + update\n const enterUpdate = enter.merge(join);\n\n // exit\n join.exit().remove();\n\n // add the hexagons to the select\n this._createHexagons(enterUpdate, data);\n\n }\n\n protected _linearlySpace(from: number, to: number, length: number): number[] {\n const step = (to - from) / Math.max(length - 1, 1);\n return Array.from({ length }, (_, i) => from + (i * step));\n }\n\n _createHexagons(g: d3.Selection<SVGGElement, number, SVGGElement, unknown>, data: HexbinData<Data>[]) {\n const thisLayer = this;\n\n // Create the bins using the hexbin layout\n\n // Generate the map bounds (to be used to filter the hexes to what is visible)\n const size = thisLayer._map.getSize();\n const bounds = thisLayer._map.getBounds().pad(thisLayer.options.radius * 2 / Math.max(size.x, size.y));\n\n const bins = thisLayer._hexLayout(data).filter(\n ({ x, y }) => bounds.contains(thisLayer._map.layerPointToLatLng(L.point(x, y)))\n );\n\n // Derive the extents of the data values for each dimension\n const colorExtent = thisLayer._getExtent(bins, thisLayer._fn.colorValue, thisLayer.options.colorScaleExtent);\n const radiusExtent = thisLayer._getExtent(bins, thisLayer._fn.radiusValue, thisLayer.options.radiusScaleExtent);\n const opacityExtent = thisLayer._getExtent(bins, thisLayer._fn.opacityValue, thisLayer.options.opacityScaleExtent);\n\n // Match the domain cardinality to that of the color range, to allow for a polylinear scale\n const colorDomain = this.options.colorDomain\n ?? thisLayer._linearlySpace(\n colorExtent[0],\n colorExtent[1],\n thisLayer._scale.color.range().length\n );\n const radiusDomain = this.options.radiusDomain || radiusExtent;\n\n // Set the scale domains\n thisLayer._scale.color.domain(colorDomain);\n thisLayer._scale.radius.domain(radiusDomain);\n thisLayer._scale.opacity.domain(opacityExtent);\n\n\n /*\n * Join\n * Join the Hexagons to the data\n * Use a deterministic id for tracking bins based on position\n */\n const join = g.selectAll<SVGGElement, HexbinBin<HexbinData<Data>>>('g.hexbin-container')\n .data(bins, ({ x, y }) => `${x}:${y}`);\n\n\n /*\n * Update\n * Set the fill and opacity on a transition\n * opacity is re-applied in case the enter transition was cancelled\n * the path is applied as well to resize the bins\n */\n join.select<SVGPathElement>('path.hexbin-hexagon')\n .transition().duration(thisLayer.options.duration)\n .attr('fill', thisLayer._fn.fill.bind(thisLayer))\n .attr('fill-opacity', (d) => thisLayer._scale.opacity(thisLayer._fn.opacityValue.call(thisLayer, d)))\n .attr('stroke-opacity', (d) => thisLayer._scale.opacity(thisLayer._fn.opacityValue.call(thisLayer, d)))\n .attr('d', (d) => {\n return thisLayer._hexLayout.hexagon(thisLayer._scale.radius(thisLayer._fn.radiusValue.call(thisLayer, d)));\n });\n\n\n /*\n * Enter\n * Establish the path, size, fill, and the initial opacity\n * Transition to the final opacity and size\n */\n const container = join.enter().append('g').attr('class', 'hexbin-container')\n .style('pointer-events', thisLayer.options.pointerEvents);\n\n\n container.on('mouseover', function (this: SVGGElement, d: MouseEvent, i) {\n // Bring container to foreground by re-appending it to the DOM\n select<SVGGElement, HexbinBin<HexbinData<Data>>>(this).raise();\n })\n\n const hexagons = container.append('path').attr('class', 'hexbin-hexagon')\n .attr('transform', ({ x, y }) => `translate(${x},${y})`)\n .attr('d', () => thisLayer._hexLayout.hexagon(thisLayer._scale.radius.range()[0]))\n // .attr('d', (data, length) => thisLayer._hexLayout.hexagon(thisLayer._scale.radius(data.length)))\n .attr('fill', thisLayer._fn.fill.bind(thisLayer))\n .attr('fill-opacity', 0.01)\n .attr('stroke-opacity', 0.01)\n .style('pointer-events', 'all');\n\n hexagons.transition().duration(thisLayer.options.duration)\n .attr('fill-opacity', (d) => thisLayer._scale.opacity(thisLayer._fn.opacityValue.call(thisLayer, d)))\n .attr('stroke-opacity', (d) => thisLayer._scale.opacity(thisLayer._fn.opacityValue.call(thisLayer, d)))\n .attr('d', (d) => thisLayer._hexLayout.hexagon(thisLayer._scale.radius(thisLayer._fn.radiusValue.call(thisLayer, d))))\n .style('pointer-events', 'all');\n\n // Grid\n const gridEnter = container.append('path').attr('class', 'hexbin-grid')\n .attr('transform', ({ x, y }) => `translate(${x},${y})`)\n .attr('d', () => thisLayer._hexLayout.hexagon(thisLayer.options.radius))\n .attr('fill', 'none')\n .attr('stroke', 'none')\n\n\n // Grid enter-update\n hexagons.on('mouseover', function (this: SVGPathElement, ev: MouseEvent, data) {\n if (thisLayer._tooltipOptions?.content) {\n thisLayer._tooltip\n ?.setContent(\n typeof thisLayer._tooltipOptions.content === \"function\"\n ? thisLayer._tooltipOptions.content(data)\n : thisLayer._tooltipOptions.content\n )\n .setLatLng(\n thisLayer._map.layerPointToLatLng(L.point(data.x, data.y))\n )\n .openOn(thisLayer._map);\n }\n thisLayer._hoverHandler.mouseover(this, thisLayer, ev, data);\n thisLayer._dispatch.call('mouseover', this, data, thisLayer, ev);\n this.classList.add('hover')\n })\n .on('mouseout', function (this: SVGPathElement, ev: MouseEvent, data) {\n thisLayer._tooltip?.close()\n thisLayer._hoverHandler.mouseout(this, thisLayer, ev, data);\n thisLayer._dispatch.call('mouseout', this, data, thisLayer, ev);\n this.classList.remove('hover')\n })\n .on('click', function (this, ev: MouseEvent, data) {\n const latLng = thisLayer._map.layerPointToLatLng(L.point(data.x, data.y));\n thisLayer._dispatch.call('click', this, data, latLng, thisLayer, ev);\n ev.stopPropagation()\n });\n\n\n // Exit\n const exit = join.exit();\n\n exit.select('path.hexbin-hexagon')\n .transition().duration(thisLayer.options.duration)\n .attr('fill-opacity', 0)\n .attr('stroke-opacity', 0)\n .attr('d', (d) => thisLayer._hexLayout.hexagon(0));\n\n exit.transition().duration(thisLayer.options.duration).remove();\n\n }\n\n _getExtent(\n bins: HexbinBin<HexbinData<Data>>[],\n valueFn: (d: HexbinBin<HexbinData<Data>>) => number,\n scaleExtent: [number, number | undefined]\n ): [number, number] {\n\n // Determine the extent of the values\n let ext = extent<HexbinBin<HexbinData<Data>>, number>(bins, valueFn.bind(this));\n // If either's null, initialize them to 0\n if (ext[0] === undefined || ext[1] === undefined) {\n ext = [0, 0]\n }\n\n // Now apply the optional clipping of the extent\n if (undefined != scaleExtent[0]) ext[0] = scaleExtent[0];\n if (undefined != scaleExtent[1]) ext[1] = scaleExtent[1];\n\n return ext as [number, number]\n }\n\n // ------------------------------------\n // Public API\n // ------------------------------------\n\n /**\n * Get or set the radius of the hexagon grid cells\n */\n radius(): number;\n radius(v: number): this;\n radius(v?: number): this | number {\n if (v === undefined) return this.options.radius;\n\n this.options.radius = v;\n this._hexLayout.radius(v);\n\n if (null == this.options.radiusRange) {\n this._scale.radius.range([this.options.radius, this.options.radius]).clamp(true);\n }\n\n return this;\n }\n\n\n /**\n * Get or set the opacity of the hexbin layer\n * @param v The opacity value to set. If an array is provided, the first element is the minimum opacity and the second is the maximum.\n */\n opacity(): number | [number, number];\n opacity(v: number | [number, number]): this;\n opacity(v?: number | [number, number]): this | number | [number, number] {\n if (v === undefined) return this.options.opacity\n this.options.opacity = v;\n this._scale.opacity.range(typeof v === 'number' ? [v, v] : v).clamp(true);\n\n return this;\n }\n\n /**\n * Get or set the duration of transition animations\n */\n duration(): number;\n duration(v: number): this;\n duration(v?: number): this | number {\n if (v === undefined) return this.options.duration\n this.options.duration = v\n\n return this;\n }\n\n /**\n * Get or set the color scale domain extent\n * @param v The color scale extent to set. If an array is provided, the first element is the minimum extent and the second is the maximum. This means that for the purpose of color interpolation, the domain will be clipped to this extent, i.e. values below the minimum will be treated as the minimum, and values above the maximum will be treated as the maximum.\n */\n colorScaleExtent(): [number, number | undefined];\n colorScaleExtent(v: [number, number | undefined]): this;\n colorScaleExtent(v?: [number, number | undefined]): this | [number, number | undefined] {\n if (v === undefined) { return this.options.colorScaleExtent; }\n this.options.colorScaleExtent = v;\n\n return this;\n }\n\n /**\n * Get or set the radius scale domain extent\n * @param v The radius scale extent to set. If an array is provided, the first element is the minimum extent and the second is the maximum. This means that for the purpose of radius interpolation, the domain will be clipped to this extent, i.e. values below the minimum will be treated as the minimum, and values above the maximum will be treated as the maximum.\n */\n radiusScaleExtent(): [number, number | undefined];\n radiusScaleExtent(v: [number, number | undefined]): this;\n radiusScaleExtent(v?: [number, number | undefined]): this | [number, number | undefined] {\n if (v === undefined) { return this.options.radiusScaleExtent; }\n this.options.radiusScaleExtent = v;\n\n return this;\n }\n\n /**\n * Get or set the opacity scale domain extent\n * @param v The opacity scale extent to set. If an array is provided, the first element is the minimum extent and the second is the maximum. This means that for the purpose of opacity interpolation, the domain will be clipped to this extent, i.e. values below the minimum will be treated as the minimum, and values above the maximum will be treated as the maximum.\n */\n opacityScaleExtent(): [number, number | undefined];\n opacityScaleExtent(v: [number, number | undefined]): this;\n opacityScaleExtent(v?: [number, number | undefined]): this | [number, number | undefined] {\n if (v === undefined) { return this.options.opacityScaleExtent; }\n this.options.opacityScaleExtent = v;\n\n return this;\n }\n\n\n /**\n * Get or set the color scale range\n * @param v The color range to set. Colors will be interpolated between all provided colors.\n */\n colorRange(): string[];\n colorRange(v: string[]): this;\n colorRange(v?: string[]): this | string[] {\n if (v === undefined) { return this.options.colorRange; }\n this.options.colorRange = v;\n this._scale.color.range(v);\n\n return this;\n }\n\n /**\n * Get or set the radius scale range\n * @param v The min and max radius range to set. If null, the range will be set to the hexagon grid cell radius value.\n */\n radiusRange(): [number, number] | null;\n radiusRange(v: [number, number] | null): this;\n radiusRange(v?: [number, number] | null): this | [number, number] | null {\n if (v === undefined) { return this.options.radiusRange; }\n this.options.radiusRange = v;\n this._scale.radius.range(this.options.radiusRange ?? [this.options.radius, this.options.radius]).clamp(true);\n\n return this;\n }\n\n /**\n * Get or set the color scale domain\n */\n colorScale(): d3.ScaleLinear<string, string>;\n colorScale(v: d3.ScaleLinear<string, string>): this;\n colorScale(v?: d3.ScaleLinear<string, string>) {\n if (v === undefined) return this._scale.color;\n this._scale.color = v;\n return this;\n }\n\n /**\n * Get or set the radius scale domain\n */\n radiusScale(): d3.ScaleLinear<number, number>;\n radiusScale(v: d3.ScaleLinear<number, number>): this;\n radiusScale(v?: d3.ScaleLinear<number, number>): this | d3.ScaleLinear<number, number> {\n if (v === undefined) return this._scale.radius\n this._scale.radius = v;\n return this;\n }\n\n /**\n * Get or set the value mapper for the color scale\n * @param v The value mapper to set. This function should accept an array of hexbin data and return a number to be used for color interpolation.\n * @default the length of the data in the hexbin\n */\n colorValue(): (d: HexbinData<Data>[]) => number;\n colorValue(v: (d: HexbinData<Data>[]) => number): this;\n colorValue(v?: (d: HexbinData<Data>[]) => number) {\n if (v === undefined) { return this._fn.colorValue; }\n this._fn.colorValue = v;\n\n return this;\n }\n\n /**\n * Get or set the value mapper for the radius scale\n * @param v The value mapper to set. This function should return a number for each bin, which will be used to determine the radius of the hexagon.\n * @default the length of the data in the hexbin\n */\n radiusValue(): (d: HexbinData<Data>[]) => number;\n radiusValue(v: (d: HexbinData<Data>[]) => number): this;\n radiusValue(v?: (d: HexbinData<Data>[]) => number) {\n if (v === undefined) { return this._fn.radiusValue; }\n this._fn.radiusValue = v;\n\n return this;\n }\n\n /**\n * Get or set the value mapper for the fill color of the hexbins\n * @param v The value mapper to set. This function should return a string to be used as the fill color for the hexbin.\n * @default a color interpolated from the color scale based on the value returned by the colorValue function\n */\n fill(): (d: HexbinData<Data>[]) => string;\n fill(v: (d: HexbinData<Data>[]) => string): this;\n fill(v?: (d: HexbinData<Data>[]) => string) {\n if (v === undefined) { return this._fn.fill; }\n this._fn.fill = v;\n\n return this;\n }\n\n /**\n * Get or set the data to be binned by the hexbin layer.\n * Triggers a redraw of the hexbins when set.\n * @param v The data to set. This should be an array of data to be binned.\n * @param accessor An optional function to convert the data into a LatLngExpression. If not provided, the data is assumed to be an array of LatLngExpressions.\n */\n data(): Data[];\n data(v: Data extends L.LatLngExpression ? Data[] : never): this;\n data(v: Data[], accessor?: (d: Data) => L.LatLngExpression): this;\n\n // Implementation\n data(v?: Data[] | L.LatLngExpression[], accessor?: (d: Data) => L.LatLngExpression): this | Data[] {\n if (v === undefined) {\n return this._data;\n }\n\n if (!isLatLngExpression(v[0]) && !accessor) {\n console.error(\"Leaflet hexbin: data does not appear to be an array of L.LatLngExpression. You must provide an accessor function to convert the data to L.LatLngExpression\");\n }\n\n this._data = v as Data[] ?? []\n this._accessor = accessor ?? ((d: Data) => d as L.LatLngExpression)\n\n if (!this.options.noRedraw) this.redraw();\n return this;\n }\n\n accessor(): (d: Data) => L.LatLngExpression {\n return this._accessor;\n }\n\n /*\n * Getter for the D3 event dispatcher\n */\n dispatch() { return this._dispatch }\n\n /**\n * Get or set the hover handler for the hexbin layer.\n */\n hoverHandler(): HexbinHoverHandler<Data>;\n hoverHandler(v: HexbinHoverHandler<Data>): this;\n hoverHandler(v?: HexbinHoverHandler<Data>): this | HexbinHoverHandler<Data> {\n if (v === undefined) { return this._hoverHandler; }\n this._hoverHandler = (null != v) ? v : HexbinHoverHandler.none();\n\n if (!this.options.noRedraw) this.redraw();\n\n return this;\n }\n\n /**\n * Get or set the tooltip content and options for the hexbin layer.\n */\n // Cannot overload bindTooltip() with data dependant content\n tooltip(tooltip: TooltipOptions<Data>): this {\n this._tooltipOptions = tooltip;\n if (this._tooltip)\n this._tooltip.options = tooltip.options ?? {};\n else {\n this._tooltip = L.tooltip(tooltip.options)\n }\n return this\n }\n\n /**\n * Get the tooltip instance attached to the hexbin layer\n */\n getTooltip(): L.Tooltip | undefined {\n return this._tooltip\n }\n\n /**\n * Bind a tooltip to the hexbin layer with the provided content and options.\n * Useful to bind an existing tooltip instance to the hexbin layer.\n */\n bindTooltip(content: L.Tooltip | L.Content, options?: L.TooltipOptions): this {\n if (content instanceof L.Tooltip) {\n this._tooltip = content;\n // FIXME: weird bug likely coming from vue-leaflet were tooltip is not properly positioned\n // this._tooltip.options.offset[0] -= 5;\n if (this._map) {\n this._tooltip.setLatLng([0, 0]).addTo(this._map)\n }\n } else {\n this._tooltip = L.tooltip(options).setContent(content);\n }\n return this\n }\n\n /**\n * Unbind the tooltip from the hexbin layer\n */\n unbindTooltip(): this {\n this._tooltip?.remove();\n this._tooltip = undefined;\n return this\n }\n\n /*\n * Returns an array of the points in the path, or nested arrays of points in case of multi-polyline.\n */\n getLatLngs() {\n // Map the data into an array of latLngs using the configured lat/lng accessors\n return this._data.map((d) => {\n return L.latLng(this._accessor(d));\n });\n }\n /*\n * Get path geometry as GeoJSON\n */\n toGeoJSON(): GeoJSON.Feature<GeoJSON.MultiPoint, L.LatLng> {\n return L.GeoJSON.getFeature<L.LatLng, GeoJSON.MultiPoint>(this, {\n type: 'MultiPoint',\n coordinates: L.GeoJSON.latLngsToCoords(this.getLatLngs(), 0)\n });\n }\n}\n\n/**\n * Factory function to instanciate a new hexbin layer\n */\nexport function hexbinLayer<Data = L.LatLngExpression>(options?: HexbinLayerConfig) {\n return new HexbinLayer<Data>(options);\n}\n\n\n"],"names":["HexbinHoverHandler","resizeFill","svg","hexLayer","event","data","d3","d","resizeScale","radiusScale","compound","handlers","none","h","HexbinHoverHandler$1","isLatLngExpression","L","HexbinLayer","options","val","scaleLinear","dispatch","hexbin","x","y","select","map","_a","that","coord","point","join","enterUpdate","from","to","length","step","_","i","g","thisLayer","size","bounds","bins","colorExtent","radiusExtent","opacityExtent","colorDomain","radiusDomain","container","hexagons","ev","_b","latLng","exit","valueFn","scaleExtent","ext","extent","v","accessor","tooltip","content","hexbinLayer"],"mappings":"ynBAeiB,IAAAA,GAAAA,GAAV,CAIE,SAASC,GAAsC,CAC7C,MAAA,CACL,UAAW,SAAUC,EAAqBC,EAA4BC,EAAmBC,EAAyB,CACtGC,EAAG,OAA8CJ,EAAI,aAAa,EAC1E,OAAO,qBAAqB,EAC3B,WAAa,EAAA,SAASC,EAAS,QAAQ,QAAQ,EAC/C,KAAK,IAAK,SAAUI,EAAG,CACtB,OAAOJ,EAAS,WAAW,QAAQA,EAAS,QAAQ,MAAM,CAAA,CAC3D,CACL,EACA,SAAU,SAAUD,EAAqBC,EAA4BC,EAAmBC,EAAyB,CACrGC,EAAG,OAA8CJ,EAAI,aAAa,EAC1E,OAAuB,qBAAqB,EAC3C,WAAa,EAAA,SAASC,EAAS,QAAQ,QAAQ,EAC/C,KAAK,IAAK,SAAUI,EAAG,CACf,OAAAJ,EAAS,WAAW,QAAQA,EAAS,cAAcA,EAAS,YAAY,EAAEI,CAAC,CAAC,CAAC,CAAA,CACrF,CAAA,CAEP,CAAA,CAlBKP,EAAS,WAAAC,EAyBA,SAAAO,EAAYC,EAAsB,IAA8B,CAGvE,MAAA,CACL,UAAW,SAAUP,EAAKC,EAAUC,EAAOC,EAAM,CACrCC,EAAG,OAA8CJ,EAAI,aAAa,EAC1E,OAAO,qBAAqB,EAC3B,WAAA,EAAa,SAASC,EAAS,QAAQ,QAAQ,EAC/C,KAAK,IAAK,UAAY,CACd,OAAAA,EAAS,WAAW,QAAQA,EAAS,cAAc,MAAM,EAAE,CAAC,EAAKM,CAAY,CAAA,CACrF,CACL,EACA,SAAU,SAAUP,EAAKC,EAAUC,EAAOC,E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OAAA,IAAID,EAAkBC,CAAO,CACtC"}
1
+ {"version":3,"file":"index.umd.js","sources":["../src/HexbinHoverHandler.ts","../src/HexbinLayer.ts"],"sourcesContent":["import * as d3 from 'd3';\nimport type { HexbinData } from './HexbinLayer';\nimport { type HexbinLayer } from './HexbinLayer';\n\n/**\n * Interface for handling hover events on hexbins.\n */\nexport interface HexbinHoverHandler<Data> {\n mouseover(svg: SVGPathElement, hexLayer: HexbinLayer<Data>, event: MouseEvent, data: HexbinData<Data>[]): void;\n mouseout(svg: SVGPathElement, hexLayer: HexbinLayer<Data>, event: MouseEvent, data: HexbinData<Data>[]): void;\n}\n\n/**\n * Built-in hover handlers for hexbins.\n */\nexport namespace HexbinHoverHandler {\n /**\n * Resize the hexbin to fill the hexagon grid cell on hover.\n */\n export function resizeFill(): HexbinHoverHandler<any> {\n return {\n mouseover: function (svg: SVGPathElement, hexLayer: HexbinLayer<any>, event: MouseEvent, data: HexbinData<any>[]) {\n const o = d3.select<HTMLElement | null, HexbinData<any>[]>(svg.parentElement);\n o.select('path.hexbin-hexagon')\n .transition().duration(hexLayer.options.duration)\n .attr('d', function (d) {\n return hexLayer._hexLayout.hexagon(hexLayer.options.radius);\n });\n },\n mouseout: function (svg: SVGPathElement, hexLayer: HexbinLayer<any>, event: MouseEvent, data: HexbinData<any>[]) {\n const o = d3.select<HTMLElement | null, HexbinData<any>[]>(svg.parentElement);\n o.select<SVGPathElement>('path.hexbin-hexagon')\n .transition().duration(hexLayer.options.duration)\n .attr('d', function (d) {\n return hexLayer._hexLayout.hexagon(hexLayer.radiusScale()(hexLayer.radiusValue()(d)));\n });\n }\n };\n\n }\n\n /**\n * Resize the hexbin by a scaling factor applied to the maximum hex radius.\n * Use a scaling factor of 1 to grow/shrink the hexbin to the edge of the cell.\n */\n export function resizeScale(radiusScale: number = 1.5): HexbinHoverHandler<any> {\n\n // return the handler instance\n return {\n mouseover: function (svg, hexLayer, event, data) {\n const o = d3.select<HTMLElement | null, HexbinData<any>[]>(svg.parentElement);\n o.select('path.hexbin-hexagon')\n .transition().duration(hexLayer.options.duration)\n .attr('d', function () {\n return hexLayer._hexLayout.hexagon(hexLayer.radiusScale().range()[1] * (radiusScale));\n });\n },\n mouseout: function (svg, hexLayer, event, data) {\n const o = d3.select<HTMLElement | null, HexbinData<any>[]>(svg.parentElement!);\n o.select('path.hexbin-hexagon')\n .transition().duration(hexLayer.options.duration)\n .attr('d', (d) => {\n return hexLayer._hexLayout.hexagon(hexLayer.radiusScale()(hexLayer.radiusValue()(d)));\n });\n }\n };\n }\n\n /**\n * Compound multiple hover handlers into a single handler.\n */\n export function compound<Data>(handlers: HexbinHoverHandler<Data>[] = [none()]): HexbinHoverHandler<Data> {\n return {\n mouseover: function (svg, hexLayer, event, data) {\n handlers!.forEach((h) => { h.mouseover(svg, hexLayer, event, data); });\n },\n mouseout: function (svg, hexLayer, event, data) {\n handlers!.forEach((h) => { h.mouseout(svg, hexLayer, event, data); });\n }\n };\n }\n\n /**\n * No hover handler.\n * @deprecated Will be removed in future versions\n */\n export function none(): HexbinHoverHandler<any> {\n return {\n mouseover: function () { },\n mouseout: function () { }\n };\n }\n\n}\nexport default HexbinHoverHandler\n","import { scaleLinear, dispatch, select, extent } from 'd3';\nimport { hexbin, type HexbinBin } from 'd3-hexbin';\nimport * as L from 'leaflet';\nimport HexbinHoverHandler from './HexbinHoverHandler';\n\n/**\n * @notExported\n */\nL.SVG\n\n// Need to expose some methods from L.SVG\ndeclare module 'leaflet' {\n interface SVG {\n _initContainer(): void;\n _container: SVGElementTagNameMap['svg']\n }\n}\n\n/**\n * Tooltip definition for the hexbin layer.\n * This can be used to generate a tooltip for each hexbin, if an external tooltip was not provided using bindTooltip()\n */\nexport type TooltipOptions<Data> = {\n options?: L.TooltipOptions,\n content?: L.Content | ((d: HexbinData<Data>[]) => L.Content)\n}\n\n/**\n * Hexbin layer configuration options this can be provided when instantiating a new hexbin layer.\n */\nexport interface HexbinLayerConfig {\n /**\n * Hex grid cell radius in pixels.\n * This value should be a positive number.\n * This radius controls the radius of the hexagons used to bin the data\n * but not necessarily to draw each individual hexbin.\n * @default 12\n */\n radius?: number,\n /**\n * Sets the opacity on the hexbin layer.\n * This value should be a number between 0 and 1.\n * If an array is provided, the first element is the minimum opacity and the second is the maximum.\n * @default 0.6\n */\n opacity?: number | [number, number],\n /**\n * Opacity scale extent: [min, max] domain for opacity interpolation.\n * @default [1, undefined]\n */\n opacityScaleExtent?: [number, number | undefined],\n /**\n * Duration of transition in milliseconds.\n * @default 200\n */\n duration?: number,\n\n /**\n * Color scale extent: [min, max] domain for color interpolation.\n * @default [1, undefined]\n */\n colorScaleExtent?: [number, number | undefined],\n /**\n * This is used to override the default behavior, which is to derive the color domain from the data.\n * Normally, you can tweak the generation of the color domain using the colorScaleExtent option.\n * However, if you want to set a completely custom domain, you can provide it as an array of values with this option.\n * The array of values will be passed directly into the domain of the color scale before rendering.\n * @default null\n */\n colorDomain?: number[] | null\n /**\n * Color range used to fill the hexbins.\n * @default ['#f7fbff', '#08306b']\n */\n colorRange?: string[],\n\n /**\n * Radius scale extent: [min, max] domain for radius interpolation.\n * @default [1, undefined]\n */\n radiusScaleExtent?: [number, number | undefined],\n /**\n * This is used to override the default behavior, which is to derive the radius domain from the data.\n * Normally, you can tweak the generation of the radius domain using the radiusScaleExtent option.\n * However, if you want to set a completely custom domain, you can provide it as an array of values with this option.\n * The array of values will be passed directly into the domain of the radius scale before rendering.\n * @default null\n */\n radiusDomain?: number[] | null\n /**\n * Sets the range of the radius scale used to size the hexbins.\n * @default hex grid cell radius\n */\n radiusRange?: [number, number] | null,\n\n /**\n * You should only modify this config option if you want to change the mouse event behavior on hexbins. This will modify when the events are propagated based on the visibility state and/or part of the hexbin being hovered.\n * @default 'all'\n */\n pointerEvents?: string\n\n /**\n * If true, the layer will not be redrawn after data changes and hover handler binding.\n * @default false\n */\n noRedraw?: boolean\n}\n\n/**\n * Hexbin data attached to each hexagon, once binned.\n */\nexport type HexbinData<Data> = {\n data: Data;\n coord: L.LatLngExpression;\n point: Readonly<L.Point>;\n}\n\n\nfunction isLatLngExpression(d: any): d is L.LatLngExpression {\n return (\n d instanceof L.LatLng ||\n (typeof d === 'object' && \"lat\" in d && \"lng\" in d) ||\n (Array.isArray(d) && d.length === 2 && typeof d[0] === 'number' && typeof d[1] === 'number')\n )\n}\n\nconst debounce = <T extends unknown[]>(\n callback: (...args: T) => void,\n delay: number,\n) => {\n let timeoutTimer: ReturnType<typeof setTimeout>;\n\n return function (...args: T) {\n clearTimeout(timeoutTimer);\n\n timeoutTimer = setTimeout(() => {\n callback(...args);\n }, delay);\n };\n};\n\n\n/**\n * A layer for displaying binned data in a hexagon grid on a Leaflet map.\n * Extends L.SVG to take advantage of built-in zoom animations.\n */\nexport class HexbinLayer<Data = L.LatLngExpression> extends L.SVG {\n /**\n * Default options for the hexbin layer\n */\n options: Required<HexbinLayerConfig> & L.RendererOptions = {\n radius: 12,\n opacity: 0.6,\n duration: 200,\n\n colorScaleExtent: [1, undefined],\n radiusScaleExtent: [1, undefined],\n opacityScaleExtent: [1, undefined],\n colorDomain: null,\n radiusDomain: null,\n colorRange: ['#f7fbff', '#08306b'],\n radiusRange: null,\n\n pointerEvents: 'all',\n noRedraw: false,\n // Handle parent default options\n // ...L.SVG.prototype.options,\n ...L.Renderer.prototype.options,\n ...L.Layer.prototype.options\n }\n\n /**\n * Internal functions to access the data\n */\n protected _fn = {\n colorValue: (d: HexbinData<Data>[]) => d.length,\n radiusValue: (d: HexbinData<Data>[]) => d.length,\n opacityValue: (d: HexbinData<Data>[]) => d.length,\n fill: (d: HexbinData<Data>[]) => {\n const val = this._fn.colorValue(d);\n return (null != val) ? this._scale.color(val) : 'none';\n }\n }\n /**\n * D3 scales used for the hexbin layer\n */\n _scale = {\n color: scaleLinear<string, string>(),\n radius: scaleLinear(),\n opacity: scaleLinear()\n };\n\n // Set up the Dispatcher for managing events and callbacks\n protected _dispatch = dispatch<SVGPathElement>('mouseover', 'mouseout', 'click');\n\n // Set up the default hover handler\n protected _hoverHandler: HexbinHoverHandler<Data> = HexbinHoverHandler.none();\n\n // Create the hex layout\n _hexLayout = hexbin<HexbinData<Data>>()\n .radius(this.options.radius)\n .x(({ point: { x } }) => x)\n .y(({ point: { y } }) => y);\n\n // Initialize the data array to be empty\n protected _data = Array<Data>()\n\n\n declare protected _map: L.Map;\n\n protected _tooltipOptions: TooltipOptions<Data> = {};\n declare protected _tooltip: L.Tooltip | undefined;\n\n // declare _container: SVGElementTagNameMap['svg'];\n\n // declare _container: HTMLElement;\n declare protected _d3Container: d3.Selection<SVGGElement, unknown, null, undefined>;\n\n public constructor(options?: HexbinLayerConfig) {\n super()\n // L.SVG.prototype.initialize.call(this, options);\n this.options = { ...this.options, ...options };\n this._scale.color\n .range(this.options.colorRange)\n .clamp(true);\n\n this._scale.radius\n .range(this.options.radiusRange ?? [this.options.radius, this.options.radius])\n .clamp(true);\n\n this._scale.opacity\n .range(\n typeof this.options.opacity === 'number'\n ? [this.options.opacity, this.options.opacity]\n : this.options.opacity\n ).clamp(true);\n\n };\n\n protected _accessor(d: Data) {\n return d as L.LatLngExpression;\n }\n\n /**\n * Create the SVG container for the hexbins\n * @private\n */\n _initContainer() {\n super._initContainer();\n this._d3Container = select(this._container).select<SVGElementTagNameMap['g']>('g');\n }\n /**\n * Callback made by Leaflet when the layer is added to the map\n * @param map Reference to the map to which this layer has been added\n */\n onAdd(map: L.Map): this {\n // Call super.onAdd to properly initialize the SVG pane\n super.onAdd(map)\n\n // Store a reference to the map for later use\n this._map = map;\n this._tooltip?.setLatLng([0, 0]).addTo(map);\n // Redraw on moveend\n map.on('moveend', debounce(() => this.redraw(), 100));\n // Initial draw\n this.redraw();\n return this\n }\n\n /**\n * Callback made by Leaflet when the layer is removed from the map\n * @param map Reference to the map from which this layer is being removed\n */\n onRemove(map: L.Map): this {\n // Destroy the svg container\n this._destroyContainer();\n // Remove events\n map.off('moveend', this.redraw, this);\n return this\n }\n\n /**\n * Clean up the svg container\n */\n protected _destroyContainer() {\n select(this._container).remove();\n }\n\n /**\n * (Re)draws the hexbins data on the container\n */\n public redraw() {\n const that = this;\n\n if (!that._map) return\n\n // Generate the mapped version of the data\n const data = that._data.map<HexbinData<Data>>((d: Data) => {\n const coord = that._accessor(d)\n const point = that._map.latLngToLayerPoint(coord);\n return { coord: coord, point, data: d };\n });\n\n // Select the hex group for the current zoom level. This has\n // the effect of recreating the group if the zoom level has changed\n const join = this._d3Container.selectAll<SVGGElement, number>('g.hexbin')\n .data<number>([this._map.getZoom()], (d) => d);\n\n // enter\n const enter = join.enter().append('g')\n .attr('class', function (d) { return 'hexbin zoom-' + d; });\n\n // enter + update\n const enterUpdate = enter.merge(join);\n\n // exit\n join.exit().remove();\n\n // add the hexagons to the select\n this._createHexagons(enterUpdate, data);\n\n }\n\n protected _linearlySpace(from: number, to: number, length: number): number[] {\n const step = (to - from) / Math.max(length - 1, 1);\n return Array.from({ length }, (_, i) => from + (i * step));\n }\n\n _createHexagons(g: d3.Selection<SVGGElement, number, SVGGElement, unknown>, data: HexbinData<Data>[]) {\n const thisLayer = this;\n\n // Create the bins using the hexbin layout\n\n // Generate the map bounds (to be used to filter the hexes to what is visible)\n const size = thisLayer._map.getSize();\n const bounds = thisLayer._map.getBounds().pad(thisLayer.options.radius * 2 / Math.max(size.x, size.y));\n\n const bins = thisLayer._hexLayout.radius(this.options.radius)(data).filter(\n ({ x, y }) => bounds.contains(thisLayer._map.layerPointToLatLng(L.point(x, y)))\n );\n\n // Derive the extents of the data values for each dimension\n const colorExtent = thisLayer._getExtent(bins, thisLayer._fn.colorValue, thisLayer.options.colorScaleExtent);\n const radiusExtent = thisLayer._getExtent(bins, thisLayer._fn.radiusValue, thisLayer.options.radiusScaleExtent);\n const opacityExtent = thisLayer._getExtent(bins, thisLayer._fn.opacityValue, thisLayer.options.opacityScaleExtent);\n\n // Match the domain cardinality to that of the color range, to allow for a polylinear scale\n const colorDomain = this.options.colorDomain\n ?? thisLayer._linearlySpace(\n colorExtent[0],\n colorExtent[1],\n thisLayer._scale.color.range().length\n );\n const radiusDomain = this.options.radiusDomain || radiusExtent;\n\n // Set the scale domains\n thisLayer._scale.color.domain(colorDomain);\n thisLayer._scale.radius.domain(radiusDomain);\n thisLayer._scale.opacity.domain(opacityExtent);\n\n\n /*\n * Join\n * Join the Hexagons to the data\n * Use a deterministic id for tracking bins based on position\n */\n const join = g.selectAll<SVGGElement, HexbinBin<HexbinData<Data>>>('g.hexbin-container')\n .data(bins, ({ x, y }) => `${x}:${y}`);\n\n\n /*\n * Update\n * Set the fill and opacity on a transition\n * opacity is re-applied in case the enter transition was cancelled\n * the path is applied as well to resize the bins\n */\n join.select<SVGPathElement>('path.hexbin-hexagon')\n .transition().duration(thisLayer.options.duration)\n .attr('fill', thisLayer._fn.fill.bind(thisLayer))\n .attr('fill-opacity', (d) => thisLayer._scale.opacity(thisLayer._fn.opacityValue.call(thisLayer, d)))\n .attr('stroke-opacity', (d) => thisLayer._scale.opacity(thisLayer._fn.opacityValue.call(thisLayer, d)))\n .attr('d', (d) => {\n return thisLayer._hexLayout.hexagon(thisLayer._scale.radius(thisLayer._fn.radiusValue.call(thisLayer, d)));\n });\n\n\n /*\n * Enter\n * Establish the path, size, fill, and the initial opacity\n * Transition to the final opacity and size\n */\n const container = join.enter().append('g').attr('class', 'hexbin-container')\n .style('pointer-events', thisLayer.options.pointerEvents);\n\n\n container.on('mouseover', function (this: SVGGElement, d: MouseEvent, i) {\n // Bring container to foreground by re-appending it to the DOM\n select<SVGGElement, HexbinBin<HexbinData<Data>>>(this).raise();\n })\n\n const hexagons = container.append('path').attr('class', 'hexbin-hexagon')\n .attr('transform', ({ x, y }) => `translate(${x},${y})`)\n .attr('d', () => thisLayer._hexLayout.hexagon(thisLayer._scale.radius.range()[0]))\n // .attr('d', (data, length) => thisLayer._hexLayout.hexagon(thisLayer._scale.radius(data.length)))\n .attr('fill', thisLayer._fn.fill.bind(thisLayer))\n .attr('fill-opacity', 0.01)\n .attr('stroke-opacity', 0.01)\n .style('pointer-events', 'all');\n\n hexagons.transition().duration(thisLayer.options.duration)\n .attr('fill-opacity', (d) => thisLayer._scale.opacity(thisLayer._fn.opacityValue.call(thisLayer, d)))\n .attr('stroke-opacity', (d) => thisLayer._scale.opacity(thisLayer._fn.opacityValue.call(thisLayer, d)))\n .attr('d', (d) => thisLayer._hexLayout.hexagon(thisLayer._scale.radius(thisLayer._fn.radiusValue.call(thisLayer, d))))\n .style('pointer-events', 'all');\n\n // Grid\n const gridEnter = container.append('path').attr('class', 'hexbin-grid')\n .attr('transform', ({ x, y }) => `translate(${x},${y})`)\n .attr('d', () => thisLayer._hexLayout.hexagon(thisLayer.options.radius))\n .attr('fill', 'none')\n .attr('stroke', 'none')\n\n\n // Grid enter-update\n hexagons.on('mouseover', function (this: SVGPathElement, ev: MouseEvent, data) {\n if (thisLayer._tooltipOptions?.content) {\n thisLayer._tooltip\n ?.setContent(\n typeof thisLayer._tooltipOptions.content === \"function\"\n ? thisLayer._tooltipOptions.content(data)\n : thisLayer._tooltipOptions.content\n )\n .setLatLng(\n thisLayer._map.layerPointToLatLng(L.point(data.x, data.y))\n )\n .openOn(thisLayer._map);\n }\n thisLayer._hoverHandler.mouseover(this, thisLayer, ev, data);\n thisLayer._dispatch.call('mouseover', this, data, thisLayer, ev);\n this.classList.add('hover')\n })\n .on('mouseout', function (this: SVGPathElement, ev: MouseEvent, data) {\n thisLayer._tooltip?.close()\n thisLayer._hoverHandler.mouseout(this, thisLayer, ev, data);\n thisLayer._dispatch.call('mouseout', this, data, thisLayer, ev);\n this.classList.remove('hover')\n })\n .on('click', function (this, ev: MouseEvent, data) {\n const latLng = thisLayer._map.layerPointToLatLng(L.point(data.x, data.y));\n thisLayer._dispatch.call('click', this, data, latLng, thisLayer, ev);\n ev.stopPropagation()\n });\n\n\n // Exit\n const exit = join.exit();\n\n exit.select('path.hexbin-hexagon')\n .transition().duration(thisLayer.options.duration)\n .attr('fill-opacity', 0)\n .attr('stroke-opacity', 0)\n .attr('d', (d) => thisLayer._hexLayout.hexagon(0));\n\n exit.transition().duration(thisLayer.options.duration).remove();\n\n }\n\n _getExtent(\n bins: HexbinBin<HexbinData<Data>>[],\n valueFn: (d: HexbinBin<HexbinData<Data>>) => number,\n scaleExtent: [number, number | undefined]\n ): [number, number] {\n\n // Determine the extent of the values\n let ext = extent<HexbinBin<HexbinData<Data>>, number>(bins, valueFn.bind(this));\n // If either's null, initialize them to 0\n if (ext[0] === undefined || ext[1] === undefined) {\n ext = [0, 0]\n }\n\n // Now apply the optional clipping of the extent\n if (undefined != scaleExtent[0]) ext[0] = scaleExtent[0];\n if (undefined != scaleExtent[1]) ext[1] = scaleExtent[1];\n\n return ext as [number, number]\n }\n\n // ------------------------------------\n // Public API\n // ------------------------------------\n\n /**\n * Get or set the radius of the hexagon grid cells\n */\n radius(): number;\n radius(v: number): this;\n radius(v?: number): this | number {\n if (v === undefined) return this.options.radius;\n\n this.options.radius = v;\n this._hexLayout.radius(v);\n\n if (null == this.options.radiusRange) {\n this._scale.radius.range([this.options.radius, this.options.radius]).clamp(true);\n }\n\n return this;\n }\n\n\n /**\n * Get or set the opacity of the hexbin layer\n * @param v The opacity value to set. If an array is provided, the first element is the minimum opacity and the second is the maximum.\n */\n opacity(): number | [number, number];\n opacity(v: number | [number, number]): this;\n opacity(v?: number | [number, number]): this | number | [number, number] {\n if (v === undefined) return this.options.opacity\n this.options.opacity = v;\n this._scale.opacity.range(typeof v === 'number' ? [v, v] : v).clamp(true);\n\n return this;\n }\n\n /**\n * Get or set the duration of transition animations\n */\n duration(): number;\n duration(v: number): this;\n duration(v?: number): this | number {\n if (v === undefined) return this.options.duration\n this.options.duration = v\n\n return this;\n }\n\n /**\n * Get or set the color scale domain extent\n * @param v The color scale extent to set. If an array is provided, the first element is the minimum extent and the second is the maximum. This means that for the purpose of color interpolation, the domain will be clipped to this extent, i.e. values below the minimum will be treated as the minimum, and values above the maximum will be treated as the maximum.\n */\n colorScaleExtent(): [number, number | undefined];\n colorScaleExtent(v: [number, number | undefined]): this;\n colorScaleExtent(v?: [number, number | undefined]): this | [number, number | undefined] {\n if (v === undefined) { return this.options.colorScaleExtent; }\n this.options.colorScaleExtent = v;\n\n return this;\n }\n\n /**\n * Get or set the radius scale domain extent\n * @param v The radius scale extent to set. If an array is provided, the first element is the minimum extent and the second is the maximum. This means that for the purpose of radius interpolation, the domain will be clipped to this extent, i.e. values below the minimum will be treated as the minimum, and values above the maximum will be treated as the maximum.\n */\n radiusScaleExtent(): [number, number | undefined];\n radiusScaleExtent(v: [number, number | undefined]): this;\n radiusScaleExtent(v?: [number, number | undefined]): this | [number, number | undefined] {\n if (v === undefined) { return this.options.radiusScaleExtent; }\n this.options.radiusScaleExtent = v;\n\n return this;\n }\n\n /**\n * Get or set the opacity scale domain extent\n * @param v The opacity scale extent to set. If an array is provided, the first element is the minimum extent and the second is the maximum. This means that for the purpose of opacity interpolation, the domain will be clipped to this extent, i.e. values below the minimum will be treated as the minimum, and values above the maximum will be treated as the maximum.\n */\n opacityScaleExtent(): [number, number | undefined];\n opacityScaleExtent(v: [number, number | undefined]): this;\n opacityScaleExtent(v?: [number, number | undefined]): this | [number, number | undefined] {\n if (v === undefined) { return this.options.opacityScaleExtent; }\n this.options.opacityScaleExtent = v;\n\n return this;\n }\n\n\n /**\n * Get or set the color scale range\n * @param v The color range to set. Colors will be interpolated between all provided colors.\n */\n colorRange(): string[];\n colorRange(v: string[]): this;\n colorRange(v?: string[]): this | string[] {\n if (v === undefined) { return this.options.colorRange; }\n this.options.colorRange = v;\n this._scale.color.range(v);\n\n return this;\n }\n\n /**\n * Get or set the radius scale range\n * @param v The min and max radius range to set. If null, the range will be set to the hexagon grid cell radius value.\n */\n radiusRange(): [number, number] | null;\n radiusRange(v: [number, number] | null): this;\n radiusRange(v?: [number, number] | null): this | [number, number] | null {\n if (v === undefined) { return this.options.radiusRange; }\n this.options.radiusRange = v;\n this._scale.radius.range(this.options.radiusRange ?? [this.options.radius, this.options.radius]).clamp(true);\n\n return this;\n }\n\n /**\n * Get or set the color scale domain\n */\n colorScale(): d3.ScaleLinear<string, string>;\n colorScale(v: d3.ScaleLinear<string, string>): this;\n colorScale(v?: d3.ScaleLinear<string, string>) {\n if (v === undefined) return this._scale.color;\n this._scale.color = v;\n return this;\n }\n\n /**\n * Get or set the radius scale domain\n */\n radiusScale(): d3.ScaleLinear<number, number>;\n radiusScale(v: d3.ScaleLinear<number, number>): this;\n radiusScale(v?: d3.ScaleLinear<number, number>): this | d3.ScaleLinear<number, number> {\n if (v === undefined) return this._scale.radius\n this._scale.radius = v;\n return this;\n }\n\n /**\n * Get or set the value mapper for the color scale\n * @param v The value mapper to set. This function should accept an array of hexbin data and return a number to be used for color interpolation.\n * @default the length of the data in the hexbin\n */\n colorValue(): (d: HexbinData<Data>[]) => number;\n colorValue(v: (d: HexbinData<Data>[]) => number): this;\n colorValue(v?: (d: HexbinData<Data>[]) => number) {\n if (v === undefined) { return this._fn.colorValue; }\n this._fn.colorValue = v;\n\n return this;\n }\n\n /**\n * Get or set the value mapper for the radius scale\n * @param v The value mapper to set. This function should return a number for each bin, which will be used to determine the radius of the hexagon.\n * @default the length of the data in the hexbin\n */\n radiusValue(): (d: HexbinData<Data>[]) => number;\n radiusValue(v: (d: HexbinData<Data>[]) => number): this;\n radiusValue(v?: (d: HexbinData<Data>[]) => number) {\n if (v === undefined) { return this._fn.radiusValue; }\n this._fn.radiusValue = v;\n\n return this;\n }\n\n /**\n * Get or set the value mapper for the fill color of the hexbins\n * @param v The value mapper to set. This function should return a string to be used as the fill color for the hexbin.\n * @default a color interpolated from the color scale based on the value returned by the colorValue function\n */\n fill(): (d: HexbinData<Data>[]) => string;\n fill(v: (d: HexbinData<Data>[]) => string): this;\n fill(v?: (d: HexbinData<Data>[]) => string) {\n if (v === undefined) { return this._fn.fill; }\n this._fn.fill = v;\n\n return this;\n }\n\n /**\n * Get or set the data to be binned by the hexbin layer.\n * Triggers a redraw of the hexbins when set.\n * @param v The data to set. This should be an array of data to be binned.\n * @param accessor An optional function to convert the data into a LatLngExpression. If not provided, the data is assumed to be an array of LatLngExpressions.\n */\n data(): Data[];\n data(v: Data extends L.LatLngExpression ? Data[] : never): this;\n data(v: Data[], accessor?: (d: Data) => L.LatLngExpression): this;\n\n // Implementation\n data(v?: Data[] | L.LatLngExpression[], accessor?: (d: Data) => L.LatLngExpression): this | Data[] {\n if (v === undefined) {\n return this._data;\n }\n\n if (!isLatLngExpression(v[0]) && !accessor) {\n console.error(\"Leaflet hexbin: data does not appear to be an array of L.LatLngExpression. You must provide an accessor function to convert the data to L.LatLngExpression\");\n }\n\n this._data = v as Data[] ?? []\n this._accessor = accessor ?? ((d: Data) => d as L.LatLngExpression)\n\n if (!this.options.noRedraw) this.redraw();\n return this;\n }\n\n accessor(): (d: Data) => L.LatLngExpression {\n return this._accessor;\n }\n\n /*\n * Getter for the D3 event dispatcher\n */\n dispatch() { return this._dispatch }\n\n /**\n * Get or set the hover handler for the hexbin layer.\n */\n hoverHandler(): HexbinHoverHandler<Data>;\n hoverHandler(v: HexbinHoverHandler<Data>): this;\n hoverHandler(v?: HexbinHoverHandler<Data>): this | HexbinHoverHandler<Data> {\n if (v === undefined) { return this._hoverHandler; }\n this._hoverHandler = (null != v) ? v : HexbinHoverHandler.none();\n\n if (!this.options.noRedraw) this.redraw();\n\n return this;\n }\n\n /**\n * Get or set the tooltip content and options for the hexbin layer.\n */\n // Cannot overload bindTooltip() with data dependant content\n tooltip(tooltip: TooltipOptions<Data>): this {\n this._tooltipOptions = tooltip;\n if (this._tooltip)\n this._tooltip.options = tooltip.options ?? {};\n else {\n this._tooltip = L.tooltip(tooltip.options)\n }\n return this\n }\n\n /**\n * Get the tooltip instance attached to the hexbin layer\n */\n getTooltip(): L.Tooltip | undefined {\n return this._tooltip\n }\n\n /**\n * Bind a tooltip to the hexbin layer with the provided content and options.\n * Useful to bind an existing tooltip instance to the hexbin layer.\n */\n bindTooltip(content: L.Tooltip | L.Content, options?: L.TooltipOptions): this {\n if (content instanceof L.Tooltip) {\n this._tooltip = content;\n // FIXME: weird bug likely coming from vue-leaflet were tooltip is not properly positioned\n // this._tooltip.options.offset[0] -= 5;\n if (this._map) {\n this._tooltip.setLatLng([0, 0]).addTo(this._map)\n }\n } else {\n this._tooltip = L.tooltip(options).setContent(content);\n }\n return this\n }\n\n /**\n * Unbind the tooltip from the hexbin layer\n */\n unbindTooltip(): this {\n this._tooltip?.remove();\n this._tooltip = undefined;\n return this\n }\n\n /*\n * Returns an array of the points in the path, or nested arrays of points in case of multi-polyline.\n */\n getLatLngs() {\n // Map the data into an array of latLngs using the configured lat/lng accessors\n return this._data.map((d) => {\n return L.latLng(this._accessor(d));\n });\n }\n /*\n * Get path geometry as GeoJSON\n */\n toGeoJSON(): GeoJSON.Feature<GeoJSON.MultiPoint, L.LatLng> {\n return L.GeoJSON.getFeature<L.LatLng, GeoJSON.MultiPoint>(this, {\n type: 'MultiPoint',\n coordinates: L.GeoJSON.latLngsToCoords(this.getLatLngs(), 0)\n });\n }\n}\n\n/**\n * Factory function to instanciate a new hexbin layer\n */\nexport function hexbinLayer<Data = L.LatLngExpression>(options?: HexbinLayerConfig) {\n return new HexbinLayer<Data>(options);\n}\n\n\n"],"names":["HexbinHoverHandler","resizeFill","svg","hexLayer","event","data","d3","d","resizeScale","radiusScale","compound","handlers","none","h","HexbinHoverHandler$1","isLatLngExpression","L","debounce","callback","delay","timeoutTimer","args","HexbinLayer","options","val","scaleLinear","dispatch","hexbin","x","y","select","map","_a","that","coord","point","join","enterUpdate","from","to","length","step","_","i","g","thisLayer","size","bounds","bins","colorExtent","radiusExtent","opacityExtent","colorDomain","radiusDomain","container","hexagons","ev","_b","latLng","exit","valueFn","scaleExtent","ext","extent","v","accessor","tooltip","content","hexbinLayer"],"mappings":"ynBAeiB,IAAAA,GAAAA,GAAV,CAIE,SAASC,GAAsC,CAC7C,MAAA,CACL,UAAW,SAAUC,EAAqBC,EAA4BC,EAAmBC,EAAyB,CACtGC,EAAG,OAA8CJ,EA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A,GAEtC,KAAK,QAAQ,eAAe,OAAO,EACjC,KAAA,CAGT,UAA4C,CAC1C,OAAO,KAAK,SAAA,CAMd,UAAW,CAAE,OAAO,KAAK,SAAA,CAOzB,aAAayD,EAA+D,CAC1E,OAAIA,IAAM,OAAoB,KAAK,eACnC,KAAK,cAAyBA,GAAShE,EAAmB,KAAK,EAE1D,KAAK,QAAQ,eAAe,OAAO,EAEjC,KAAA,CAOT,QAAQkE,EAAqC,CAC3C,YAAK,gBAAkBA,EACnB,KAAK,SACP,KAAK,SAAS,QAAUA,EAAQ,SAAW,CAAC,EAE5C,KAAK,SAAWlD,EAAE,QAAQkD,EAAQ,OAAO,EAEpC,IAAA,CAMT,YAAoC,CAClC,OAAO,KAAK,QAAA,CAOd,YAAYC,EAAgC5C,EAAkC,CACxE,OAAA4C,aAAmBnD,EAAE,SACvB,KAAK,SAAWmD,EAGZ,KAAK,MACF,KAAA,SAAS,UAAU,CAAC,EAAG,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,GAGjD,KAAK,SAAWnD,EAAE,QAAQO,CAAO,EAAE,WAAW4C,CAAO,EAEhD,IAAA,CAMT,eAAsB,OACpB,OAAAnC,EAAA,KAAK,WAAL,MAAAA,EAAe,SACf,KAAK,SAAW,OACT,IAAA,CAMT,YAAa,CAEX,OAAO,KAAK,MAAM,IAAKzB,GACdS,EAAE,OAAO,KAAK,UAAUT,CAAC,CAAC,CAClC,CAAA,CAKH,WAA2D,CAClD,OAAAS,EAAE,QAAQ,WAAyC,KAAM,CAC9D,KAAM,aACN,YAAaA,EAAE,QAAQ,gBAAgB,KAAK,WAAA,EAAc,CAAC,CAAA,CAC5D,CAAA,CAEL,CAKO,SAASoD,EAAuC7C,EAA6B,CAC3E,OAAA,IAAID,EAAkBC,CAAO,CACtC"}
@@ -15,7 +15,8 @@ export declare namespace HexbinHoverHandler {
15
15
  */
16
16
  function resizeFill(): HexbinHoverHandler<any>;
17
17
  /**
18
- * Resize the hexbin by a scaling factor on hover.
18
+ * Resize the hexbin by a scaling factor applied to the maximum hex radius.
19
+ * Use a scaling factor of 1 to grow/shrink the hexbin to the edge of the cell.
19
20
  */
20
21
  function resizeScale(radiusScale?: number): HexbinHoverHandler<any>;
21
22
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "leaflet-hexbin",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "license": "MIT",