leaflet-hexbin 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/index.es.js +275 -0
- package/dist/index.es.js.map +1 -0
- package/dist/index.umd.js +2 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/types/HexbinHoverHandler.d.ts +21 -0
- package/dist/types/HexbinLayer.d.ts +116 -0
- package/dist/types/index.d.ts +12 -0
- package/package.json +67 -0
package/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2025 Louis Duchemin
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
package/dist/index.es.js
ADDED
@@ -0,0 +1,275 @@
|
|
1
|
+
import * as m from "d3";
|
2
|
+
import { scaleLinear as E, dispatch as S, select as L, extent as V } from "d3";
|
3
|
+
import { hexbin as C } from "d3-hexbin";
|
4
|
+
import * as h from "leaflet";
|
5
|
+
var y;
|
6
|
+
((p) => {
|
7
|
+
function t(i = { tooltipContent(e) {
|
8
|
+
return `Count: ${e.length}`;
|
9
|
+
} }) {
|
10
|
+
const e = m.select("body").append("div").attr("class", "hexbin-tooltip").style("z-index", 9999).style("pointer-events", "none").style("visibility", "hidden").style("position", "fixed");
|
11
|
+
return e.append("div").attr("class", "tooltip-content"), {
|
12
|
+
mouseover: function(a, d, c, s) {
|
13
|
+
const _ = m.pointer(c);
|
14
|
+
e.style("visibility", "visible").html(i.tooltipContent(s, d));
|
15
|
+
const g = e.node();
|
16
|
+
if (!g) {
|
17
|
+
console.warn("Leaflet hexbin: tooltip node not found");
|
18
|
+
return;
|
19
|
+
}
|
20
|
+
const x = g.clientHeight, r = g.clientWidth;
|
21
|
+
e.style("top", c.clientY - _[1] - x - 16 + "px").style("left", c.clientX - _[0] - r / 2 + "px");
|
22
|
+
},
|
23
|
+
mouseout: function(a, d, c, s) {
|
24
|
+
e.style("visibility", "hidden").html();
|
25
|
+
}
|
26
|
+
};
|
27
|
+
}
|
28
|
+
p.tooltip = t;
|
29
|
+
function o() {
|
30
|
+
return {
|
31
|
+
mouseover: function(i, e, a, d) {
|
32
|
+
m.select(i.parentElement).select("path.hexbin-hexagon").attr("d", function(s) {
|
33
|
+
return e._hexLayout.hexagon(e.options.radius);
|
34
|
+
});
|
35
|
+
},
|
36
|
+
mouseout: function(i, e, a, d) {
|
37
|
+
m.select(i.parentElement).select("path.hexbin-hexagon").attr("d", function(s) {
|
38
|
+
return e._hexLayout.hexagon(e._scale.radius(e._fn.radiusValue.call(e, s)));
|
39
|
+
});
|
40
|
+
}
|
41
|
+
};
|
42
|
+
}
|
43
|
+
p.resizeFill = o;
|
44
|
+
function n(i = 1.5) {
|
45
|
+
return {
|
46
|
+
mouseover: function(e, a, d, c) {
|
47
|
+
m.select(e.parentElement).select("path.hexbin-hexagon").transition().duration(a.options.duration).attr("d", function() {
|
48
|
+
return a._hexLayout.hexagon(a._scale.radius.range()[1] * i);
|
49
|
+
});
|
50
|
+
},
|
51
|
+
mouseout: function(e, a, d, c) {
|
52
|
+
m.select(e.parentElement).select("path.hexbin-hexagon").transition().duration(a.options.duration).attr("d", (_) => a._hexLayout.hexagon(a._scale.radius(a._fn.radiusValue.call(a, _))));
|
53
|
+
}
|
54
|
+
};
|
55
|
+
}
|
56
|
+
p.resizeScale = n;
|
57
|
+
function u(i = [f()]) {
|
58
|
+
return {
|
59
|
+
mouseover: function(e, a, d, c) {
|
60
|
+
i.forEach((s) => {
|
61
|
+
s.mouseover(e, a, d, c);
|
62
|
+
});
|
63
|
+
},
|
64
|
+
mouseout: function(e, a, d, c) {
|
65
|
+
i.forEach((s) => {
|
66
|
+
s.mouseout(e, a, d, c);
|
67
|
+
});
|
68
|
+
}
|
69
|
+
};
|
70
|
+
}
|
71
|
+
p.compound = u;
|
72
|
+
function f() {
|
73
|
+
return {
|
74
|
+
mouseover: function() {
|
75
|
+
},
|
76
|
+
mouseout: function() {
|
77
|
+
}
|
78
|
+
};
|
79
|
+
}
|
80
|
+
p.none = f;
|
81
|
+
})(y || (y = {}));
|
82
|
+
const b = y;
|
83
|
+
class v extends h.SVG {
|
84
|
+
constructor(t) {
|
85
|
+
super(), this.options = {
|
86
|
+
radius: 12,
|
87
|
+
opacity: 0.6,
|
88
|
+
duration: 200,
|
89
|
+
colorScaleExtent: [1, void 0],
|
90
|
+
radiusScaleExtent: [1, void 0],
|
91
|
+
colorDomain: null,
|
92
|
+
radiusDomain: null,
|
93
|
+
colorRange: ["#f7fbff", "#08306b"],
|
94
|
+
radiusRange: [4, 12],
|
95
|
+
pointerEvents: "all",
|
96
|
+
// Handle parent default options
|
97
|
+
// ...L.SVG.prototype.options,
|
98
|
+
...h.Renderer.prototype.options,
|
99
|
+
...h.Layer.prototype.options
|
100
|
+
}, this._fn = {
|
101
|
+
lng: (o) => h.latLng(o).lng,
|
102
|
+
lat: (o) => h.latLng(o).lat,
|
103
|
+
colorValue: (o) => o.length,
|
104
|
+
radiusValue: (o) => Number.MAX_VALUE,
|
105
|
+
fill: (o) => {
|
106
|
+
const n = this._fn.colorValue(o);
|
107
|
+
return n != null ? this._scale.color(n) : "none";
|
108
|
+
}
|
109
|
+
}, this._scale = {
|
110
|
+
color: E(),
|
111
|
+
radius: E()
|
112
|
+
}, this._dispatch = S("mouseover", "mouseout", "click"), this._hoverHandler = b.none(), this._hexLayout = C().radius(this.options.radius).x(({ point: [o, n] }) => o).y(({ point: [o, 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).clamp(!0);
|
113
|
+
}
|
114
|
+
/**
|
115
|
+
* Create the SVG container for the hexbins
|
116
|
+
* @private
|
117
|
+
*/
|
118
|
+
_initContainer() {
|
119
|
+
super._initContainer(), this._d3Container = L(this._container).select("g");
|
120
|
+
}
|
121
|
+
/**
|
122
|
+
* Callback made by Leaflet when the layer is added to the map
|
123
|
+
* @param map Reference to the map to which this layer has been added
|
124
|
+
*/
|
125
|
+
onAdd(t) {
|
126
|
+
return super.onAdd(t), this._map = t, t.on("moveend", this.redraw, this), this.redraw(), this;
|
127
|
+
}
|
128
|
+
_project(t) {
|
129
|
+
const { x: o, y: n } = this._map.latLngToLayerPoint(t);
|
130
|
+
return [o, n];
|
131
|
+
}
|
132
|
+
/**
|
133
|
+
* Callback made by Leaflet when the layer is removed from the map
|
134
|
+
* @param map Reference to the map from which this layer is being removed
|
135
|
+
*/
|
136
|
+
onRemove(t) {
|
137
|
+
return this._destroyContainer(), t.off("moveend", this.redraw, this), this;
|
138
|
+
}
|
139
|
+
/**
|
140
|
+
* Clean up the svg container
|
141
|
+
* @private
|
142
|
+
*/
|
143
|
+
_destroyContainer() {
|
144
|
+
L(this._container).remove();
|
145
|
+
}
|
146
|
+
/**
|
147
|
+
* (Re)draws the hexbins data on the container
|
148
|
+
* @private
|
149
|
+
*/
|
150
|
+
redraw() {
|
151
|
+
const t = this;
|
152
|
+
if (!t._map) return;
|
153
|
+
const o = t._data.map((i) => {
|
154
|
+
const e = t._project(i);
|
155
|
+
return { o: i, point: e };
|
156
|
+
}), n = this._d3Container.selectAll("g.hexbin").data([this._map.getZoom()], (i) => i), f = n.enter().append("g").attr("class", function(i) {
|
157
|
+
return "hexbin zoom-" + i;
|
158
|
+
}).merge(n);
|
159
|
+
n.exit().remove(), this._createHexagons(f, o);
|
160
|
+
}
|
161
|
+
_linearlySpace(t, o, n) {
|
162
|
+
const u = (o - t) / Math.max(n - 1, 1);
|
163
|
+
return Array.from({ length: n }, (f, i) => t + i * u);
|
164
|
+
}
|
165
|
+
_createHexagons(t, o) {
|
166
|
+
const n = this, u = n._map.getSize(), f = n._map.getBounds().pad(n.options.radius * 2 / Math.max(u.x, u.y)), i = n._hexLayout(o).filter(
|
167
|
+
({ x: r, y: l }) => f.contains(n._map.layerPointToLatLng(h.point(r, l)))
|
168
|
+
), e = n._getExtent(i, n._fn.colorValue, n.options.colorScaleExtent), a = n._getExtent(i, n._fn.radiusValue, n.options.radiusScaleExtent), d = this.options.colorDomain ?? n._linearlySpace(
|
169
|
+
e[0],
|
170
|
+
e[1],
|
171
|
+
n._scale.color.range().length
|
172
|
+
), c = this.options.radiusDomain || a;
|
173
|
+
n._scale.color.domain(d), n._scale.radius.domain(c);
|
174
|
+
const s = t.selectAll("g.hexbin-container").data(i, ({ x: r, y: l }) => `${r}:${l}`);
|
175
|
+
s.select("path.hexbin-hexagon").transition().duration(n.options.duration).attr("fill", n._fn.fill.bind(n)).attr("fill-opacity", n.options.opacity).attr("stroke-opacity", n.options.opacity).attr("d", (r) => n._hexLayout.hexagon(n._scale.radius(n._fn.radiusValue.call(n, r))));
|
176
|
+
const _ = s.enter().append("g").attr("class", "hexbin-container").style("pointer-events", n.options.pointerEvents), g = _.append("path").attr("class", "hexbin-hexagon").attr("transform", ({ x: r, y: l }) => `translate(${r},${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");
|
177
|
+
g.transition().duration(n.options.duration).attr("fill-opacity", n.options.opacity).attr("stroke-opacity", n.options.opacity).attr("d", (r) => n._hexLayout.hexagon(n._scale.radius(n._fn.radiusValue.call(n, r)))).style("pointer-events", "all"), _.append("path").attr("class", "hexbin-grid").attr("transform", ({ x: r, y: l }) => `translate(${r},${l})`).attr("d", () => n._hexLayout.hexagon(n.options.radius)).attr("fill", "none").attr("stroke", "none"), g.on("mouseover", function(r, l) {
|
178
|
+
this.parentElement.parentElement.appendChild(this.parentElement), n._hoverHandler.mouseover(this, n, r, l), n._dispatch.call("mouseover", this, r, l);
|
179
|
+
}).on("mouseout", function(r, l) {
|
180
|
+
n._hoverHandler.mouseout(this, n, r, l), n._dispatch.call("mouseout", this, n, r, l);
|
181
|
+
}).on("click", function(r, l) {
|
182
|
+
n._dispatch.call("click", this, n, r, l);
|
183
|
+
});
|
184
|
+
const x = s.exit();
|
185
|
+
x.select("path.hexbin-hexagon").transition().duration(n.options.duration).attr("fill-opacity", 0).attr("stroke-opacity", 0).attr("d", (r) => n._hexLayout.hexagon(0)), x.transition().duration(n.options.duration).remove();
|
186
|
+
}
|
187
|
+
_getExtent(t, o, n) {
|
188
|
+
let u = V(t, o.bind(this));
|
189
|
+
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;
|
190
|
+
}
|
191
|
+
radius(t) {
|
192
|
+
return t === void 0 ? this.options.radius : (this.options.radius = t, this._hexLayout.radius(t), this);
|
193
|
+
}
|
194
|
+
opacity(t) {
|
195
|
+
return t === void 0 ? this.options.opacity : (this.options.opacity = t, this);
|
196
|
+
}
|
197
|
+
duration(t) {
|
198
|
+
return t === void 0 ? this.options.duration : (this.options.duration = t, this);
|
199
|
+
}
|
200
|
+
colorScaleExtent(t) {
|
201
|
+
return t === void 0 ? this.options.colorScaleExtent : (this.options.colorScaleExtent = t, this);
|
202
|
+
}
|
203
|
+
radiusScaleExtent(t) {
|
204
|
+
return t === void 0 ? this.options.radiusScaleExtent : (this.options.radiusScaleExtent = t, this);
|
205
|
+
}
|
206
|
+
colorRange(t) {
|
207
|
+
return t === void 0 ? this.options.colorRange : (this.options.colorRange = t, this._scale.color.range(t), this);
|
208
|
+
}
|
209
|
+
radiusRange(t) {
|
210
|
+
return t === void 0 ? this.options.radiusRange : (this.options.radiusRange = t, this._scale.radius.range(t), this);
|
211
|
+
}
|
212
|
+
colorScale(t) {
|
213
|
+
return t === void 0 ? this._scale.color : (this._scale.color = t, this);
|
214
|
+
}
|
215
|
+
radiusScale(t) {
|
216
|
+
return t === void 0 ? this._scale.radius : (this._scale.radius = t, this);
|
217
|
+
}
|
218
|
+
lng(t) {
|
219
|
+
return t === void 0 ? this._fn.lng : (this._fn.lng = t, this);
|
220
|
+
}
|
221
|
+
lat(t) {
|
222
|
+
return t === void 0 ? this._fn.lat : (this._fn.lat = t, this);
|
223
|
+
}
|
224
|
+
colorValue(t) {
|
225
|
+
return t === void 0 ? this._fn.colorValue : (this._fn.colorValue = t, this);
|
226
|
+
}
|
227
|
+
radiusValue(t) {
|
228
|
+
return t === void 0 ? this._fn.radiusValue : (this._fn.radiusValue = t, this);
|
229
|
+
}
|
230
|
+
fill(t) {
|
231
|
+
return t === void 0 ? this._fn.fill : (this._fn.fill = t, this);
|
232
|
+
}
|
233
|
+
data(t) {
|
234
|
+
return t === void 0 ? this._data : (this._data = t ?? [], this.redraw(), this);
|
235
|
+
}
|
236
|
+
/*
|
237
|
+
* Getter for the event dispatcher
|
238
|
+
*/
|
239
|
+
dispatch() {
|
240
|
+
return this._dispatch;
|
241
|
+
}
|
242
|
+
hoverHandler(t) {
|
243
|
+
return t === void 0 ? this._hoverHandler : (this._hoverHandler = t ?? b.none(), this.redraw(), this);
|
244
|
+
}
|
245
|
+
/*
|
246
|
+
* Returns an array of the points in the path, or nested arrays of points in case of multi-polyline.
|
247
|
+
*/
|
248
|
+
getLatLngs() {
|
249
|
+
const t = this;
|
250
|
+
return this._data.map(function(o) {
|
251
|
+
return h.latLng(t._fn.lat(o), t._fn.lng(o));
|
252
|
+
});
|
253
|
+
}
|
254
|
+
/*
|
255
|
+
* Get path geometry as GeoJSON
|
256
|
+
*/
|
257
|
+
toGeoJSON() {
|
258
|
+
return h.GeoJSON.getFeature(this, {
|
259
|
+
type: "MultiPoint",
|
260
|
+
coordinates: h.GeoJSON.latLngsToCoords(this.getLatLngs(), 0)
|
261
|
+
});
|
262
|
+
}
|
263
|
+
}
|
264
|
+
function R(p) {
|
265
|
+
return new v(p);
|
266
|
+
}
|
267
|
+
h.HexbinLayer = v;
|
268
|
+
h.HexbinHoverHandler = b;
|
269
|
+
h.hexbinLayer = R;
|
270
|
+
export {
|
271
|
+
b as HexbinHoverHandler,
|
272
|
+
v as HexbinLayer,
|
273
|
+
R as hexbinLayer
|
274
|
+
};
|
275
|
+
//# sourceMappingURL=index.es.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../src/HexbinHoverHandler.ts","../src/HexbinLayer.ts","../src/index.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 radius?: number,\n opacity?: number,\n duration?: number,\n\n colorScaleExtent?: [number, number | undefined],\n colorDomain?: number[] | null\n colorRange?: string[],\n\n radiusScaleExtent?: [number, number | undefined],\n radiusDomain?: number[] | null\n radiusRange?: [number, number],\n\n pointerEvents?: string\n}\n\nexport type HexbinData = {\n o: L.LatLngExpression;\n point: Readonly<[number, number]>;\n}\n\n\n/**\n * L is defined by the Leaflet library, see git://github.com/Leaflet/Leaflet.git for documentation\n * We extend L.SVG to take advantage of built-in zoom animations.\n */\nexport class HexbinLayer extends L.SVG implements L.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 colorDomain: null,\n radiusDomain: null,\n colorRange: ['#f7fbff', '#08306b'],\n radiusRange: [4, 12],\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[]) => Number.MAX_VALUE,\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 };\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)\n .clamp(true);\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 // L.SVG.prototype.onRemove.call(this, map);\n // super.onRemove(map);\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 // const arr = new Array(length);\n // var step = (to - from) / Math.max(length - 1, 1);\n\n // for (var i = 0; i < length; ++i) {\n // arr[i] = from + (i * step);\n // }\n\n // return arr;\n }\n\n _createHexagons(g: d3.Selection<SVGGElement, number, SVGGElement, unknown>, data: HexbinData[]) {\n const that = 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 = that._map.getSize();\n const bounds = that._map.getBounds().pad(that.options.radius * 2 / Math.max(size.x, size.y));\n\n const bins = that._hexLayout(data).filter(\n ({ x, y }) => bounds.contains(that._map.layerPointToLatLng(L.point(x, y)))\n );\n\n // Derive the extents of the data values for each dimension\n const colorExtent = that._getExtent(bins, that._fn.colorValue, that.options.colorScaleExtent);\n const radiusExtent = that._getExtent(bins, that._fn.radiusValue, that.options.radiusScaleExtent);\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 ?? that._linearlySpace(\n colorExtent[0],\n colorExtent[1],\n that._scale.color.range().length\n );\n const radiusDomain = this.options.radiusDomain || radiusExtent;\n\n // Set the scale domains\n that._scale.color.domain(colorDomain);\n that._scale.radius.domain(radiusDomain);\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 // bins = bins.filter(function (d) {\n // return bounds.contains(that._map.layerPointToLatLng(L.point(d.x, d.y)));\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').transition().duration(that.options.duration)\n .attr('fill', that._fn.fill.bind(that))\n .attr('fill-opacity', that.options.opacity)\n .attr('stroke-opacity', that.options.opacity)\n .attr('d', (d) => {\n return that._hexLayout.hexagon(that._scale.radius(that._fn.radiusValue.call(that, 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 enter = join.enter().append('g').attr('class', 'hexbin-container')\n .style('pointer-events', that.options.pointerEvents);\n\n const hexagons = enter.append('path').attr('class', 'hexbin-hexagon')\n .attr('transform', ({ x, y }) => `translate(${x},${y})`)\n .attr('d', () => that._hexLayout.hexagon(that._scale.radius.range()[0]))\n .attr('fill', that._fn.fill.bind(that))\n .attr('fill-opacity', 0.01)\n .attr('stroke-opacity', 0.01)\n .style('pointer-events', 'all');\n\n hexagons.transition().duration(that.options.duration)\n .attr('fill-opacity', that.options.opacity)\n .attr('stroke-opacity', that.options.opacity)\n .attr('d', (d) => that._hexLayout.hexagon(that._scale.radius(that._fn.radiusValue.call(that, d))))\n .style('pointer-events', 'all');\n // .style('pointer-events', that.options.pointerEvents);\n\n // Grid\n const gridEnter = enter.append('path').attr('class', 'hexbin-grid')\n .attr('transform', ({ x, y }) => `translate(${x},${y})`)\n .attr('d', () => that._hexLayout.hexagon(that.options.radius))\n .attr('fill', 'none')\n .attr('stroke', 'none')\n // .style('pointer-events', that.options.pointerEvents);\n\n\n // Grid enter-update\n // gridEnter(join.select('path.hexbin-hexagon'))\n hexagons\n // join\n .on('mouseover', function (this: SVGPathElement, d: MouseEvent, i) {\n this.parentElement!.parentElement!.appendChild(this.parentElement!);\n that._hoverHandler.mouseover(this, that as L.HexbinLayer, d, i);\n that._dispatch.call('mouseover', this, d, i);\n })\n .on('mouseout', function (this: SVGPathElement, d: MouseEvent, i) {\n that._hoverHandler.mouseout(this, that as L.HexbinLayer, d, i);\n that._dispatch.call('mouseout', this, that as L.HexbinLayer, d, i);\n })\n .on('click', function (this, d, i) {\n that._dispatch.call('click', this, that as L.HexbinLayer, d, i);\n });\n\n\n // Exit\n const exit = join.exit();\n\n exit.select('path.hexbin-hexagon')\n .transition().duration(that.options.duration)\n .attr('fill-opacity', 0)\n .attr('stroke-opacity', 0)\n .attr('d', (d) => that._hexLayout.hexagon(0));\n\n exit.transition().duration(that.options.duration).remove();\n\n }\n\n\n _getExtent(\n bins: HexbinBin<HexbinData>[],\n valueFn: (d: HexbinBin<HexbinData>) => number,\n scaleExtent: [number, number | undefined]\n ) {\n\n // Determine the extent of the values\n let ext = extent<HexbinBin<HexbinData>, number>(bins, valueFn.bind(this));\n if (ext[0] === undefined || ext[1] === undefined) {\n ext = [0, 0]\n }\n // If either's null, initialize them to 0\n // if (undefined == extent[0]) extent[0] = 0;\n // if (null == extent[1]) extent[1] = 0;\n\n // Now apply the optional clipping of the extent\n if (null != scaleExtent[0]) ext[0] = scaleExtent[0];\n if (null != scaleExtent[1]) ext[1] = scaleExtent[1];\n\n return ext\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 return this;\n }\n\n opacity(): number;\n opacity(v: number): this;\n opacity(v?: number): this | number {\n if (v === undefined) return this.options.opacity\n this.options.opacity = v;\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 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];\n radiusRange(v: [number, number]): this;\n radiusRange(v?: [number, number]): this | [number, number] {\n if (v === undefined) { return this.options.radiusRange; }\n this.options.radiusRange = v;\n this._scale.radius.range(v);\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 /*\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\nexport function hexbinLayer(options?: HexbinLayerConfig) {\n return new HexbinLayer(options);\n}\n\n\n","import { HexbinLayer as CHexbinLayer, HexbinLayer, type HexbinLayerConfig as IHexbinLayerConfig, hexbinLayer } from './HexbinLayer'\nimport HexbinHoverHandler, { HexbinHoverHandler as IHexbinHoverHandler } from './HexbinHoverHandler'\n\nimport * as L from \"leaflet\"\n\n\ndeclare module 'leaflet' {\n interface HexbinLayer extends CHexbinLayer { }\n interface HexbinLayerConfig extends IHexbinLayerConfig { }\n interface HexbinHoverHandler extends IHexbinHoverHandler { }\n function hexbinLayer(config?: HexbinLayerConfig): HexbinLayer;\n}\n\n(L as any).HexbinLayer = CHexbinLayer;\n(L as any).HexbinHoverHandler = HexbinHoverHandler;\n(L as any).hexbinLayer = hexbinLayer\n\n\nexport {\n HexbinHoverHandler,\n CHexbinLayer as HexbinLayer,\n hexbinLayer,\n type IHexbinLayerConfig as HexbinLayerConfig\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","g","size","bounds","bins","colorExtent","radiusExtent","colorDomain","radiusDomain","enter","hexagons","i","exit","valueFn","scaleExtent","ext","extent","v","hexbinLayer","CHexbinLayer"],"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,KAAK,IAAI,EACvD,MAAM,QAAQJ,EAAM,UAAUE,EAAQ,CAAC,IAAIG,IAAI,IAAI,IAAI;AAAA,MAE5D;AAAA,MACA,UAAU,SAAUP,GAAKC,GAAuBC,GAAmBC,GAAoB;AACrFP,QAAAA,EACG,MAAM,cAAc,QAAQ,EAC5B,KAAK;AAAA,MAAA;AAAA,IAEZ;AAAA,EAAA;AAvCKD,EAAAA,EAAS,UAAAC;AA2CT,WAASY,IAAiC;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=="function"&&define.amd?define(["exports","d3","d3-hexbin","leaflet"],_):(f=typeof globalThis<"u"?globalThis:f||self,_(f["leaflet-hexbin"]={},f.d3,f["d3-hexbin"],f.L))})(this,function(f,_,C,H){"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(_),h=v(H);var S;(l=>{function t(o={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(a,p,d,s){const x=m.pointer(d);i.style("visibility","visible").html(o.tooltipContent(s,p));const y=i.node();if(!y){console.warn("Leaflet hexbin: tooltip node not found");return}const L=y.clientHeight,r=y.clientWidth;i.style("top",d.clientY-x[1]-L-16+"px").style("left",d.clientX-x[0]-r/2+"px")},mouseout:function(a,p,d,s){i.style("visibility","hidden").html()}}}l.tooltip=t;function n(){return{mouseover:function(o,i,a,p){m.select(o.parentElement).select("path.hexbin-hexagon").attr("d",function(s){return i._hexLayout.hexagon(i.options.radius)})},mouseout:function(o,i,a,p){m.select(o.parentElement).select("path.hexbin-hexagon").attr("d",function(s){return i._hexLayout.hexagon(i._scale.radius(i._fn.radiusValue.call(i,s)))})}}}l.resizeFill=n;function e(o=1.5){return{mouseover:function(i,a,p,d){m.select(i.parentElement).select("path.hexbin-hexagon").transition().duration(a.options.duration).attr("d",function(){return a._hexLayout.hexagon(a._scale.radius.range()[1]*o)})},mouseout:function(i,a,p,d){m.select(i.parentElement).select("path.hexbin-hexagon").transition().duration(a.options.duration).attr("d",x=>a._hexLayout.hexagon(a._scale.radius(a._fn.radiusValue.call(a,x))))}}}l.resizeScale=e;function c(o=[g()]){return{mouseover:function(i,a,p,d){o.forEach(s=>{s.mouseover(i,a,p,d)})},mouseout:function(i,a,p,d){o.forEach(s=>{s.mouseout(i,a,p,d)})}}}l.compound=c;function g(){return{mouseover:function(){},mouseout:function(){}}}l.none=g})(S||(S={}));const b=S;class E extends h.SVG{constructor(t){super(),this.options={radius:12,opacity:.6,duration:200,colorScaleExtent:[1,void 0],radiusScaleExtent:[1,void 0],colorDomain:null,radiusDomain:null,colorRange:["#f7fbff","#08306b"],radiusRange:[4,12],pointerEvents:"all",...h.Renderer.prototype.options,...h.Layer.prototype.options},this._fn={lng:n=>h.latLng(n).lng,lat:n=>h.latLng(n).lat,colorValue:n=>n.length,radiusValue:n=>Number.MAX_VALUE,fill:n=>{const e=this._fn.colorValue(n);return e!=null?this._scale.color(e):"none"}},this._scale={color:_.scaleLinear(),radius:_.scaleLinear()},this._dispatch=_.dispatch("mouseover","mouseout","click"),this._hoverHandler=b.none(),this._hexLayout=C.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).clamp(!0)}_initContainer(){super._initContainer(),this._d3Container=_.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(){_.select(this._container).remove()}redraw(){const t=this;if(!t._map)return;const n=t._data.map(o=>{const i=t._project(o);return{o,point:i}}),e=this._d3Container.selectAll("g.hexbin").data([this._map.getZoom()],o=>o),g=e.enter().append("g").attr("class",function(o){return"hexbin zoom-"+o}).merge(e);e.exit().remove(),this._createHexagons(g,n)}_linearlySpace(t,n,e){const c=(n-t)/Math.max(e-1,1);return Array.from({length:e},(g,o)=>t+o*c)}_createHexagons(t,n){const e=this,c=e._map.getSize(),g=e._map.getBounds().pad(e.options.radius*2/Math.max(c.x,c.y)),o=e._hexLayout(n).filter(({x:r,y:u})=>g.contains(e._map.layerPointToLatLng(h.point(r,u)))),i=e._getExtent(o,e._fn.colorValue,e.options.colorScaleExtent),a=e._getExtent(o,e._fn.radiusValue,e.options.radiusScaleExtent),p=this.options.colorDomain??e._linearlySpace(i[0],i[1],e._scale.color.range().length),d=this.options.radiusDomain||a;e._scale.color.domain(p),e._scale.radius.domain(d);const s=t.selectAll("g.hexbin-container").data(o,({x:r,y:u})=>`${r}:${u}`);s.select("path.hexbin-hexagon").transition().duration(e.options.duration).attr("fill",e._fn.fill.bind(e)).attr("fill-opacity",e.options.opacity).attr("stroke-opacity",e.options.opacity).attr("d",r=>e._hexLayout.hexagon(e._scale.radius(e._fn.radiusValue.call(e,r))));const x=s.enter().append("g").attr("class","hexbin-container").style("pointer-events",e.options.pointerEvents),y=x.append("path").attr("class","hexbin-hexagon").attr("transform",({x:r,y:u})=>`translate(${r},${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");y.transition().duration(e.options.duration).attr("fill-opacity",e.options.opacity).attr("stroke-opacity",e.options.opacity).attr("d",r=>e._hexLayout.hexagon(e._scale.radius(e._fn.radiusValue.call(e,r)))).style("pointer-events","all"),x.append("path").attr("class","hexbin-grid").attr("transform",({x:r,y:u})=>`translate(${r},${u})`).attr("d",()=>e._hexLayout.hexagon(e.options.radius)).attr("fill","none").attr("stroke","none"),y.on("mouseover",function(r,u){this.parentElement.parentElement.appendChild(this.parentElement),e._hoverHandler.mouseover(this,e,r,u),e._dispatch.call("mouseover",this,r,u)}).on("mouseout",function(r,u){e._hoverHandler.mouseout(this,e,r,u),e._dispatch.call("mouseout",this,e,r,u)}).on("click",function(r,u){e._dispatch.call("click",this,e,r,u)});const L=s.exit();L.select("path.hexbin-hexagon").transition().duration(e.options.duration).attr("fill-opacity",0).attr("stroke-opacity",0).attr("d",r=>e._hexLayout.hexagon(0)),L.transition().duration(e.options.duration).remove()}_getExtent(t,n,e){let c=_.extent(t,n.bind(this));return(c[0]===void 0||c[1]===void 0)&&(c=[0,0]),e[0]!=null&&(c[0]=e[0]),e[1]!=null&&(c[1]=e[1]),c}radius(t){return t===void 0?this.options.radius:(this.options.radius=t,this._hexLayout.radius(t),this)}opacity(t){return t===void 0?this.options.opacity:(this.options.opacity=t,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)}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(t),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??b.none(),this.redraw(),this)}getLatLngs(){const t=this;return this._data.map(function(n){return h.latLng(t._fn.lat(n),t._fn.lng(n))})}toGeoJSON(){return h.GeoJSON.getFeature(this,{type:"MultiPoint",coordinates:h.GeoJSON.latLngsToCoords(this.getLatLngs(),0)})}}function V(l){return new E(l)}h.HexbinLayer=E,h.HexbinHoverHandler=b,h.hexbinLayer=V,f.HexbinHoverHandler=b,f.HexbinLayer=E,f.hexbinLayer=V,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})});
|
2
|
+
//# sourceMappingURL=index.umd.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.umd.js","sources":["../src/HexbinHoverHandler.ts","../src/HexbinLayer.ts","../src/index.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 radius?: number,\n opacity?: number,\n duration?: number,\n\n colorScaleExtent?: [number, number | undefined],\n colorDomain?: number[] | null\n colorRange?: string[],\n\n radiusScaleExtent?: [number, number | undefined],\n radiusDomain?: number[] | null\n radiusRange?: [number, number],\n\n pointerEvents?: string\n}\n\nexport type HexbinData = {\n o: L.LatLngExpression;\n point: Readonly<[number, number]>;\n}\n\n\n/**\n * L is defined by the Leaflet library, see git://github.com/Leaflet/Leaflet.git for documentation\n * We extend L.SVG to take advantage of built-in zoom animations.\n */\nexport class HexbinLayer extends L.SVG implements L.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 colorDomain: null,\n radiusDomain: null,\n colorRange: ['#f7fbff', '#08306b'],\n radiusRange: [4, 12],\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[]) => Number.MAX_VALUE,\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 };\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)\n .clamp(true);\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 // L.SVG.prototype.onRemove.call(this, map);\n // super.onRemove(map);\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 // const arr = new Array(length);\n // var step = (to - from) / Math.max(length - 1, 1);\n\n // for (var i = 0; i < length; ++i) {\n // arr[i] = from + (i * step);\n // }\n\n // return arr;\n }\n\n _createHexagons(g: d3.Selection<SVGGElement, number, SVGGElement, unknown>, data: HexbinData[]) {\n const that = 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 = that._map.getSize();\n const bounds = that._map.getBounds().pad(that.options.radius * 2 / Math.max(size.x, size.y));\n\n const bins = that._hexLayout(data).filter(\n ({ x, y }) => bounds.contains(that._map.layerPointToLatLng(L.point(x, y)))\n );\n\n // Derive the extents of the data values for each dimension\n const colorExtent = that._getExtent(bins, that._fn.colorValue, that.options.colorScaleExtent);\n const radiusExtent = that._getExtent(bins, that._fn.radiusValue, that.options.radiusScaleExtent);\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 ?? that._linearlySpace(\n colorExtent[0],\n colorExtent[1],\n that._scale.color.range().length\n );\n const radiusDomain = this.options.radiusDomain || radiusExtent;\n\n // Set the scale domains\n that._scale.color.domain(colorDomain);\n that._scale.radius.domain(radiusDomain);\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 // bins = bins.filter(function (d) {\n // return bounds.contains(that._map.layerPointToLatLng(L.point(d.x, d.y)));\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').transition().duration(that.options.duration)\n .attr('fill', that._fn.fill.bind(that))\n .attr('fill-opacity', that.options.opacity)\n .attr('stroke-opacity', that.options.opacity)\n .attr('d', (d) => {\n return that._hexLayout.hexagon(that._scale.radius(that._fn.radiusValue.call(that, 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 enter = join.enter().append('g').attr('class', 'hexbin-container')\n .style('pointer-events', that.options.pointerEvents);\n\n const hexagons = enter.append('path').attr('class', 'hexbin-hexagon')\n .attr('transform', ({ x, y }) => `translate(${x},${y})`)\n .attr('d', () => that._hexLayout.hexagon(that._scale.radius.range()[0]))\n .attr('fill', that._fn.fill.bind(that))\n .attr('fill-opacity', 0.01)\n .attr('stroke-opacity', 0.01)\n .style('pointer-events', 'all');\n\n hexagons.transition().duration(that.options.duration)\n .attr('fill-opacity', that.options.opacity)\n .attr('stroke-opacity', that.options.opacity)\n .attr('d', (d) => that._hexLayout.hexagon(that._scale.radius(that._fn.radiusValue.call(that, d))))\n .style('pointer-events', 'all');\n // .style('pointer-events', that.options.pointerEvents);\n\n // Grid\n const gridEnter = enter.append('path').attr('class', 'hexbin-grid')\n .attr('transform', ({ x, y }) => `translate(${x},${y})`)\n .attr('d', () => that._hexLayout.hexagon(that.options.radius))\n .attr('fill', 'none')\n .attr('stroke', 'none')\n // .style('pointer-events', that.options.pointerEvents);\n\n\n // Grid enter-update\n // gridEnter(join.select('path.hexbin-hexagon'))\n hexagons\n // join\n .on('mouseover', function (this: SVGPathElement, d: MouseEvent, i) {\n this.parentElement!.parentElement!.appendChild(this.parentElement!);\n that._hoverHandler.mouseover(this, that as L.HexbinLayer, d, i);\n that._dispatch.call('mouseover', this, d, i);\n })\n .on('mouseout', function (this: SVGPathElement, d: MouseEvent, i) {\n that._hoverHandler.mouseout(this, that as L.HexbinLayer, d, i);\n that._dispatch.call('mouseout', this, that as L.HexbinLayer, d, i);\n })\n .on('click', function (this, d, i) {\n that._dispatch.call('click', this, that as L.HexbinLayer, d, i);\n });\n\n\n // Exit\n const exit = join.exit();\n\n exit.select('path.hexbin-hexagon')\n .transition().duration(that.options.duration)\n .attr('fill-opacity', 0)\n .attr('stroke-opacity', 0)\n .attr('d', (d) => that._hexLayout.hexagon(0));\n\n exit.transition().duration(that.options.duration).remove();\n\n }\n\n\n _getExtent(\n bins: HexbinBin<HexbinData>[],\n valueFn: (d: HexbinBin<HexbinData>) => number,\n scaleExtent: [number, number | undefined]\n ) {\n\n // Determine the extent of the values\n let ext = extent<HexbinBin<HexbinData>, number>(bins, valueFn.bind(this));\n if (ext[0] === undefined || ext[1] === undefined) {\n ext = [0, 0]\n }\n // If either's null, initialize them to 0\n // if (undefined == extent[0]) extent[0] = 0;\n // if (null == extent[1]) extent[1] = 0;\n\n // Now apply the optional clipping of the extent\n if (null != scaleExtent[0]) ext[0] = scaleExtent[0];\n if (null != scaleExtent[1]) ext[1] = scaleExtent[1];\n\n return ext\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 return this;\n }\n\n opacity(): number;\n opacity(v: number): this;\n opacity(v?: number): this | number {\n if (v === undefined) return this.options.opacity\n this.options.opacity = v;\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 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];\n radiusRange(v: [number, number]): this;\n radiusRange(v?: [number, number]): this | [number, number] {\n if (v === undefined) { return this.options.radiusRange; }\n this.options.radiusRange = v;\n this._scale.radius.range(v);\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 /*\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\nexport function hexbinLayer(options?: HexbinLayerConfig) {\n return new HexbinLayer(options);\n}\n\n\n","import { HexbinLayer as CHexbinLayer, HexbinLayer, type HexbinLayerConfig as IHexbinLayerConfig, hexbinLayer } from './HexbinLayer'\nimport HexbinHoverHandler, { HexbinHoverHandler as IHexbinHoverHandler } from './HexbinHoverHandler'\n\nimport * as L from \"leaflet\"\n\n\ndeclare module 'leaflet' {\n interface HexbinLayer extends CHexbinLayer { }\n interface HexbinLayerConfig extends IHexbinLayerConfig { }\n interface HexbinHoverHandler extends IHexbinHoverHandler { }\n function hexbinLayer(config?: HexbinLayerConfig): HexbinLayer;\n}\n\n(L as any).HexbinLayer = CHexbinLayer;\n(L as any).HexbinHoverHandler = HexbinHoverHandler;\n(L as any).hexbinLayer = hexbinLayer\n\n\nexport {\n HexbinHoverHandler,\n CHexbinLayer as HexbinLayer,\n hexbinLayer,\n type IHexbinLayerConfig as HexbinLayerConfig\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","size","bounds","bins","colorExtent","radiusExtent","colorDomain","radiusDomain","enter","hexagons","exit","valueFn","scaleExtent","ext","extent","v","hexbinLayer","L__namespace","CHexbinLayer"],"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,SAA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AK,OAAO,EAEL,KAAA,CAMT,YAAa,CACX,MAAMgC,EAAO,KAGb,OAAO,KAAK,MAAM,IAAI,SAAU7B,EAAG,CAC1B,OAAAkB,EAAE,OAAOW,EAAK,IAAI,IAAI7B,CAAC,EAAG6B,EAAK,IAAI,IAAI7B,CAAC,CAAC,CAAA,CACjD,CAAA,CAMH,WAA2D,CAClD,OAAAkB,EAAE,QAAQ,WAAyC,KAAM,CAC9D,KAAM,aACN,YAAaA,EAAE,QAAQ,gBAAgB,KAAK,WAAA,EAAc,CAAC,CAAA,CAC5D,CAAA,CAEL,CAEO,SAASoC,EAAYvD,EAA6B,CAChD,OAAA,IAAIkB,EAAYlB,CAAO,CAChC,CC3gBCwD,EAAU,YAAcC,EACxBD,EAAU,mBAAqB1D,EAC/B0D,EAAU,YAAcD"}
|
@@ -0,0 +1,21 @@
|
|
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;
|
5
|
+
}
|
6
|
+
export declare namespace HexbinHoverHandler {
|
7
|
+
interface TooltipOptions {
|
8
|
+
tooltipContent: (d: HexbinData[], hexLayer: HexbinLayer) => string;
|
9
|
+
}
|
10
|
+
export function tooltip(options?: TooltipOptions): HexbinHoverHandler;
|
11
|
+
export function resizeFill(): HexbinHoverHandler;
|
12
|
+
export interface ResizeScaleOptions {
|
13
|
+
radiusScale?: number;
|
14
|
+
duration?: number;
|
15
|
+
}
|
16
|
+
export function resizeScale(radiusScale?: number): HexbinHoverHandler;
|
17
|
+
export function compound(handlers?: HexbinHoverHandler[]): HexbinHoverHandler;
|
18
|
+
export function none(): HexbinHoverHandler;
|
19
|
+
export {};
|
20
|
+
}
|
21
|
+
export default HexbinHoverHandler;
|
@@ -0,0 +1,116 @@
|
|
1
|
+
import { HexbinBin } from 'd3-hexbin';
|
2
|
+
import { default as HexbinHoverHandler } from './HexbinHoverHandler';
|
3
|
+
import * as L from 'leaflet';
|
4
|
+
declare module 'leaflet' {
|
5
|
+
interface SVG {
|
6
|
+
_initContainer(): void;
|
7
|
+
_container: SVGElementTagNameMap['svg'];
|
8
|
+
}
|
9
|
+
}
|
10
|
+
export interface HexbinLayerConfig {
|
11
|
+
radius?: number;
|
12
|
+
opacity?: number;
|
13
|
+
duration?: number;
|
14
|
+
colorScaleExtent?: [number, number | undefined];
|
15
|
+
colorDomain?: number[] | null;
|
16
|
+
colorRange?: string[];
|
17
|
+
radiusScaleExtent?: [number, number | undefined];
|
18
|
+
radiusDomain?: number[] | null;
|
19
|
+
radiusRange?: [number, number];
|
20
|
+
pointerEvents?: string;
|
21
|
+
}
|
22
|
+
export type HexbinData = {
|
23
|
+
o: L.LatLngExpression;
|
24
|
+
point: Readonly<[number, number]>;
|
25
|
+
};
|
26
|
+
/**
|
27
|
+
* L is defined by the Leaflet library, see git://github.com/Leaflet/Leaflet.git for documentation
|
28
|
+
* We extend L.SVG to take advantage of built-in zoom animations.
|
29
|
+
*/
|
30
|
+
export declare class HexbinLayer extends L.SVG implements L.HexbinLayer {
|
31
|
+
options: Required<HexbinLayerConfig> & L.RendererOptions;
|
32
|
+
_fn: {
|
33
|
+
lng: (d: L.LatLngExpression) => number;
|
34
|
+
lat: (d: L.LatLngExpression) => number;
|
35
|
+
colorValue: (d: HexbinData[]) => number;
|
36
|
+
radiusValue: (d: HexbinData[]) => number;
|
37
|
+
fill: (d: HexbinData[]) => string;
|
38
|
+
};
|
39
|
+
_scale: {
|
40
|
+
color: import('d3').ScaleLinear<string, string, never>;
|
41
|
+
radius: import('d3').ScaleLinear<number, number, never>;
|
42
|
+
};
|
43
|
+
_dispatch: import('d3').Dispatch<SVGPathElement>;
|
44
|
+
_hoverHandler: HexbinHoverHandler;
|
45
|
+
_hexLayout: import('d3-hexbin').Hexbin<HexbinData>;
|
46
|
+
_data: L.LatLngExpression[];
|
47
|
+
_map: L.Map;
|
48
|
+
_container: SVGElementTagNameMap['svg'];
|
49
|
+
_d3Container: d3.Selection<SVGGElement, unknown, null, undefined>;
|
50
|
+
constructor(options?: HexbinLayerConfig);
|
51
|
+
/**
|
52
|
+
* Create the SVG container for the hexbins
|
53
|
+
* @private
|
54
|
+
*/
|
55
|
+
_initContainer(): void;
|
56
|
+
/**
|
57
|
+
* Callback made by Leaflet when the layer is added to the map
|
58
|
+
* @param map Reference to the map to which this layer has been added
|
59
|
+
*/
|
60
|
+
onAdd(map: L.Map): this;
|
61
|
+
_project(latlng: L.LatLngExpression): readonly [number, number];
|
62
|
+
/**
|
63
|
+
* Callback made by Leaflet when the layer is removed from the map
|
64
|
+
* @param map Reference to the map from which this layer is being removed
|
65
|
+
*/
|
66
|
+
onRemove(map: L.Map): this;
|
67
|
+
/**
|
68
|
+
* Clean up the svg container
|
69
|
+
* @private
|
70
|
+
*/
|
71
|
+
_destroyContainer(): void;
|
72
|
+
/**
|
73
|
+
* (Re)draws the hexbins data on the container
|
74
|
+
* @private
|
75
|
+
*/
|
76
|
+
redraw(): void;
|
77
|
+
_linearlySpace(from: number, to: number, length: number): number[];
|
78
|
+
_createHexagons(g: d3.Selection<SVGGElement, number, SVGGElement, unknown>, data: HexbinData[]): void;
|
79
|
+
_getExtent(bins: HexbinBin<HexbinData>[], valueFn: (d: HexbinBin<HexbinData>) => number, scaleExtent: [number, number | undefined]): [number, number] | [undefined, undefined];
|
80
|
+
radius(): number;
|
81
|
+
radius(v: number): this;
|
82
|
+
opacity(): number;
|
83
|
+
opacity(v: number): this;
|
84
|
+
duration(): number;
|
85
|
+
duration(v: number): this;
|
86
|
+
colorScaleExtent(): [number, number | undefined];
|
87
|
+
colorScaleExtent(v: [number, number | undefined]): this;
|
88
|
+
radiusScaleExtent(): [number, number | undefined];
|
89
|
+
radiusScaleExtent(v: [number, number | undefined]): this;
|
90
|
+
colorRange(): string[];
|
91
|
+
colorRange(v: string[]): this;
|
92
|
+
radiusRange(): [number, number];
|
93
|
+
radiusRange(v: [number, number]): this;
|
94
|
+
colorScale(): d3.ScaleLinear<string, string>;
|
95
|
+
colorScale(v: d3.ScaleLinear<string, string>): this;
|
96
|
+
radiusScale(): d3.ScaleLinear<number, number>;
|
97
|
+
radiusScale(v: d3.ScaleLinear<number, number>): this;
|
98
|
+
lng(): (d: L.LatLngExpression) => number;
|
99
|
+
lng(v: (d: L.LatLngExpression) => number): this;
|
100
|
+
lat(): (d: L.LatLngExpression) => number;
|
101
|
+
lat(v: (d: L.LatLngExpression) => number): this;
|
102
|
+
colorValue(): (d: HexbinData[]) => number;
|
103
|
+
colorValue(v: (d: HexbinData[]) => number): this;
|
104
|
+
radiusValue(): (d: HexbinData[]) => number;
|
105
|
+
radiusValue(v: (d: HexbinData[]) => number): this;
|
106
|
+
fill(): (d: HexbinData[]) => string;
|
107
|
+
fill(v: (d: HexbinData[]) => string): this;
|
108
|
+
data(): L.LatLngExpression[];
|
109
|
+
data(v: L.LatLngExpression[]): this;
|
110
|
+
dispatch(): import('d3').Dispatch<SVGPathElement>;
|
111
|
+
hoverHandler(): HexbinHoverHandler;
|
112
|
+
hoverHandler(v: HexbinHoverHandler): this;
|
113
|
+
getLatLngs(): L.LatLng[];
|
114
|
+
toGeoJSON(): GeoJSON.Feature<GeoJSON.MultiPoint, L.LatLng>;
|
115
|
+
}
|
116
|
+
export declare function hexbinLayer(options?: HexbinLayerConfig): HexbinLayer;
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { HexbinLayer as CHexbinLayer, HexbinLayerConfig as IHexbinLayerConfig, hexbinLayer } from './HexbinLayer';
|
2
|
+
import { default as HexbinHoverHandler, HexbinHoverHandler as IHexbinHoverHandler } from './HexbinHoverHandler';
|
3
|
+
declare module 'leaflet' {
|
4
|
+
interface HexbinLayer extends CHexbinLayer {
|
5
|
+
}
|
6
|
+
interface HexbinLayerConfig extends IHexbinLayerConfig {
|
7
|
+
}
|
8
|
+
interface HexbinHoverHandler extends IHexbinHoverHandler {
|
9
|
+
}
|
10
|
+
function hexbinLayer(config?: HexbinLayerConfig): HexbinLayer;
|
11
|
+
}
|
12
|
+
export { HexbinHoverHandler, CHexbinLayer as HexbinLayer, hexbinLayer, type IHexbinLayerConfig as HexbinLayerConfig };
|
package/package.json
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
{
|
2
|
+
"name": "leaflet-hexbin",
|
3
|
+
"version": "0.0.1",
|
4
|
+
"private": false,
|
5
|
+
"type": "module",
|
6
|
+
"license": "MIT",
|
7
|
+
"description": "Leaflet plugin to create hexbin layers",
|
8
|
+
"homepage": "https://lsdch.github.io/leaflet-hexbin/",
|
9
|
+
"repository": {
|
10
|
+
"type": "git",
|
11
|
+
"url": "git+https://github.com/lsdch/leaflet-hexbin.git"
|
12
|
+
},
|
13
|
+
"bugs": {
|
14
|
+
"url": "https://github.com/lsdch/leaflet-hexbin/issues"
|
15
|
+
},
|
16
|
+
"author": {
|
17
|
+
"email": "ls.duchemin@gmail.com",
|
18
|
+
"name": "Louis Duchemin",
|
19
|
+
"url": "https://github.com/lsdch"
|
20
|
+
},
|
21
|
+
"main": "dist/index.umd.js",
|
22
|
+
"module": "dist/index.es.js",
|
23
|
+
"types": "dist/types/index.d.ts",
|
24
|
+
"exports": {
|
25
|
+
".": {
|
26
|
+
"types": "./dist/types/index.d.ts",
|
27
|
+
"import": "./dist/index.es.js",
|
28
|
+
"require": "./dist/index.umd.js"
|
29
|
+
}
|
30
|
+
},
|
31
|
+
"files": [
|
32
|
+
"dist/"
|
33
|
+
],
|
34
|
+
"dependencies": {
|
35
|
+
"d3": "^7.9.0",
|
36
|
+
"d3-hexbin": "^0.2.2",
|
37
|
+
"leaflet": "^1.9.4"
|
38
|
+
},
|
39
|
+
"peerDependencies": {
|
40
|
+
"geojson": "^0.5.0"
|
41
|
+
},
|
42
|
+
"devDependencies": {
|
43
|
+
"@tsconfig/node22": "^22.0.0",
|
44
|
+
"@types/d3": "^7.4.3",
|
45
|
+
"@types/d3-hexbin": "^0.2.5",
|
46
|
+
"@types/jsdom": "^21.1.7",
|
47
|
+
"@types/leaflet": "^1.9.16",
|
48
|
+
"@types/node": "^22.10.7",
|
49
|
+
"@vitest/eslint-plugin": "1.1.25",
|
50
|
+
"eslint": "^9.18.0",
|
51
|
+
"jiti": "^2.4.2",
|
52
|
+
"jsdom": "^26.0.0",
|
53
|
+
"npm-run-all2": "^7.0.2",
|
54
|
+
"typescript": "~5.7.3",
|
55
|
+
"vite-plugin-dts": "^4.5.0"
|
56
|
+
},
|
57
|
+
"scripts": {
|
58
|
+
"dev": "vite",
|
59
|
+
"build": "tsc && vite build",
|
60
|
+
"preview": "vite preview",
|
61
|
+
"test:unit": "vitest",
|
62
|
+
"build-only": "vite build",
|
63
|
+
"type-check": "tsc --build",
|
64
|
+
"lint": "eslint . --fix",
|
65
|
+
"format": "prettier --write src/"
|
66
|
+
}
|
67
|
+
}
|