leaflet-hexbin 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.es.js CHANGED
@@ -1,74 +1,74 @@
1
- import * as m from "d3";
2
- import { scaleLinear as b, dispatch as V, select as E, extent as v } from "d3";
1
+ import * as y from "d3";
2
+ import { scaleLinear as b, dispatch as V, select as L, extent as v } from "d3";
3
3
  import { hexbin as R } from "d3-hexbin";
4
- import * as h from "leaflet";
5
- var S;
6
- ((p) => {
4
+ import * as p from "leaflet";
5
+ var E;
6
+ ((r) => {
7
7
  function t(a = { tooltipContent(o) {
8
8
  return `Count: ${o.length}`;
9
9
  } }) {
10
- const o = m.select("body").append("div").attr("class", "hexbin-tooltip").style("z-index", 9999).style("pointer-events", "none").style("visibility", "hidden").style("position", "fixed");
10
+ const o = y.select("body").append("div").attr("class", "hexbin-tooltip").style("z-index", 9999).style("pointer-events", "none").style("visibility", "hidden").style("position", "fixed");
11
11
  return o.append("div").attr("class", "tooltip-content"), {
12
- mouseover: function(s, d, u, c) {
13
- const f = m.pointer(u);
14
- o.style("visibility", "visible").html(a.tooltipContent(c, d));
12
+ mouseover: function(s, h, c, d) {
13
+ const f = y.pointer(c);
14
+ o.style("visibility", "visible").html(a.tooltipContent(d, h));
15
15
  const g = o.node();
16
16
  if (!g) {
17
17
  console.warn("Leaflet hexbin: tooltip node not found");
18
18
  return;
19
19
  }
20
- const y = g.clientHeight, x = g.clientWidth;
21
- o.style("top", u.clientY - f[1] - y - 16 + "px").style("left", u.clientX - f[0] - x / 2 + "px");
20
+ const m = g.clientHeight, x = g.clientWidth;
21
+ o.style("top", c.clientY - f[1] - m - 16 + "px").style("left", c.clientX - f[0] - x / 2 + "px");
22
22
  },
23
- mouseout: function(s, d, u, c) {
23
+ mouseout: function(s, h, c, d) {
24
24
  o.style("visibility", "hidden").html();
25
25
  }
26
26
  };
27
27
  }
28
- p.tooltip = t;
28
+ r.tooltip = t;
29
29
  function e() {
30
30
  return {
31
- mouseover: function(a, o, s, d) {
32
- m.select(a.parentElement).select("path.hexbin-hexagon").attr("d", function(c) {
31
+ mouseover: function(a, o, s, h) {
32
+ y.select(a.parentElement).select("path.hexbin-hexagon").attr("d", function(d) {
33
33
  return o._hexLayout.hexagon(o.options.radius);
34
34
  });
35
35
  },
36
- mouseout: function(a, o, s, d) {
37
- m.select(a.parentElement).select("path.hexbin-hexagon").attr("d", function(c) {
38
- return o._hexLayout.hexagon(o._scale.radius(o._fn.radiusValue.call(o, c)));
36
+ mouseout: function(a, o, s, h) {
37
+ y.select(a.parentElement).select("path.hexbin-hexagon").attr("d", function(d) {
38
+ return o._hexLayout.hexagon(o._scale.radius(o._fn.radiusValue.call(o, d)));
39
39
  });
40
40
  }
41
41
  };
42
42
  }
43
- p.resizeFill = e;
43
+ r.resizeFill = e;
44
44
  function n(a = 1.5) {
45
45
  return {
46
- mouseover: function(o, s, d, u) {
47
- m.select(o.parentElement).select("path.hexbin-hexagon").transition().duration(s.options.duration).attr("d", function() {
46
+ mouseover: function(o, s, h, c) {
47
+ y.select(o.parentElement).select("path.hexbin-hexagon").transition().duration(s.options.duration).attr("d", function() {
48
48
  return s._hexLayout.hexagon(s._scale.radius.range()[1] * a);
49
49
  });
50
50
  },
51
- mouseout: function(o, s, d, u) {
52
- m.select(o.parentElement).select("path.hexbin-hexagon").transition().duration(s.options.duration).attr("d", (f) => s._hexLayout.hexagon(s._scale.radius(s._fn.radiusValue.call(s, f))));
51
+ mouseout: function(o, s, h, c) {
52
+ y.select(o.parentElement).select("path.hexbin-hexagon").transition().duration(s.options.duration).attr("d", (f) => s._hexLayout.hexagon(s._scale.radius(s._fn.radiusValue.call(s, f))));
53
53
  }
54
54
  };
55
55
  }
56
- p.resizeScale = n;
57
- function l(a = [_()]) {
56
+ r.resizeScale = n;
57
+ function u(a = [_()]) {
58
58
  return {
59
- mouseover: function(o, s, d, u) {
60
- a.forEach((c) => {
61
- c.mouseover(o, s, d, u);
59
+ mouseover: function(o, s, h, c) {
60
+ a.forEach((d) => {
61
+ d.mouseover(o, s, h, c);
62
62
  });
63
63
  },
64
- mouseout: function(o, s, d, u) {
65
- a.forEach((c) => {
66
- c.mouseout(o, s, d, u);
64
+ mouseout: function(o, s, h, c) {
65
+ a.forEach((d) => {
66
+ d.mouseout(o, s, h, c);
67
67
  });
68
68
  }
69
69
  };
70
70
  }
71
- p.compound = l;
71
+ r.compound = u;
72
72
  function _() {
73
73
  return {
74
74
  mouseover: function() {
@@ -77,10 +77,13 @@ var S;
77
77
  }
78
78
  };
79
79
  }
80
- p.none = _;
81
- })(S || (S = {}));
82
- const L = S;
83
- class C extends h.SVG {
80
+ r.none = _;
81
+ })(E || (E = {}));
82
+ const S = E;
83
+ function C(r) {
84
+ return r instanceof p.LatLng || typeof r == "object" && "lat" in r && "lng" in r || Array.isArray(r) && r.length === 2 && typeof r[0] == "number" && typeof r[1] == "number";
85
+ }
86
+ class w extends p.SVG {
84
87
  constructor(t) {
85
88
  super(), this.options = {
86
89
  radius: 12,
@@ -96,11 +99,11 @@ class C extends h.SVG {
96
99
  pointerEvents: "all",
97
100
  // Handle parent default options
98
101
  // ...L.SVG.prototype.options,
99
- ...h.Renderer.prototype.options,
100
- ...h.Layer.prototype.options
102
+ ...p.Renderer.prototype.options,
103
+ ...p.Layer.prototype.options
101
104
  }, this._fn = {
102
- lng: (e) => h.latLng(e).lng,
103
- lat: (e) => h.latLng(e).lat,
105
+ lng: (e) => p.latLng(this._accessor(e)).lng,
106
+ lat: (e) => p.latLng(this._accessor(e)).lat,
104
107
  colorValue: (e) => e.length,
105
108
  radiusValue: (e) => e.length,
106
109
  opacityValue: (e) => e.length,
@@ -112,16 +115,19 @@ class C extends h.SVG {
112
115
  color: b(),
113
116
  radius: b(),
114
117
  opacity: b()
115
- }, this._dispatch = V("mouseover", "mouseout", "click"), this._hoverHandler = L.none(), this._hexLayout = R().radius(this.options.radius).x(({ point: [e, n] }) => e).y(({ point: [e, n] }) => n), this._data = Array(), 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(
118
+ }, this._dispatch = V("mouseover", "mouseout", "click"), this._hoverHandler = S.none(), this._hexLayout = R().radius(this.options.radius).x(({ point: [e, n] }) => e).y(({ point: [e, n] }) => n), this._data = Array(), 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(
116
119
  typeof this.options.opacity == "number" ? [this.options.opacity, this.options.opacity] : this.options.opacity
117
120
  ).clamp(!0);
118
121
  }
122
+ _accessor(t) {
123
+ return t;
124
+ }
119
125
  /**
120
126
  * Create the SVG container for the hexbins
121
127
  * @private
122
128
  */
123
129
  _initContainer() {
124
- super._initContainer(), this._d3Container = E(this._container).select("g");
130
+ super._initContainer(), this._d3Container = L(this._container).select("g");
125
131
  }
126
132
  /**
127
133
  * Callback made by Leaflet when the layer is added to the map
@@ -146,7 +152,7 @@ class C extends h.SVG {
146
152
  * @private
147
153
  */
148
154
  _destroyContainer() {
149
- E(this._container).remove();
155
+ L(this._container).remove();
150
156
  }
151
157
  /**
152
158
  * (Re)draws the hexbins data on the container
@@ -156,46 +162,46 @@ class C extends h.SVG {
156
162
  const t = this;
157
163
  if (!t._map) return;
158
164
  const e = t._data.map((a) => {
159
- const o = t._project(a);
160
- return { o: a, point: o };
165
+ const o = t._accessor(a), s = t._project(o);
166
+ return { coord: o, point: s, data: a };
161
167
  }), n = this._d3Container.selectAll("g.hexbin").data([this._map.getZoom()], (a) => a), _ = n.enter().append("g").attr("class", function(a) {
162
168
  return "hexbin zoom-" + a;
163
169
  }).merge(n);
164
170
  n.exit().remove(), this._createHexagons(_, e);
165
171
  }
166
172
  _linearlySpace(t, e, n) {
167
- const l = (e - t) / Math.max(n - 1, 1);
168
- return Array.from({ length: n }, (_, a) => t + a * l);
173
+ const u = (e - t) / Math.max(n - 1, 1);
174
+ return Array.from({ length: n }, (_, a) => t + a * u);
169
175
  }
170
176
  _createHexagons(t, e) {
171
- const n = this, l = n._map.getSize(), _ = n._map.getBounds().pad(n.options.radius * 2 / Math.max(l.x, l.y)), a = n._hexLayout(e).filter(
172
- ({ x: i, y: r }) => _.contains(n._map.layerPointToLatLng(h.point(i, r)))
173
- ), o = n._getExtent(a, n._fn.colorValue, n.options.colorScaleExtent), s = n._getExtent(a, n._fn.radiusValue, n.options.radiusScaleExtent), d = n._getExtent(a, n._fn.opacityValue, n.options.opacityScaleExtent), u = this.options.colorDomain ?? n._linearlySpace(
177
+ const n = this, u = n._map.getSize(), _ = n._map.getBounds().pad(n.options.radius * 2 / Math.max(u.x, u.y)), a = n._hexLayout(e).filter(
178
+ ({ x: i, y: l }) => _.contains(n._map.layerPointToLatLng(p.point(i, l)))
179
+ ), o = n._getExtent(a, n._fn.colorValue, n.options.colorScaleExtent), s = n._getExtent(a, n._fn.radiusValue, n.options.radiusScaleExtent), h = n._getExtent(a, n._fn.opacityValue, n.options.opacityScaleExtent), c = this.options.colorDomain ?? n._linearlySpace(
174
180
  o[0],
175
181
  o[1],
176
182
  n._scale.color.range().length
177
- ), c = this.options.radiusDomain || s;
178
- n._scale.color.domain(u), n._scale.radius.domain(c), n._scale.opacity.domain(d);
179
- const f = t.selectAll("g.hexbin-container").data(a, ({ x: i, y: r }) => `${i}:${r}`);
183
+ ), d = this.options.radiusDomain || s;
184
+ n._scale.color.domain(c), n._scale.radius.domain(d), n._scale.opacity.domain(h);
185
+ const f = t.selectAll("g.hexbin-container").data(a, ({ x: i, y: l }) => `${i}:${l}`);
180
186
  f.select("path.hexbin-hexagon").transition().duration(n.options.duration).attr("fill", n._fn.fill.bind(n)).attr("fill-opacity", (i) => n._scale.opacity(n._fn.opacityValue.call(n, i))).attr("stroke-opacity", (i) => n._scale.opacity(n._fn.opacityValue.call(n, i))).attr("d", (i) => n._hexLayout.hexagon(n._scale.radius(n._fn.radiusValue.call(n, i))));
181
187
  const g = f.enter().append("g").attr("class", "hexbin-container").style("pointer-events", n.options.pointerEvents);
182
- g.on("mouseover", function(i, r) {
183
- E(this).raise();
188
+ g.on("mouseover", function(i, l) {
189
+ L(this).raise();
184
190
  });
185
- const y = g.append("path").attr("class", "hexbin-hexagon").attr("transform", ({ x: i, y: r }) => `translate(${i},${r})`).attr("d", () => n._hexLayout.hexagon(n._scale.radius.range()[0])).attr("fill", n._fn.fill.bind(n)).attr("fill-opacity", 0.01).attr("stroke-opacity", 0.01).style("pointer-events", "all");
186
- y.transition().duration(n.options.duration).attr("fill-opacity", (i) => n._scale.opacity(n._fn.opacityValue.call(n, i))).attr("stroke-opacity", (i) => n._scale.opacity(n._fn.opacityValue.call(n, i))).attr("d", (i) => n._hexLayout.hexagon(n._scale.radius(n._fn.radiusValue.call(n, i)))).style("pointer-events", "all"), g.append("path").attr("class", "hexbin-grid").attr("transform", ({ x: i, y: r }) => `translate(${i},${r})`).attr("d", () => n._hexLayout.hexagon(n.options.radius)).attr("fill", "none").attr("stroke", "none"), y.on("mouseover", function(i, r) {
187
- n._hoverHandler.mouseover(this, n, i, r), n._dispatch.call("mouseover", this, i, r), this.classList.add("hover");
188
- }).on("mouseout", function(i, r) {
189
- n._hoverHandler.mouseout(this, n, i, r), n._dispatch.call("mouseout", this, n, i, r), this.classList.remove("hover");
190
- }).on("click", function(i, r) {
191
- n._dispatch.call("click", this, n, i, r);
191
+ const m = g.append("path").attr("class", "hexbin-hexagon").attr("transform", ({ x: i, y: l }) => `translate(${i},${l})`).attr("d", () => n._hexLayout.hexagon(n._scale.radius.range()[0])).attr("fill", n._fn.fill.bind(n)).attr("fill-opacity", 0.01).attr("stroke-opacity", 0.01).style("pointer-events", "all");
192
+ m.transition().duration(n.options.duration).attr("fill-opacity", (i) => n._scale.opacity(n._fn.opacityValue.call(n, i))).attr("stroke-opacity", (i) => n._scale.opacity(n._fn.opacityValue.call(n, i))).attr("d", (i) => n._hexLayout.hexagon(n._scale.radius(n._fn.radiusValue.call(n, i)))).style("pointer-events", "all"), g.append("path").attr("class", "hexbin-grid").attr("transform", ({ x: i, y: l }) => `translate(${i},${l})`).attr("d", () => n._hexLayout.hexagon(n.options.radius)).attr("fill", "none").attr("stroke", "none"), m.on("mouseover", function(i, l) {
193
+ n._hoverHandler.mouseover(this, n, i, l), n._dispatch.call("mouseover", this, l, n, i), this.classList.add("hover");
194
+ }).on("mouseout", function(i, l) {
195
+ n._hoverHandler.mouseout(this, n, i, l), n._dispatch.call("mouseout", this, l, n, i), this.classList.remove("hover");
196
+ }).on("click", function(i, l) {
197
+ n._dispatch.call("click", this, l, n, i);
192
198
  });
193
199
  const x = f.exit();
194
200
  x.select("path.hexbin-hexagon").transition().duration(n.options.duration).attr("fill-opacity", 0).attr("stroke-opacity", 0).attr("d", (i) => n._hexLayout.hexagon(0)), x.transition().duration(n.options.duration).remove();
195
201
  }
196
202
  _getExtent(t, e, n) {
197
- let l = v(t, e.bind(this));
198
- return (l[0] === void 0 || l[1] === void 0) && (l = [0, 0]), n[0] != null && (l[0] = n[0]), n[1] != null && (l[1] = n[1]), l;
203
+ let u = v(t, e.bind(this));
204
+ return (u[0] === void 0 || u[1] === void 0) && (u = [0, 0]), n[0] != null && (u[0] = n[0]), n[1] != null && (u[1] = n[1]), u;
199
205
  }
200
206
  radius(t) {
201
207
  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);
@@ -242,8 +248,9 @@ class C extends h.SVG {
242
248
  fill(t) {
243
249
  return t === void 0 ? this._fn.fill : (this._fn.fill = t, this);
244
250
  }
245
- data(t) {
246
- return t === void 0 ? this._data : (this._data = t ?? [], this.redraw(), this);
251
+ // Implementation
252
+ data(t, e) {
253
+ return t === void 0 ? this._data : (!C(t[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 = t ?? [], this._accessor = e ?? ((n) => n), this.redraw(), this);
247
254
  }
248
255
  /*
249
256
  * Getter for the event dispatcher
@@ -252,7 +259,7 @@ class C extends h.SVG {
252
259
  return this._dispatch;
253
260
  }
254
261
  hoverHandler(t) {
255
- return t === void 0 ? this._hoverHandler : (this._hoverHandler = t ?? L.none(), this.redraw(), this);
262
+ return t === void 0 ? this._hoverHandler : (this._hoverHandler = t ?? S.none(), this.redraw(), this);
256
263
  }
257
264
  /*
258
265
  * Returns an array of the points in the path, or nested arrays of points in case of multi-polyline.
@@ -260,25 +267,25 @@ class C extends h.SVG {
260
267
  getLatLngs() {
261
268
  const t = this;
262
269
  return this._data.map(function(e) {
263
- return h.latLng(t._fn.lat(e), t._fn.lng(e));
270
+ return p.latLng(t._fn.lat(e), t._fn.lng(e));
264
271
  });
265
272
  }
266
273
  /*
267
274
  * Get path geometry as GeoJSON
268
275
  */
269
276
  toGeoJSON() {
270
- return h.GeoJSON.getFeature(this, {
277
+ return p.GeoJSON.getFeature(this, {
271
278
  type: "MultiPoint",
272
- coordinates: h.GeoJSON.latLngsToCoords(this.getLatLngs(), 0)
279
+ coordinates: p.GeoJSON.latLngsToCoords(this.getLatLngs(), 0)
273
280
  });
274
281
  }
275
282
  }
276
- function z(p) {
277
- return new C(p);
283
+ function A(r) {
284
+ return new w(r);
278
285
  }
279
286
  export {
280
- L as HexbinHoverHandler,
281
- C as HexbinLayer,
282
- z as hexbinLayer
287
+ S as HexbinHoverHandler,
288
+ w as HexbinLayer,
289
+ A as hexbinLayer
283
290
  };
284
291
  //# 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\nexport interface HexbinHoverHandler {\n mouseover(svg: SVGPathElement, hexLayer: HexbinLayer, event: MouseEvent, data: HexbinData[]): void;\n mouseout(svg: SVGPathElement, hexLayer: HexbinLayer, event: MouseEvent, data: HexbinData[]): void;\n}\n\nexport namespace HexbinHoverHandler {\n\n interface TooltipOptions {\n tooltipContent: (d: HexbinData[], hexLayer: HexbinLayer) => string;\n }\n\n export function tooltip(options: TooltipOptions = { tooltipContent(d) { return `Count: ${d.length}` } }): HexbinHoverHandler {\n\n // Generate the tooltip\n const tooltip = d3.select('body').append('div')\n .attr('class', 'hexbin-tooltip')\n .style('z-index', 9999)\n .style('pointer-events', 'none')\n .style('visibility', 'hidden')\n .style('position', 'fixed');\n\n tooltip.append('div').attr('class', 'tooltip-content');\n\n // return the handler instance\n return {\n mouseover: function (svg: SVGPathElement, hexLayer: HexbinLayer, event: MouseEvent, data: HexbinData[]) {\n const gCoords = d3.pointer(event);\n\n tooltip\n .style('visibility', 'visible')\n .html(options.tooltipContent(data, hexLayer));\n\n\n const div = tooltip.node();\n if (!div) {\n console.warn(\"Leaflet hexbin: tooltip node not found\");\n return\n }\n const h = div.clientHeight, w = div.clientWidth;\n\n tooltip\n .style('top', event.clientY - gCoords[1] - h - 16 + 'px')\n .style('left', event.clientX - gCoords[0] - w / 2 + 'px');\n\n },\n mouseout: function (svg, hexLayer: HexbinLayer, event: MouseEvent, data: HexbinData[]) {\n tooltip\n .style('visibility', 'hidden')\n .html();\n }\n };\n\n }\n\n export function resizeFill(): HexbinHoverHandler {\n return {\n mouseover: function (svg: SVGPathElement, hexLayer: HexbinLayer, event: MouseEvent, data: HexbinData[]) {\n const o = d3.select<HTMLElement | null, HexbinData[]>(svg.parentElement);\n o.select('path.hexbin-hexagon')\n .attr('d', function (d) {\n return hexLayer._hexLayout.hexagon(hexLayer.options.radius);\n });\n },\n mouseout: function (svg: SVGPathElement, hexLayer: HexbinLayer, event: MouseEvent, data: HexbinData[]) {\n const o = d3.select<HTMLElement | null, HexbinData[]>(svg.parentElement);\n o.select<SVGPathElement>('path.hexbin-hexagon')\n .attr('d', function (d) {\n return hexLayer._hexLayout.hexagon(hexLayer._scale.radius(hexLayer._fn.radiusValue.call(hexLayer, d)));\n });\n }\n };\n\n }\n\n export interface ResizeScaleOptions {\n radiusScale?: number;\n duration?: number;\n }\n\n export function resizeScale(radiusScale: number = 1.5): HexbinHoverHandler {\n\n // return the handler instance\n return {\n mouseover: function (svg, hexLayer, event, data) {\n const o = d3.select<HTMLElement | null, HexbinData[]>(svg.parentElement);\n o.select('path.hexbin-hexagon')\n .transition().duration(hexLayer.options.duration)\n .attr('d', function () {\n return hexLayer._hexLayout.hexagon(hexLayer._scale.radius.range()[1] * (radiusScale));\n });\n },\n mouseout: function (svg, hexLayer, event, data) {\n const o = d3.select<HTMLElement | null, HexbinData[]>(svg.parentElement!);\n o.select('path.hexbin-hexagon')\n .transition().duration(hexLayer.options.duration)\n .attr('d', (d) => {\n return hexLayer._hexLayout.hexagon(hexLayer._scale.radius(hexLayer._fn.radiusValue.call(hexLayer, d)));\n });\n }\n };\n }\n\n\n export function compound(handlers: HexbinHoverHandler[] = [none()]): HexbinHoverHandler {\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 export function none(): HexbinHoverHandler {\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// Need to expose some methods from L.SVG\ndeclare module 'leaflet' {\n interface SVG {\n _initContainer(): void;\n _container: SVGElementTagNameMap['svg']\n }\n}\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/**\n * Hexbin data attached to each hexagon, once binned.\n */\nexport type HexbinData = {\n o: L.LatLngExpression;\n point: Readonly<[number, number]>;\n}\n\n\n/**\n * Instantiate a hexbin layer.\n * Extends L.SVG to take advantage of built-in zoom animations.\n */\nexport class HexbinLayer extends L.SVG implements HexbinLayer {\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 // Handle parent default options\n // ...L.SVG.prototype.options,\n ...L.Renderer.prototype.options,\n ...L.Layer.prototype.options\n }\n _fn = {\n lng: (d: L.LatLngExpression) => L.latLng(d).lng,\n lat: (d: L.LatLngExpression) => L.latLng(d).lat,\n colorValue: (d: HexbinData[]) => d.length,\n radiusValue: (d: HexbinData[]) => d.length,\n opacityValue: (d: HexbinData[]) => d.length,\n fill: (d: HexbinData[]) => {\n const val = this._fn.colorValue(d);\n return (null != val) ? this._scale.color(val) : 'none';\n }\n }\n // Set up the customizable scale\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 _dispatch = dispatch<SVGPathElement>('mouseover', 'mouseout', 'click');\n\n // Set up the default hover handler\n _hoverHandler: HexbinHoverHandler = HexbinHoverHandler.none();\n\n // Create the hex layout\n _hexLayout = hexbin<HexbinData>()\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 _data = Array<L.LatLngExpression>()\n\n declare _map: L.Map;\n declare _container: SVGElementTagNameMap['svg'];\n\n // declare _container: HTMLElement;\n declare _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 /**\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 // Redraw on moveend\n map.on('moveend', this.redraw, this);\n // Initial draw\n this.redraw();\n return this\n }\n\n _project(latlng: L.LatLngExpression) {\n const { x, y } = this._map.latLngToLayerPoint(latlng);\n return [x, y] as const;\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 * @private\n */\n _destroyContainer() {\n select(this._container).remove();\n }\n\n /**\n * (Re)draws the hexbins data on the container\n * @private\n */\n 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>((d) => {\n const point = that._project(d);\n return { o: d, point };\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 _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[]) {\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>>('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 const c = select<SVGGElement, HexbinBin<HexbinData>>(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, d: MouseEvent, i) {\n thisLayer._hoverHandler.mouseover(this, thisLayer as HexbinLayer, d, i);\n thisLayer._dispatch.call('mouseover', this, d, i);\n this.classList.add('hover')\n })\n .on('mouseout', function (this: SVGPathElement, d: MouseEvent, i) {\n thisLayer._hoverHandler.mouseout(this, thisLayer as HexbinLayer, d, i);\n thisLayer._dispatch.call('mouseout', this, thisLayer as HexbinLayer, d, i);\n this.classList.remove('hover')\n })\n .on('click', function (this, d, i) {\n thisLayer._dispatch.call('click', this, thisLayer as HexbinLayer, d, i);\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>[],\n valueFn: (d: HexbinBin<HexbinData>) => number,\n scaleExtent: [number, number | undefined]\n ): [number, number] {\n\n // Determine the extent of the values\n let ext = extent<HexbinBin<HexbinData>, 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 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 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 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 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 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 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 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 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 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 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 lng(): (d: L.LatLngExpression) => number;\n lng(v: (d: L.LatLngExpression) => number): this;\n lng(v?: (d: L.LatLngExpression) => number) {\n if (v === undefined) { return this._fn.lng; }\n this._fn.lng = v;\n\n return this;\n }\n\n lat(): (d: L.LatLngExpression) => number;\n lat(v: (d: L.LatLngExpression) => number): this;\n lat(v?: (d: L.LatLngExpression) => number) {\n if (v === undefined) { return this._fn.lat; }\n this._fn.lat = v;\n\n return this;\n }\n\n colorValue(): (d: HexbinData[]) => number;\n colorValue(v: (d: HexbinData[]) => number): this;\n colorValue(v?: (d: HexbinData[]) => number) {\n if (v === undefined) { return this._fn.colorValue; }\n this._fn.colorValue = v;\n\n return this;\n }\n\n radiusValue(): (d: HexbinData[]) => number;\n radiusValue(v: (d: HexbinData[]) => number): this;\n radiusValue(v?: (d: HexbinData[]) => number) {\n if (v === undefined) { return this._fn.radiusValue; }\n this._fn.radiusValue = v;\n\n return this;\n }\n\n fill(): (d: HexbinData[]) => string;\n fill(v: (d: HexbinData[]) => string): this;\n fill(v?: (d: HexbinData[]) => string) {\n if (v === undefined) { return this._fn.fill; }\n this._fn.fill = v;\n\n return this;\n }\n\n data(): L.LatLngExpression[];\n data(v: L.LatLngExpression[]): this;\n data(v?: L.LatLngExpression[]): this | L.LatLngExpression[] {\n if (v === undefined) { return this._data; }\n this._data = (null != v) ? v : [];\n this.redraw();\n\n return this;\n }\n\n /*\n * Getter for the event dispatcher\n */\n dispatch() { return this._dispatch }\n\n hoverHandler(): HexbinHoverHandler;\n hoverHandler(v: HexbinHoverHandler): this;\n hoverHandler(v?: HexbinHoverHandler): this | HexbinHoverHandler {\n if (v === undefined) { return this._hoverHandler; }\n this._hoverHandler = (null != v) ? v : HexbinHoverHandler.none();\n\n this.redraw();\n\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 const that = this;\n\n // Map the data into an array of latLngs using the configured lat/lng accessors\n return this._data.map(function (d) {\n return L.latLng(that._fn.lat(d), that._fn.lng(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(options?: HexbinLayerConfig) {\n return new HexbinLayer(options);\n}\n\n\n"],"names":["HexbinHoverHandler","tooltip","options","d","d3","svg","hexLayer","event","data","gCoords","div","h","w","resizeFill","resizeScale","radiusScale","compound","handlers","none","HexbinHoverHandler$1","HexbinLayer","L","val","scaleLinear","dispatch","hexbin","x","_","y","select","map","latlng","that","point","join","enterUpdate","from","to","length","step","i","g","thisLayer","size","bounds","bins","colorExtent","radiusExtent","opacityExtent","colorDomain","radiusDomain","container","hexagons","exit","valueFn","scaleExtent","ext","extent","v","hexbinLayer"],"mappings":";;;;AASiB,IAAAA;AAAA,CAAV,CAAUA,MAAV;AAME,WAASC,EAAQC,IAA0B,EAAE,eAAeC,GAAG;AAAS,WAAA,UAAUA,EAAE,MAAM;AAAA,EAAA,KAA4B;AAGrHF,UAAAA,IAAUG,EAAG,OAAO,MAAM,EAAE,OAAO,KAAK,EAC3C,KAAK,SAAS,gBAAgB,EAC9B,MAAM,WAAW,IAAI,EACrB,MAAM,kBAAkB,MAAM,EAC9B,MAAM,cAAc,QAAQ,EAC5B,MAAM,YAAY,OAAO;AAE5BH,WAAAA,EAAQ,OAAO,KAAK,EAAE,KAAK,SAAS,iBAAiB,GAG9C;AAAA,MACL,WAAW,SAAUI,GAAqBC,GAAuBC,GAAmBC,GAAoB;AAChG,cAAAC,IAAUL,EAAG,QAAQG,CAAK;AAEhCN,QAAAA,EACG,MAAM,cAAc,SAAS,EAC7B,KAAKC,EAAQ,eAAeM,GAAMF,CAAQ,CAAC;AAGxC,cAAAI,IAAMT,EAAQ,KAAK;AACzB,YAAI,CAACS,GAAK;AACR,kBAAQ,KAAK,wCAAwC;AACrD;AAAA,QAAA;AAEF,cAAMC,IAAID,EAAI,cAAcE,IAAIF,EAAI;AAEpCT,QAAAA,EACG,MAAM,OAAOM,EAAM,UAAUE,EAAQ,CAAC,IAAIE,IAAI,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AAA,GAAc,CAAC;AAAA,IAAA,CAC5D;AAAA,EAAA;AAEL;AAKO,SAASsC,EAAYzD,GAA6B;AAChD,SAAA,IAAIkB,EAAYlB,CAAO;AAChC;"}
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\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\nexport namespace HexbinHoverHandler {\n\n interface TooltipOptions<Data> {\n tooltipContent: (d: HexbinData<Data>[], hexLayer: HexbinLayer<Data>) => string;\n }\n\n export function tooltip<Data>(options: TooltipOptions<Data> = { tooltipContent(d) { return `Count: ${d.length}` } }): HexbinHoverHandler<Data> {\n\n // Generate the tooltip\n const tooltip = d3.select('body').append('div')\n .attr('class', 'hexbin-tooltip')\n .style('z-index', 9999)\n .style('pointer-events', 'none')\n .style('visibility', 'hidden')\n .style('position', 'fixed');\n\n tooltip.append('div').attr('class', 'tooltip-content');\n\n // return the handler instance\n return {\n mouseover: function (svg: SVGPathElement, hexLayer: HexbinLayer<Data>, event: MouseEvent, data: HexbinData<Data>[]) {\n const gCoords = d3.pointer(event);\n\n tooltip\n .style('visibility', 'visible')\n .html(options.tooltipContent(data, hexLayer));\n\n\n const div = tooltip.node();\n if (!div) {\n console.warn(\"Leaflet hexbin: tooltip node not found\");\n return\n }\n const h = div.clientHeight, w = div.clientWidth;\n\n tooltip\n .style('top', event.clientY - gCoords[1] - h - 16 + 'px')\n .style('left', event.clientX - gCoords[0] - w / 2 + 'px');\n\n },\n mouseout: function (svg, hexLayer: HexbinLayer<Data>, event: MouseEvent, data: HexbinData<Data>[]) {\n tooltip\n .style('visibility', 'hidden')\n .html();\n }\n };\n\n }\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 .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 .attr('d', function (d) {\n return hexLayer._hexLayout.hexagon(hexLayer._scale.radius(hexLayer._fn.radiusValue.call(hexLayer, d)));\n });\n }\n };\n\n }\n\n export interface ResizeScaleOptions {\n radiusScale?: number;\n duration?: number;\n }\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._scale.radius.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._scale.radius(hexLayer._fn.radiusValue.call(hexLayer, d)));\n });\n }\n };\n }\n\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 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// Need to expose some methods from L.SVG\ndeclare module 'leaflet' {\n interface SVG {\n _initContainer(): void;\n _container: SVGElementTagNameMap['svg']\n }\n}\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/**\n * Hexbin data attached to each hexagon, once binned.\n */\nexport type HexbinData<Data> = {\n data: Data;\n coord: L.LatLngExpression;\n point: Readonly<[number, number]>;\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 * Instantiate a hexbin layer.\n * Extends L.SVG to take advantage of built-in zoom animations.\n */\nexport class HexbinLayer<Data = L.LatLngExpression> extends L.SVG {\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 // Handle parent default options\n // ...L.SVG.prototype.options,\n ...L.Renderer.prototype.options,\n ...L.Layer.prototype.options\n }\n _fn = {\n lng: (d: Data) => L.latLng(this._accessor(d)).lng,\n lat: (d: Data) => L.latLng(this._accessor(d)).lat,\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 // Set up the customizable scale\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 _dispatch = dispatch<SVGPathElement>('mouseover', 'mouseout', 'click');\n\n // Set up the default hover handler\n _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 _data = Array<Data>()\n\n\n declare _map: L.Map;\n declare _container: SVGElementTagNameMap['svg'];\n\n // declare _container: HTMLElement;\n declare _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 _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 // Redraw on moveend\n map.on('moveend', this.redraw, this);\n // Initial draw\n this.redraw();\n return this\n }\n\n _project(latlng: L.LatLngExpression) {\n const { x, y } = this._map.latLngToLayerPoint(latlng);\n return [x, y] as const;\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 * @private\n */\n _destroyContainer() {\n select(this._container).remove();\n }\n\n /**\n * (Re)draws the hexbins data on the container\n * @private\n */\n 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._project(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 _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 const c = 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 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._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 thisLayer._dispatch.call('click', this, data, thisLayer, ev);\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 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 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 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 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 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 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 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 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 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 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 lng(): (d: Data) => number;\n lng(v: (d: Data) => number): this;\n lng(v?: (d: Data) => number) {\n if (v === undefined) { return this._fn.lng; }\n this._fn.lng = v;\n\n return this;\n }\n\n lat(): (d: Data) => number;\n lat(v: (d: Data) => number): this;\n lat(v?: (d: Data) => number) {\n if (v === undefined) { return this._fn.lat; }\n this._fn.lat = v;\n\n return this;\n }\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 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 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 // data(): Data[];\n // data(v: (Data & L.LatLngExpression)[]): this;\n // data(v: Data[], accessor?: (d: Data) => L.LatLngExpression): this;\n\n // data(v?: L.LatLngExpression[], accessor?: Data extends L.LatLngExpression ? undefined : (d: Data) => L.LatLngExpression): this | Data[] {\n // if (v === undefined) { return this._data; }\n // this._data = (null != v) ? v : [];\n // this.redraw();\n\n // return this;\n // }\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 this.redraw();\n return this;\n }\n\n /*\n * Getter for the event dispatcher\n */\n dispatch() { return this._dispatch }\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 this.redraw();\n\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 const that = this;\n\n // Map the data into an array of latLngs using the configured lat/lng accessors\n return this._data.map(function (d) {\n return L.latLng(that._fn.lat(d), that._fn.lng(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","tooltip","options","d","d3","svg","hexLayer","event","data","gCoords","div","h","w","resizeFill","resizeScale","radiusScale","compound","handlers","none","HexbinHoverHandler$1","isLatLngExpression","L","HexbinLayer","val","scaleLinear","dispatch","hexbin","x","_","y","select","map","latlng","that","coord","point","join","enterUpdate","from","to","length","step","i","g","thisLayer","size","bounds","bins","colorExtent","radiusExtent","opacityExtent","colorDomain","radiusDomain","container","hexagons","ev","exit","valueFn","scaleExtent","ext","extent","v","accessor","hexbinLayer"],"mappings":";;;;AASiB,IAAAA;AAAA,CAAV,CAAUA,MAAV;AAME,WAASC,EAAcC,IAAgC,EAAE,eAAeC,GAAG;AAAS,WAAA,UAAUA,EAAE,MAAM;AAAA,EAAA,KAAkC;AAGvIF,UAAAA,IAAUG,EAAG,OAAO,MAAM,EAAE,OAAO,KAAK,EAC3C,KAAK,SAAS,gBAAgB,EAC9B,MAAM,WAAW,IAAI,EACrB,MAAM,kBAAkB,MAAM,EAC9B,MAAM,cAAc,QAAQ,EAC5B,MAAM,YAAY,OAAO;AAE5BH,WAAAA,EAAQ,OAAO,KAAK,EAAE,KAAK,SAAS,iBAAiB,GAG9C;AAAA,MACL,WAAW,SAAUI,GAAqBC,GAA6BC,GAAmBC,GAA0B;AAC5G,cAAAC,IAAUL,EAAG,QAAQG,CAAK;AAEhCN,QAAAA,EACG,MAAM,cAAc,SAAS,EAC7B,KAAKC,EAAQ,eAAeM,GAAMF,CAAQ,CAAC;AAGxC,cAAAI,IAAMT,EAAQ,KAAK;AACzB,YAAI,CAACS,GAAK;AACR,kBAAQ,KAAK,wCAAwC;AACrD;AAAA,QAAA;AAEF,cAAMC,IAAID,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ACL;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA,EAMT,WAAW;AAAE,WAAO,KAAK;AAAA,EAAA;AAAA,EAIzB,aAAa0D,GAA+D;AAC1E,WAAIA,MAAM,SAAoB,KAAK,iBACnC,KAAK,gBAAyBA,KAAS7D,EAAmB,KAAK,GAE/D,KAAK,OAAO,GAEL;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA,EAMT,aAAa;AACX,UAAMiC,IAAO;AAGb,WAAO,KAAK,MAAM,IAAI,SAAU9B,GAAG;AAC1B,aAAAkB,EAAE,OAAOY,EAAK,IAAI,IAAI9B,CAAC,GAAG8B,EAAK,IAAI,IAAI9B,CAAC,CAAC;AAAA,IAAA,CACjD;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA,EAKH,YAA2D;AAClD,WAAAkB,EAAE,QAAQ,WAAyC,MAAM;AAAA,MAC9D,MAAM;AAAA,MACN,aAAaA,EAAE,QAAQ,gBAAgB,KAAK,WAAA,GAAc,CAAC;AAAA,IAAA,CAC5D;AAAA,EAAA;AAEL;AAKO,SAAS0C,EAAuC7D,GAA6B;AAC3E,SAAA,IAAIoB,EAAkBpB,CAAO;AACtC;"}
package/dist/index.umd.js CHANGED
@@ -1,2 +1,2 @@
1
- (function(f,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("d3"),require("d3-hexbin"),require("leaflet")):typeof define=="function"&&define.amd?define(["exports","d3","d3-hexbin","leaflet"],d):(f=typeof globalThis<"u"?globalThis:f||self,d(f["leaflet-hexbin"]={},f.d3,f["d3-hexbin"],f.L))})(this,function(f,d,R,C){"use strict";function v(l){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(l){for(const n in l)if(n!=="default"){const e=Object.getOwnPropertyDescriptor(l,n);Object.defineProperty(t,n,e.get?e:{enumerable:!0,get:()=>l[n]})}}return t.default=l,Object.freeze(t)}const m=v(d),_=v(C);var L;(l=>{function t(a={tooltipContent(o){return`Count: ${o.length}`}}){const o=m.select("body").append("div").attr("class","hexbin-tooltip").style("z-index",9999).style("pointer-events","none").style("visibility","hidden").style("position","fixed");return o.append("div").attr("class","tooltip-content"),{mouseover:function(s,p,c,h){const g=m.pointer(c);o.style("visibility","visible").html(a.tooltipContent(h,p));const x=o.node();if(!x){console.warn("Leaflet hexbin: tooltip node not found");return}const b=x.clientHeight,S=x.clientWidth;o.style("top",c.clientY-g[1]-b-16+"px").style("left",c.clientX-g[0]-S/2+"px")},mouseout:function(s,p,c,h){o.style("visibility","hidden").html()}}}l.tooltip=t;function n(){return{mouseover:function(a,o,s,p){m.select(a.parentElement).select("path.hexbin-hexagon").attr("d",function(h){return o._hexLayout.hexagon(o.options.radius)})},mouseout:function(a,o,s,p){m.select(a.parentElement).select("path.hexbin-hexagon").attr("d",function(h){return o._hexLayout.hexagon(o._scale.radius(o._fn.radiusValue.call(o,h)))})}}}l.resizeFill=n;function e(a=1.5){return{mouseover:function(o,s,p,c){m.select(o.parentElement).select("path.hexbin-hexagon").transition().duration(s.options.duration).attr("d",function(){return s._hexLayout.hexagon(s._scale.radius.range()[1]*a)})},mouseout:function(o,s,p,c){m.select(o.parentElement).select("path.hexbin-hexagon").transition().duration(s.options.duration).attr("d",g=>s._hexLayout.hexagon(s._scale.radius(s._fn.radiusValue.call(s,g))))}}}l.resizeScale=e;function u(a=[y()]){return{mouseover:function(o,s,p,c){a.forEach(h=>{h.mouseover(o,s,p,c)})},mouseout:function(o,s,p,c){a.forEach(h=>{h.mouseout(o,s,p,c)})}}}l.compound=u;function y(){return{mouseover:function(){},mouseout:function(){}}}l.none=y})(L||(L={}));const E=L;class V extends _.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",..._.Renderer.prototype.options,..._.Layer.prototype.options},this._fn={lng:n=>_.latLng(n).lng,lat:n=>_.latLng(n).lat,colorValue:n=>n.length,radiusValue:n=>n.length,opacityValue:n=>n.length,fill:n=>{const e=this._fn.colorValue(n);return e!=null?this._scale.color(e):"none"}},this._scale={color:d.scaleLinear(),radius:d.scaleLinear(),opacity:d.scaleLinear()},this._dispatch=d.dispatch("mouseover","mouseout","click"),this._hoverHandler=E.none(),this._hexLayout=R.hexbin().radius(this.options.radius).x(({point:[n,e]})=>n).y(({point:[n,e]})=>e),this._data=Array(),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)}_initContainer(){super._initContainer(),this._d3Container=d.select(this._container).select("g")}onAdd(t){return super.onAdd(t),this._map=t,t.on("moveend",this.redraw,this),this.redraw(),this}_project(t){const{x:n,y:e}=this._map.latLngToLayerPoint(t);return[n,e]}onRemove(t){return this._destroyContainer(),t.off("moveend",this.redraw,this),this}_destroyContainer(){d.select(this._container).remove()}redraw(){const t=this;if(!t._map)return;const n=t._data.map(a=>{const o=t._project(a);return{o:a,point:o}}),e=this._d3Container.selectAll("g.hexbin").data([this._map.getZoom()],a=>a),y=e.enter().append("g").attr("class",function(a){return"hexbin zoom-"+a}).merge(e);e.exit().remove(),this._createHexagons(y,n)}_linearlySpace(t,n,e){const u=(n-t)/Math.max(e-1,1);return Array.from({length:e},(y,a)=>t+a*u)}_createHexagons(t,n){const e=this,u=e._map.getSize(),y=e._map.getBounds().pad(e.options.radius*2/Math.max(u.x,u.y)),a=e._hexLayout(n).filter(({x:i,y:r})=>y.contains(e._map.layerPointToLatLng(_.point(i,r)))),o=e._getExtent(a,e._fn.colorValue,e.options.colorScaleExtent),s=e._getExtent(a,e._fn.radiusValue,e.options.radiusScaleExtent),p=e._getExtent(a,e._fn.opacityValue,e.options.opacityScaleExtent),c=this.options.colorDomain??e._linearlySpace(o[0],o[1],e._scale.color.range().length),h=this.options.radiusDomain||s;e._scale.color.domain(c),e._scale.radius.domain(h),e._scale.opacity.domain(p);const g=t.selectAll("g.hexbin-container").data(a,({x:i,y:r})=>`${i}:${r}`);g.select("path.hexbin-hexagon").transition().duration(e.options.duration).attr("fill",e._fn.fill.bind(e)).attr("fill-opacity",i=>e._scale.opacity(e._fn.opacityValue.call(e,i))).attr("stroke-opacity",i=>e._scale.opacity(e._fn.opacityValue.call(e,i))).attr("d",i=>e._hexLayout.hexagon(e._scale.radius(e._fn.radiusValue.call(e,i))));const x=g.enter().append("g").attr("class","hexbin-container").style("pointer-events",e.options.pointerEvents);x.on("mouseover",function(i,r){d.select(this).raise()});const b=x.append("path").attr("class","hexbin-hexagon").attr("transform",({x:i,y:r})=>`translate(${i},${r})`).attr("d",()=>e._hexLayout.hexagon(e._scale.radius.range()[0])).attr("fill",e._fn.fill.bind(e)).attr("fill-opacity",.01).attr("stroke-opacity",.01).style("pointer-events","all");b.transition().duration(e.options.duration).attr("fill-opacity",i=>e._scale.opacity(e._fn.opacityValue.call(e,i))).attr("stroke-opacity",i=>e._scale.opacity(e._fn.opacityValue.call(e,i))).attr("d",i=>e._hexLayout.hexagon(e._scale.radius(e._fn.radiusValue.call(e,i)))).style("pointer-events","all"),x.append("path").attr("class","hexbin-grid").attr("transform",({x:i,y:r})=>`translate(${i},${r})`).attr("d",()=>e._hexLayout.hexagon(e.options.radius)).attr("fill","none").attr("stroke","none"),b.on("mouseover",function(i,r){e._hoverHandler.mouseover(this,e,i,r),e._dispatch.call("mouseover",this,i,r),this.classList.add("hover")}).on("mouseout",function(i,r){e._hoverHandler.mouseout(this,e,i,r),e._dispatch.call("mouseout",this,e,i,r),this.classList.remove("hover")}).on("click",function(i,r){e._dispatch.call("click",this,e,i,r)});const S=g.exit();S.select("path.hexbin-hexagon").transition().duration(e.options.duration).attr("fill-opacity",0).attr("stroke-opacity",0).attr("d",i=>e._hexLayout.hexagon(0)),S.transition().duration(e.options.duration).remove()}_getExtent(t,n,e){let u=d.extent(t,n.bind(this));return(u[0]===void 0||u[1]===void 0)&&(u=[0,0]),e[0]!=null&&(u[0]=e[0]),e[1]!=null&&(u[1]=e[1]),u}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)}lng(t){return t===void 0?this._fn.lng:(this._fn.lng=t,this)}lat(t){return t===void 0?this._fn.lat:(this._fn.lat=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){return t===void 0?this._data:(this._data=t??[],this.redraw(),this)}dispatch(){return this._dispatch}hoverHandler(t){return t===void 0?this._hoverHandler:(this._hoverHandler=t??E.none(),this.redraw(),this)}getLatLngs(){const t=this;return this._data.map(function(n){return _.latLng(t._fn.lat(n),t._fn.lng(n))})}toGeoJSON(){return _.GeoJSON.getFeature(this,{type:"MultiPoint",coordinates:_.GeoJSON.latLngsToCoords(this.getLatLngs(),0)})}}function j(l){return new V(l)}f.HexbinHoverHandler=E,f.HexbinLayer=V,f.hexbinLayer=j,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})});
1
+ (function(f,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("d3"),require("d3-hexbin"),require("leaflet")):typeof define=="function"&&define.amd?define(["exports","d3","d3-hexbin","leaflet"],d):(f=typeof globalThis<"u"?globalThis:f||self,d(f["leaflet-hexbin"]={},f.d3,f["d3-hexbin"],f.L))})(this,function(f,d,R,j){"use strict";function v(s){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const n in s)if(n!=="default"){const e=Object.getOwnPropertyDescriptor(s,n);Object.defineProperty(t,n,e.get?e:{enumerable:!0,get:()=>s[n]})}}return t.default=s,Object.freeze(t)}const m=v(d),_=v(j);var E;(s=>{function t(a={tooltipContent(i){return`Count: ${i.length}`}}){const i=m.select("body").append("div").attr("class","hexbin-tooltip").style("z-index",9999).style("pointer-events","none").style("visibility","hidden").style("position","fixed");return i.append("div").attr("class","tooltip-content"),{mouseover:function(r,p,c,h){const g=m.pointer(c);i.style("visibility","visible").html(a.tooltipContent(h,p));const x=i.node();if(!x){console.warn("Leaflet hexbin: tooltip node not found");return}const b=x.clientHeight,L=x.clientWidth;i.style("top",c.clientY-g[1]-b-16+"px").style("left",c.clientX-g[0]-L/2+"px")},mouseout:function(r,p,c,h){i.style("visibility","hidden").html()}}}s.tooltip=t;function n(){return{mouseover:function(a,i,r,p){m.select(a.parentElement).select("path.hexbin-hexagon").attr("d",function(h){return i._hexLayout.hexagon(i.options.radius)})},mouseout:function(a,i,r,p){m.select(a.parentElement).select("path.hexbin-hexagon").attr("d",function(h){return i._hexLayout.hexagon(i._scale.radius(i._fn.radiusValue.call(i,h)))})}}}s.resizeFill=n;function e(a=1.5){return{mouseover:function(i,r,p,c){m.select(i.parentElement).select("path.hexbin-hexagon").transition().duration(r.options.duration).attr("d",function(){return r._hexLayout.hexagon(r._scale.radius.range()[1]*a)})},mouseout:function(i,r,p,c){m.select(i.parentElement).select("path.hexbin-hexagon").transition().duration(r.options.duration).attr("d",g=>r._hexLayout.hexagon(r._scale.radius(r._fn.radiusValue.call(r,g))))}}}s.resizeScale=e;function l(a=[y()]){return{mouseover:function(i,r,p,c){a.forEach(h=>{h.mouseover(i,r,p,c)})},mouseout:function(i,r,p,c){a.forEach(h=>{h.mouseout(i,r,p,c)})}}}s.compound=l;function y(){return{mouseover:function(){},mouseout:function(){}}}s.none=y})(E||(E={}));const S=E;function C(s){return s instanceof _.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 V extends _.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",..._.Renderer.prototype.options,..._.Layer.prototype.options},this._fn={lng:n=>_.latLng(this._accessor(n)).lng,lat:n=>_.latLng(this._accessor(n)).lat,colorValue:n=>n.length,radiusValue:n=>n.length,opacityValue:n=>n.length,fill:n=>{const e=this._fn.colorValue(n);return e!=null?this._scale.color(e):"none"}},this._scale={color:d.scaleLinear(),radius:d.scaleLinear(),opacity:d.scaleLinear()},this._dispatch=d.dispatch("mouseover","mouseout","click"),this._hoverHandler=S.none(),this._hexLayout=R.hexbin().radius(this.options.radius).x(({point:[n,e]})=>n).y(({point:[n,e]})=>e),this._data=Array(),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=d.select(this._container).select("g")}onAdd(t){return super.onAdd(t),this._map=t,t.on("moveend",this.redraw,this),this.redraw(),this}_project(t){const{x:n,y:e}=this._map.latLngToLayerPoint(t);return[n,e]}onRemove(t){return this._destroyContainer(),t.off("moveend",this.redraw,this),this}_destroyContainer(){d.select(this._container).remove()}redraw(){const t=this;if(!t._map)return;const n=t._data.map(a=>{const i=t._accessor(a),r=t._project(i);return{coord:i,point:r,data:a}}),e=this._d3Container.selectAll("g.hexbin").data([this._map.getZoom()],a=>a),y=e.enter().append("g").attr("class",function(a){return"hexbin zoom-"+a}).merge(e);e.exit().remove(),this._createHexagons(y,n)}_linearlySpace(t,n,e){const l=(n-t)/Math.max(e-1,1);return Array.from({length:e},(y,a)=>t+a*l)}_createHexagons(t,n){const e=this,l=e._map.getSize(),y=e._map.getBounds().pad(e.options.radius*2/Math.max(l.x,l.y)),a=e._hexLayout(n).filter(({x:o,y:u})=>y.contains(e._map.layerPointToLatLng(_.point(o,u)))),i=e._getExtent(a,e._fn.colorValue,e.options.colorScaleExtent),r=e._getExtent(a,e._fn.radiusValue,e.options.radiusScaleExtent),p=e._getExtent(a,e._fn.opacityValue,e.options.opacityScaleExtent),c=this.options.colorDomain??e._linearlySpace(i[0],i[1],e._scale.color.range().length),h=this.options.radiusDomain||r;e._scale.color.domain(c),e._scale.radius.domain(h),e._scale.opacity.domain(p);const g=t.selectAll("g.hexbin-container").data(a,({x:o,y:u})=>`${o}:${u}`);g.select("path.hexbin-hexagon").transition().duration(e.options.duration).attr("fill",e._fn.fill.bind(e)).attr("fill-opacity",o=>e._scale.opacity(e._fn.opacityValue.call(e,o))).attr("stroke-opacity",o=>e._scale.opacity(e._fn.opacityValue.call(e,o))).attr("d",o=>e._hexLayout.hexagon(e._scale.radius(e._fn.radiusValue.call(e,o))));const x=g.enter().append("g").attr("class","hexbin-container").style("pointer-events",e.options.pointerEvents);x.on("mouseover",function(o,u){d.select(this).raise()});const b=x.append("path").attr("class","hexbin-hexagon").attr("transform",({x:o,y:u})=>`translate(${o},${u})`).attr("d",()=>e._hexLayout.hexagon(e._scale.radius.range()[0])).attr("fill",e._fn.fill.bind(e)).attr("fill-opacity",.01).attr("stroke-opacity",.01).style("pointer-events","all");b.transition().duration(e.options.duration).attr("fill-opacity",o=>e._scale.opacity(e._fn.opacityValue.call(e,o))).attr("stroke-opacity",o=>e._scale.opacity(e._fn.opacityValue.call(e,o))).attr("d",o=>e._hexLayout.hexagon(e._scale.radius(e._fn.radiusValue.call(e,o)))).style("pointer-events","all"),x.append("path").attr("class","hexbin-grid").attr("transform",({x:o,y:u})=>`translate(${o},${u})`).attr("d",()=>e._hexLayout.hexagon(e.options.radius)).attr("fill","none").attr("stroke","none"),b.on("mouseover",function(o,u){e._hoverHandler.mouseover(this,e,o,u),e._dispatch.call("mouseover",this,u,e,o),this.classList.add("hover")}).on("mouseout",function(o,u){e._hoverHandler.mouseout(this,e,o,u),e._dispatch.call("mouseout",this,u,e,o),this.classList.remove("hover")}).on("click",function(o,u){e._dispatch.call("click",this,u,e,o)});const L=g.exit();L.select("path.hexbin-hexagon").transition().duration(e.options.duration).attr("fill-opacity",0).attr("stroke-opacity",0).attr("d",o=>e._hexLayout.hexagon(0)),L.transition().duration(e.options.duration).remove()}_getExtent(t,n,e){let l=d.extent(t,n.bind(this));return(l[0]===void 0||l[1]===void 0)&&(l=[0,0]),e[0]!=null&&(l[0]=e[0]),e[1]!=null&&(l[1]=e[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)}lng(t){return t===void 0?this._fn.lng:(this._fn.lng=t,this)}lat(t){return t===void 0?this._fn.lat:(this._fn.lat=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,n){return t===void 0?this._data:(!C(t[0])&&!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"),this._data=t??[],this._accessor=n??(e=>e),this.redraw(),this)}dispatch(){return this._dispatch}hoverHandler(t){return t===void 0?this._hoverHandler:(this._hoverHandler=t??S.none(),this.redraw(),this)}getLatLngs(){const t=this;return this._data.map(function(n){return _.latLng(t._fn.lat(n),t._fn.lng(n))})}toGeoJSON(){return _.GeoJSON.getFeature(this,{type:"MultiPoint",coordinates:_.GeoJSON.latLngsToCoords(this.getLatLngs(),0)})}}function w(s){return new V(s)}f.HexbinHoverHandler=S,f.HexbinLayer=V,f.hexbinLayer=w,Object.defineProperty(f,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\nexport interface HexbinHoverHandler {\n mouseover(svg: SVGPathElement, hexLayer: HexbinLayer, event: MouseEvent, data: HexbinData[]): void;\n mouseout(svg: SVGPathElement, hexLayer: HexbinLayer, event: MouseEvent, data: HexbinData[]): void;\n}\n\nexport namespace HexbinHoverHandler {\n\n interface TooltipOptions {\n tooltipContent: (d: HexbinData[], hexLayer: HexbinLayer) => string;\n }\n\n export function tooltip(options: TooltipOptions = { tooltipContent(d) { return `Count: ${d.length}` } }): HexbinHoverHandler {\n\n // Generate the tooltip\n const tooltip = d3.select('body').append('div')\n .attr('class', 'hexbin-tooltip')\n .style('z-index', 9999)\n .style('pointer-events', 'none')\n .style('visibility', 'hidden')\n .style('position', 'fixed');\n\n tooltip.append('div').attr('class', 'tooltip-content');\n\n // return the handler instance\n return {\n mouseover: function (svg: SVGPathElement, hexLayer: HexbinLayer, event: MouseEvent, data: HexbinData[]) {\n const gCoords = d3.pointer(event);\n\n tooltip\n .style('visibility', 'visible')\n .html(options.tooltipContent(data, hexLayer));\n\n\n const div = tooltip.node();\n if (!div) {\n console.warn(\"Leaflet hexbin: tooltip node not found\");\n return\n }\n const h = div.clientHeight, w = div.clientWidth;\n\n tooltip\n .style('top', event.clientY - gCoords[1] - h - 16 + 'px')\n .style('left', event.clientX - gCoords[0] - w / 2 + 'px');\n\n },\n mouseout: function (svg, hexLayer: HexbinLayer, event: MouseEvent, data: HexbinData[]) {\n tooltip\n .style('visibility', 'hidden')\n .html();\n }\n };\n\n }\n\n export function resizeFill(): HexbinHoverHandler {\n return {\n mouseover: function (svg: SVGPathElement, hexLayer: HexbinLayer, event: MouseEvent, data: HexbinData[]) {\n const o = d3.select<HTMLElement | null, HexbinData[]>(svg.parentElement);\n o.select('path.hexbin-hexagon')\n .attr('d', function (d) {\n return hexLayer._hexLayout.hexagon(hexLayer.options.radius);\n });\n },\n mouseout: function (svg: SVGPathElement, hexLayer: HexbinLayer, event: MouseEvent, data: HexbinData[]) {\n const o = d3.select<HTMLElement | null, HexbinData[]>(svg.parentElement);\n o.select<SVGPathElement>('path.hexbin-hexagon')\n .attr('d', function (d) {\n return hexLayer._hexLayout.hexagon(hexLayer._scale.radius(hexLayer._fn.radiusValue.call(hexLayer, d)));\n });\n }\n };\n\n }\n\n export interface ResizeScaleOptions {\n radiusScale?: number;\n duration?: number;\n }\n\n export function resizeScale(radiusScale: number = 1.5): HexbinHoverHandler {\n\n // return the handler instance\n return {\n mouseover: function (svg, hexLayer, event, data) {\n const o = d3.select<HTMLElement | null, HexbinData[]>(svg.parentElement);\n o.select('path.hexbin-hexagon')\n .transition().duration(hexLayer.options.duration)\n .attr('d', function () {\n return hexLayer._hexLayout.hexagon(hexLayer._scale.radius.range()[1] * (radiusScale));\n });\n },\n mouseout: function (svg, hexLayer, event, data) {\n const o = d3.select<HTMLElement | null, HexbinData[]>(svg.parentElement!);\n o.select('path.hexbin-hexagon')\n .transition().duration(hexLayer.options.duration)\n .attr('d', (d) => {\n return hexLayer._hexLayout.hexagon(hexLayer._scale.radius(hexLayer._fn.radiusValue.call(hexLayer, d)));\n });\n }\n };\n }\n\n\n export function compound(handlers: HexbinHoverHandler[] = [none()]): HexbinHoverHandler {\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 export function none(): HexbinHoverHandler {\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// Need to expose some methods from L.SVG\ndeclare module 'leaflet' {\n interface SVG {\n _initContainer(): void;\n _container: SVGElementTagNameMap['svg']\n }\n}\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/**\n * Hexbin data attached to each hexagon, once binned.\n */\nexport type HexbinData = {\n o: L.LatLngExpression;\n point: Readonly<[number, number]>;\n}\n\n\n/**\n * Instantiate a hexbin layer.\n * Extends L.SVG to take advantage of built-in zoom animations.\n */\nexport class HexbinLayer extends L.SVG implements HexbinLayer {\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 // Handle parent default options\n // ...L.SVG.prototype.options,\n ...L.Renderer.prototype.options,\n ...L.Layer.prototype.options\n }\n _fn = {\n lng: (d: L.LatLngExpression) => L.latLng(d).lng,\n lat: (d: L.LatLngExpression) => L.latLng(d).lat,\n colorValue: (d: HexbinData[]) => d.length,\n radiusValue: (d: HexbinData[]) => d.length,\n opacityValue: (d: HexbinData[]) => d.length,\n fill: (d: HexbinData[]) => {\n const val = this._fn.colorValue(d);\n return (null != val) ? this._scale.color(val) : 'none';\n }\n }\n // Set up the customizable scale\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 _dispatch = dispatch<SVGPathElement>('mouseover', 'mouseout', 'click');\n\n // Set up the default hover handler\n _hoverHandler: HexbinHoverHandler = HexbinHoverHandler.none();\n\n // Create the hex layout\n _hexLayout = hexbin<HexbinData>()\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 _data = Array<L.LatLngExpression>()\n\n declare _map: L.Map;\n declare _container: SVGElementTagNameMap['svg'];\n\n // declare _container: HTMLElement;\n declare _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 /**\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 // Redraw on moveend\n map.on('moveend', this.redraw, this);\n // Initial draw\n this.redraw();\n return this\n }\n\n _project(latlng: L.LatLngExpression) {\n const { x, y } = this._map.latLngToLayerPoint(latlng);\n return [x, y] as const;\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 * @private\n */\n _destroyContainer() {\n select(this._container).remove();\n }\n\n /**\n * (Re)draws the hexbins data on the container\n * @private\n */\n 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>((d) => {\n const point = that._project(d);\n return { o: d, point };\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 _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[]) {\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>>('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 const c = select<SVGGElement, HexbinBin<HexbinData>>(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, d: MouseEvent, i) {\n thisLayer._hoverHandler.mouseover(this, thisLayer as HexbinLayer, d, i);\n thisLayer._dispatch.call('mouseover', this, d, i);\n this.classList.add('hover')\n })\n .on('mouseout', function (this: SVGPathElement, d: MouseEvent, i) {\n thisLayer._hoverHandler.mouseout(this, thisLayer as HexbinLayer, d, i);\n thisLayer._dispatch.call('mouseout', this, thisLayer as HexbinLayer, d, i);\n this.classList.remove('hover')\n })\n .on('click', function (this, d, i) {\n thisLayer._dispatch.call('click', this, thisLayer as HexbinLayer, d, i);\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>[],\n valueFn: (d: HexbinBin<HexbinData>) => number,\n scaleExtent: [number, number | undefined]\n ): [number, number] {\n\n // Determine the extent of the values\n let ext = extent<HexbinBin<HexbinData>, 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 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 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 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 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 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 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 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 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 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 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 lng(): (d: L.LatLngExpression) => number;\n lng(v: (d: L.LatLngExpression) => number): this;\n lng(v?: (d: L.LatLngExpression) => number) {\n if (v === undefined) { return this._fn.lng; }\n this._fn.lng = v;\n\n return this;\n }\n\n lat(): (d: L.LatLngExpression) => number;\n lat(v: (d: L.LatLngExpression) => number): this;\n lat(v?: (d: L.LatLngExpression) => number) {\n if (v === undefined) { return this._fn.lat; }\n this._fn.lat = v;\n\n return this;\n }\n\n colorValue(): (d: HexbinData[]) => number;\n colorValue(v: (d: HexbinData[]) => number): this;\n colorValue(v?: (d: HexbinData[]) => number) {\n if (v === undefined) { return this._fn.colorValue; }\n this._fn.colorValue = v;\n\n return this;\n }\n\n radiusValue(): (d: HexbinData[]) => number;\n radiusValue(v: (d: HexbinData[]) => number): this;\n radiusValue(v?: (d: HexbinData[]) => number) {\n if (v === undefined) { return this._fn.radiusValue; }\n this._fn.radiusValue = v;\n\n return this;\n }\n\n fill(): (d: HexbinData[]) => string;\n fill(v: (d: HexbinData[]) => string): this;\n fill(v?: (d: HexbinData[]) => string) {\n if (v === undefined) { return this._fn.fill; }\n this._fn.fill = v;\n\n return this;\n }\n\n data(): L.LatLngExpression[];\n data(v: L.LatLngExpression[]): this;\n data(v?: L.LatLngExpression[]): this | L.LatLngExpression[] {\n if (v === undefined) { return this._data; }\n this._data = (null != v) ? v : [];\n this.redraw();\n\n return this;\n }\n\n /*\n * Getter for the event dispatcher\n */\n dispatch() { return this._dispatch }\n\n hoverHandler(): HexbinHoverHandler;\n hoverHandler(v: HexbinHoverHandler): this;\n hoverHandler(v?: HexbinHoverHandler): this | HexbinHoverHandler {\n if (v === undefined) { return this._hoverHandler; }\n this._hoverHandler = (null != v) ? v : HexbinHoverHandler.none();\n\n this.redraw();\n\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 const that = this;\n\n // Map the data into an array of latLngs using the configured lat/lng accessors\n return this._data.map(function (d) {\n return L.latLng(that._fn.lat(d), that._fn.lng(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(options?: HexbinLayerConfig) {\n return new HexbinLayer(options);\n}\n\n\n"],"names":["HexbinHoverHandler","tooltip","options","d","d3","svg","hexLayer","event","data","gCoords","div","h","w","resizeFill","resizeScale","radiusScale","compound","handlers","none","HexbinHoverHandler$1","HexbinLayer","L","val","scaleLinear","dispatch","hexbin","x","_","y","select","map","latlng","that","point","join","enterUpdate","from","to","length","step","i","g","thisLayer","size","bounds","bins","colorExtent","radiusExtent","opacityExtent","colorDomain","radiusDomain","container","hexagons","exit","valueFn","scaleExtent","ext","extent","v","hexbinLayer"],"mappings":"ynBASiB,IAAAA,GAAAA,GAAV,CAME,SAASC,EAAQC,EAA0B,CAAE,eAAeC,EAAG,CAAS,MAAA,UAAUA,EAAE,MAAM,EAAA,GAA4B,CAGrHF,MAAAA,EAAUG,EAAG,OAAO,MAAM,EAAE,OAAO,KAAK,EAC3C,KAAK,QAAS,gBAAgB,EAC9B,MAAM,UAAW,IAAI,EACrB,MAAM,iBAAkB,MAAM,EAC9B,MAAM,aAAc,QAAQ,EAC5B,MAAM,WAAY,OAAO,EAE5BH,OAAAA,EAAQ,OAAO,KAAK,EAAE,KAAK,QAAS,iBAAiB,EAG9C,CACL,UAAW,SAAUI,EAAqBC,EAAuBC,EAAmBC,EAAoB,CAChG,MAAAC,EAAUL,EAAG,QAAQG,CAAK,EAEhCN,EACG,MAAM,aAAc,SAAS,EAC7B,KAAKC,EAAQ,eAAeM,EAAMF,CAAQ,CAAC,EAGxC,MAAAI,EAAMT,EAAQ,KAAK,EACzB,GAAI,CAACS,EAAK,CACR,QAAQ,KAAK,wCAAwC,EACrD,MAAA,CAEF,MAAMC,EAAID,EAAI,aAAcE,EAAIF,EAAI,YAEpCT,EACG,MAAM,MAAOM,EAAM,QAAUE,EAAQ,CAAC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E,QAAQ,gBAAgB,KAAK,WAAA,EAAc,CAAC,CAAA,CAC5D,CAAA,CAEL,CAKO,SAASsC,EAAYzD,EAA6B,CAChD,OAAA,IAAIkB,EAAYlB,CAAO,CAChC"}
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\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\nexport namespace HexbinHoverHandler {\n\n interface TooltipOptions<Data> {\n tooltipContent: (d: HexbinData<Data>[], hexLayer: HexbinLayer<Data>) => string;\n }\n\n export function tooltip<Data>(options: TooltipOptions<Data> = { tooltipContent(d) { return `Count: ${d.length}` } }): HexbinHoverHandler<Data> {\n\n // Generate the tooltip\n const tooltip = d3.select('body').append('div')\n .attr('class', 'hexbin-tooltip')\n .style('z-index', 9999)\n .style('pointer-events', 'none')\n .style('visibility', 'hidden')\n .style('position', 'fixed');\n\n tooltip.append('div').attr('class', 'tooltip-content');\n\n // return the handler instance\n return {\n mouseover: function (svg: SVGPathElement, hexLayer: HexbinLayer<Data>, event: MouseEvent, data: HexbinData<Data>[]) {\n const gCoords = d3.pointer(event);\n\n tooltip\n .style('visibility', 'visible')\n .html(options.tooltipContent(data, hexLayer));\n\n\n const div = tooltip.node();\n if (!div) {\n console.warn(\"Leaflet hexbin: tooltip node not found\");\n return\n }\n const h = div.clientHeight, w = div.clientWidth;\n\n tooltip\n .style('top', event.clientY - gCoords[1] - h - 16 + 'px')\n .style('left', event.clientX - gCoords[0] - w / 2 + 'px');\n\n },\n mouseout: function (svg, hexLayer: HexbinLayer<Data>, event: MouseEvent, data: HexbinData<Data>[]) {\n tooltip\n .style('visibility', 'hidden')\n .html();\n }\n };\n\n }\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 .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 .attr('d', function (d) {\n return hexLayer._hexLayout.hexagon(hexLayer._scale.radius(hexLayer._fn.radiusValue.call(hexLayer, d)));\n });\n }\n };\n\n }\n\n export interface ResizeScaleOptions {\n radiusScale?: number;\n duration?: number;\n }\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._scale.radius.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._scale.radius(hexLayer._fn.radiusValue.call(hexLayer, d)));\n });\n }\n };\n }\n\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 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// Need to expose some methods from L.SVG\ndeclare module 'leaflet' {\n interface SVG {\n _initContainer(): void;\n _container: SVGElementTagNameMap['svg']\n }\n}\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/**\n * Hexbin data attached to each hexagon, once binned.\n */\nexport type HexbinData<Data> = {\n data: Data;\n coord: L.LatLngExpression;\n point: Readonly<[number, number]>;\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 * Instantiate a hexbin layer.\n * Extends L.SVG to take advantage of built-in zoom animations.\n */\nexport class HexbinLayer<Data = L.LatLngExpression> extends L.SVG {\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 // Handle parent default options\n // ...L.SVG.prototype.options,\n ...L.Renderer.prototype.options,\n ...L.Layer.prototype.options\n }\n _fn = {\n lng: (d: Data) => L.latLng(this._accessor(d)).lng,\n lat: (d: Data) => L.latLng(this._accessor(d)).lat,\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 // Set up the customizable scale\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 _dispatch = dispatch<SVGPathElement>('mouseover', 'mouseout', 'click');\n\n // Set up the default hover handler\n _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 _data = Array<Data>()\n\n\n declare _map: L.Map;\n declare _container: SVGElementTagNameMap['svg'];\n\n // declare _container: HTMLElement;\n declare _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 _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 // Redraw on moveend\n map.on('moveend', this.redraw, this);\n // Initial draw\n this.redraw();\n return this\n }\n\n _project(latlng: L.LatLngExpression) {\n const { x, y } = this._map.latLngToLayerPoint(latlng);\n return [x, y] as const;\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 * @private\n */\n _destroyContainer() {\n select(this._container).remove();\n }\n\n /**\n * (Re)draws the hexbins data on the container\n * @private\n */\n 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._project(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 _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 const c = 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 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._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 thisLayer._dispatch.call('click', this, data, thisLayer, ev);\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 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 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 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 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 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 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 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 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 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 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 lng(): (d: Data) => number;\n lng(v: (d: Data) => number): this;\n lng(v?: (d: Data) => number) {\n if (v === undefined) { return this._fn.lng; }\n this._fn.lng = v;\n\n return this;\n }\n\n lat(): (d: Data) => number;\n lat(v: (d: Data) => number): this;\n lat(v?: (d: Data) => number) {\n if (v === undefined) { return this._fn.lat; }\n this._fn.lat = v;\n\n return this;\n }\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 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 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 // data(): Data[];\n // data(v: (Data & L.LatLngExpression)[]): this;\n // data(v: Data[], accessor?: (d: Data) => L.LatLngExpression): this;\n\n // data(v?: L.LatLngExpression[], accessor?: Data extends L.LatLngExpression ? undefined : (d: Data) => L.LatLngExpression): this | Data[] {\n // if (v === undefined) { return this._data; }\n // this._data = (null != v) ? v : [];\n // this.redraw();\n\n // return this;\n // }\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 this.redraw();\n return this;\n }\n\n /*\n * Getter for the event dispatcher\n */\n dispatch() { return this._dispatch }\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 this.redraw();\n\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 const that = this;\n\n // Map the data into an array of latLngs using the configured lat/lng accessors\n return this._data.map(function (d) {\n return L.latLng(that._fn.lat(d), that._fn.lng(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","tooltip","options","d","d3","svg","hexLayer","event","data","gCoords","div","h","w","resizeFill","resizeScale","radiusScale","compound","handlers","none","HexbinHoverHandler$1","isLatLngExpression","L","HexbinLayer","val","scaleLinear","dispatch","hexbin","x","_","y","select","map","latlng","that","coord","point","join","enterUpdate","from","to","length","step","i","g","thisLayer","size","bounds","bins","colorExtent","radiusExtent","opacityExtent","colorDomain","radiusDomain","container","hexagons","ev","exit","valueFn","scaleExtent","ext","extent","v","accessor","hexbinLayer"],"mappings":"ynBASiB,IAAAA,GAAAA,GAAV,CAME,SAASC,EAAcC,EAAgC,CAAE,eAAeC,EAAG,CAAS,MAAA,UAAUA,EAAE,MAAM,EAAA,GAAkC,CAGvIF,MAAAA,EAAUG,EAAG,OAAO,MAAM,EAAE,OAAO,KAAK,EAC3C,KAAK,QAAS,gBAAgB,EAC9B,MAAM,UAAW,IAAI,EACrB,MAAM,iBAAkB,MAAM,EAC9B,MAAM,aAAc,QAAQ,EAC5B,MAAM,WAAY,OAAO,EAE5BH,OAAAA,EAAQ,OAAO,KAAK,EAAE,KAAK,QAAS,iBAAiB,EAG9C,CACL,UAAW,SAAUI,EAAqBC,EAA6BC,EAAmBC,EAA0B,CAC5G,MAAAC,EAAUL,EAAG,QAAQG,CAAK,EAEhCN,EACG,MAAM,aAAc,SAAS,EAC7B,KAAKC,EAAQ,eAAeM,EAAMF,CAAQ,CAAC,EAGxC,MAAAI,EAAMT,EAAQ,KAAK,EACzB,GAAI,CAACS,EAAK,CACR,QAAQ,KAAK,wCAAwC,EACrD,MAAA,CAEF,MAAMC,EAAID,EAAI,aAAcE,EAAIF,EAAI,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AA,MAAQD,GAAe,CAAC,EACxB,KAAA,UAAYC,IAAc3D,GAAYA,GAE3C,KAAK,OAAO,EACL,KAAA,CAMT,UAAW,CAAE,OAAO,KAAK,SAAA,CAIzB,aAAa0D,EAA+D,CAC1E,OAAIA,IAAM,OAAoB,KAAK,eACnC,KAAK,cAAyBA,GAAS7D,EAAmB,KAAK,EAE/D,KAAK,OAAO,EAEL,KAAA,CAMT,YAAa,CACX,MAAMiC,EAAO,KAGb,OAAO,KAAK,MAAM,IAAI,SAAU9B,EAAG,CAC1B,OAAAkB,EAAE,OAAOY,EAAK,IAAI,IAAI9B,CAAC,EAAG8B,EAAK,IAAI,IAAI9B,CAAC,CAAC,CAAA,CACjD,CAAA,CAKH,WAA2D,CAClD,OAAAkB,EAAE,QAAQ,WAAyC,KAAM,CAC9D,KAAM,aACN,YAAaA,EAAE,QAAQ,gBAAgB,KAAK,WAAA,EAAc,CAAC,CAAA,CAC5D,CAAA,CAEL,CAKO,SAAS0C,EAAuC7D,EAA6B,CAC3E,OAAA,IAAIoB,EAAkBpB,CAAO,CACtC"}
@@ -1,21 +1,21 @@
1
1
  import { HexbinData, HexbinLayer } from './HexbinLayer';
2
- export interface HexbinHoverHandler {
3
- mouseover(svg: SVGPathElement, hexLayer: HexbinLayer, event: MouseEvent, data: HexbinData[]): void;
4
- mouseout(svg: SVGPathElement, hexLayer: HexbinLayer, event: MouseEvent, data: HexbinData[]): void;
2
+ export interface HexbinHoverHandler<Data> {
3
+ mouseover(svg: SVGPathElement, hexLayer: HexbinLayer<Data>, event: MouseEvent, data: HexbinData<Data>[]): void;
4
+ mouseout(svg: SVGPathElement, hexLayer: HexbinLayer<Data>, event: MouseEvent, data: HexbinData<Data>[]): void;
5
5
  }
6
6
  export declare namespace HexbinHoverHandler {
7
- interface TooltipOptions {
8
- tooltipContent: (d: HexbinData[], hexLayer: HexbinLayer) => string;
7
+ interface TooltipOptions<Data> {
8
+ tooltipContent: (d: HexbinData<Data>[], hexLayer: HexbinLayer<Data>) => string;
9
9
  }
10
- export function tooltip(options?: TooltipOptions): HexbinHoverHandler;
11
- export function resizeFill(): HexbinHoverHandler;
10
+ export function tooltip<Data>(options?: TooltipOptions<Data>): HexbinHoverHandler<Data>;
11
+ export function resizeFill(): HexbinHoverHandler<any>;
12
12
  export interface ResizeScaleOptions {
13
13
  radiusScale?: number;
14
14
  duration?: number;
15
15
  }
16
- export function resizeScale(radiusScale?: number): HexbinHoverHandler;
17
- export function compound(handlers?: HexbinHoverHandler[]): HexbinHoverHandler;
18
- export function none(): HexbinHoverHandler;
16
+ export function resizeScale(radiusScale?: number): HexbinHoverHandler<any>;
17
+ export function compound<Data>(handlers?: HexbinHoverHandler<Data>[]): HexbinHoverHandler<Data>;
18
+ export function none(): HexbinHoverHandler<any>;
19
19
  export {};
20
20
  }
21
21
  export default HexbinHoverHandler;
@@ -78,23 +78,24 @@ export interface HexbinLayerConfig {
78
78
  /**
79
79
  * Hexbin data attached to each hexagon, once binned.
80
80
  */
81
- export type HexbinData = {
82
- o: L.LatLngExpression;
81
+ export type HexbinData<Data> = {
82
+ data: Data;
83
+ coord: L.LatLngExpression;
83
84
  point: Readonly<[number, number]>;
84
85
  };
85
86
  /**
86
87
  * Instantiate a hexbin layer.
87
88
  * Extends L.SVG to take advantage of built-in zoom animations.
88
89
  */
89
- export declare class HexbinLayer extends L.SVG implements HexbinLayer {
90
+ export declare class HexbinLayer<Data = L.LatLngExpression> extends L.SVG {
90
91
  options: Required<HexbinLayerConfig> & L.RendererOptions;
91
92
  _fn: {
92
- lng: (d: L.LatLngExpression) => number;
93
- lat: (d: L.LatLngExpression) => number;
94
- colorValue: (d: HexbinData[]) => number;
95
- radiusValue: (d: HexbinData[]) => number;
96
- opacityValue: (d: HexbinData[]) => number;
97
- fill: (d: HexbinData[]) => string;
93
+ lng: (d: Data) => number;
94
+ lat: (d: Data) => number;
95
+ colorValue: (d: HexbinData<Data>[]) => number;
96
+ radiusValue: (d: HexbinData<Data>[]) => number;
97
+ opacityValue: (d: HexbinData<Data>[]) => number;
98
+ fill: (d: HexbinData<Data>[]) => string;
98
99
  };
99
100
  _scale: {
100
101
  color: import('d3').ScaleLinear<string, string, never>;
@@ -102,13 +103,14 @@ export declare class HexbinLayer extends L.SVG implements HexbinLayer {
102
103
  opacity: import('d3').ScaleLinear<number, number, never>;
103
104
  };
104
105
  _dispatch: import('d3').Dispatch<SVGPathElement>;
105
- _hoverHandler: HexbinHoverHandler;
106
- _hexLayout: import('d3-hexbin').Hexbin<HexbinData>;
107
- _data: L.LatLngExpression[];
106
+ _hoverHandler: HexbinHoverHandler<Data>;
107
+ _hexLayout: import('d3-hexbin').Hexbin<HexbinData<Data>>;
108
+ _data: Data[];
108
109
  _map: L.Map;
109
110
  _container: SVGElementTagNameMap['svg'];
110
111
  _d3Container: d3.Selection<SVGGElement, unknown, null, undefined>;
111
112
  constructor(options?: HexbinLayerConfig);
113
+ _accessor(d: Data): L.LatLngExpression;
112
114
  /**
113
115
  * Create the SVG container for the hexbins
114
116
  * @private
@@ -136,8 +138,8 @@ export declare class HexbinLayer extends L.SVG implements HexbinLayer {
136
138
  */
137
139
  redraw(): void;
138
140
  _linearlySpace(from: number, to: number, length: number): number[];
139
- _createHexagons(g: d3.Selection<SVGGElement, number, SVGGElement, unknown>, data: HexbinData[]): void;
140
- _getExtent(bins: HexbinBin<HexbinData>[], valueFn: (d: HexbinBin<HexbinData>) => number, scaleExtent: [number, number | undefined]): [number, number];
141
+ _createHexagons(g: d3.Selection<SVGGElement, number, SVGGElement, unknown>, data: HexbinData<Data>[]): void;
142
+ _getExtent(bins: HexbinBin<HexbinData<Data>>[], valueFn: (d: HexbinBin<HexbinData<Data>>) => number, scaleExtent: [number, number | undefined]): [number, number];
141
143
  radius(): number;
142
144
  radius(v: number): this;
143
145
  opacity(): number | [number, number];
@@ -158,25 +160,26 @@ export declare class HexbinLayer extends L.SVG implements HexbinLayer {
158
160
  colorScale(v: d3.ScaleLinear<string, string>): this;
159
161
  radiusScale(): d3.ScaleLinear<number, number>;
160
162
  radiusScale(v: d3.ScaleLinear<number, number>): this;
161
- lng(): (d: L.LatLngExpression) => number;
162
- lng(v: (d: L.LatLngExpression) => number): this;
163
- lat(): (d: L.LatLngExpression) => number;
164
- lat(v: (d: L.LatLngExpression) => number): this;
165
- colorValue(): (d: HexbinData[]) => number;
166
- colorValue(v: (d: HexbinData[]) => number): this;
167
- radiusValue(): (d: HexbinData[]) => number;
168
- radiusValue(v: (d: HexbinData[]) => number): this;
169
- fill(): (d: HexbinData[]) => string;
170
- fill(v: (d: HexbinData[]) => string): this;
171
- data(): L.LatLngExpression[];
172
- data(v: L.LatLngExpression[]): this;
163
+ lng(): (d: Data) => number;
164
+ lng(v: (d: Data) => number): this;
165
+ lat(): (d: Data) => number;
166
+ lat(v: (d: Data) => number): this;
167
+ colorValue(): (d: HexbinData<Data>[]) => number;
168
+ colorValue(v: (d: HexbinData<Data>[]) => number): this;
169
+ radiusValue(): (d: HexbinData<Data>[]) => number;
170
+ radiusValue(v: (d: HexbinData<Data>[]) => number): this;
171
+ fill(): (d: HexbinData<Data>[]) => string;
172
+ fill(v: (d: HexbinData<Data>[]) => string): this;
173
+ data(): Data[];
174
+ data(v: Data extends L.LatLngExpression ? Data[] : never): this;
175
+ data(v: Data[], accessor?: (d: Data) => L.LatLngExpression): this;
173
176
  dispatch(): import('d3').Dispatch<SVGPathElement>;
174
- hoverHandler(): HexbinHoverHandler;
175
- hoverHandler(v: HexbinHoverHandler): this;
177
+ hoverHandler(): HexbinHoverHandler<Data>;
178
+ hoverHandler(v: HexbinHoverHandler<Data>): this;
176
179
  getLatLngs(): L.LatLng[];
177
180
  toGeoJSON(): GeoJSON.Feature<GeoJSON.MultiPoint, L.LatLng>;
178
181
  }
179
182
  /**
180
183
  * Factory function to instanciate a new hexbin layer
181
184
  */
182
- export declare function hexbinLayer(options?: HexbinLayerConfig): HexbinLayer;
185
+ export declare function hexbinLayer<Data = L.LatLngExpression>(options?: HexbinLayerConfig): HexbinLayer<Data>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "leaflet-hexbin",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "license": "MIT",