Skip to content

Commit a4e8d0d

Browse files
authored
SVG point symbols rework, fixes, processing time breakdown, new example polygons_c2 (#6)
merge dev into main
1 parent 6269669 commit a4e8d0d

12 files changed

+3565
-60
lines changed

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,20 @@ Aims to simplify data visualization and creation of elegant thematic web maps wi
3535
## Demo
3636
All features in the examples listed here have binded tooltips (a default Leaflet feature) for an easier check of attribute values.
3737
- combined (three layers): [./examples/combined.html](https://balladaniel.github.io/leaflet-dataclassification/examples/combined.html)
38-
- points (color): [./examples/points_c.html](https://balladaniel.github.io/leaflet-dataclassification/examples/points_c.html)
39-
- points (size, with diamond-shaped symbols): [./examples/points_s.html](https://balladaniel.github.io/leaflet-dataclassification/examples/points_s.html)
40-
- lines (color): [./examples/lines_c.html](https://balladaniel.github.io/leaflet-dataclassification/examples/lines_c.html)
41-
- lines (width): [./examples/lines_w.html](https://balladaniel.github.io/leaflet-dataclassification/examples/lines_w.html)
42-
- polygons (color): [./examples/polygons_c.html](https://balladaniel.github.io/leaflet-dataclassification/examples/polygons_c.html)
43-
- polygons (hatch fill, with both width/angle as distinction): [./examples/polygons_h.html](https://balladaniel.github.io/leaflet-dataclassification/examples/polygons_h.html)
38+
- points (color, 92 points): [./examples/points_c.html](https://balladaniel.github.io/leaflet-dataclassification/examples/points_c.html)
39+
- points (size, 471 points with diamond-shaped symbols): [./examples/points_s.html](https://balladaniel.github.io/leaflet-dataclassification/examples/points_s.html)
40+
- lines (color, 4879 lines): [./examples/lines_c.html](https://balladaniel.github.io/leaflet-dataclassification/examples/lines_c.html)
41+
- lines (width, 109 lines): [./examples/lines_w.html](https://balladaniel.github.io/leaflet-dataclassification/examples/lines_w.html)
42+
- polygons (color, 16 polygons): [./examples/polygons_c.html](https://balladaniel.github.io/leaflet-dataclassification/examples/polygons_c.html)
43+
- polygons (color 2, 3220 polygons): [./examples/polygons_c2.html](https://balladaniel.github.io/leaflet-dataclassification/examples/polygons_c2.html)
44+
- polygons (hatch fill, with both width/angle as distinction, 334 polygons): [./examples/polygons_h.html](https://balladaniel.github.io/leaflet-dataclassification/examples/polygons_h.html)
4445

4546
## Requirements
4647
- [Leaflet](https://github.com/Leaflet/Leaflet) (tested with v1.9.4)
4748
### External dependencies
4849
- [simple-statistics.js](https://github.com/simple-statistics/simple-statistics) (tested with v7.8.0)
4950
- [chroma.js](https://github.com/gka/chroma.js) (tested with v2.4.0)
50-
- [leaflet-hatchclass](https://github.com/samanbey/leaflet-hatchclass)
51+
- [leaflet-hatchclass](https://github.com/samanbey/leaflet-hatchclass) (only if you intend to use hatch pattern fills for polygons)
5152

5253
Include dependencies plus `leaflet-dataclassification.css` and `leaflet-dataclassification.js` in your code. You can also link them through GitHub Pages:
5354
``` html

examples/combined.html

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@
1212

1313
<!-- plugin: -->
1414
<script src="../leaflet-dataclassification.js"></script>
15-
<link rel="stylesheet" href="../leaflet-dataclassification.css" />
15+
<link rel="stylesheet" href="../leaflet-dataclassification.css" />
16+
1617
<!-- dependencies locally: -->
17-
<script src="../lib/simple-statistics.min.js"></script>
18-
<script src="../lib/chroma.min.js"></script>
18+
<script src="../lib/simple-statistics.min.js"></script> <!-- https://github.com/simple-statistics/simple-statistics -->
19+
<script src="../lib/chroma.min.js"></script> <!-- https://github.com/gka/chroma.js -->
1920

2021
<style>
2122
html, body {
@@ -85,9 +86,6 @@
8586
function tooltip(feature, layer) {
8687
if (feature.properties.name && feature.properties.population) {
8788
layer.bindTooltip('<b>' + feature.properties.name + '</b><br>' + parseInt(feature.properties.population));
88-
layer.on('mousemove',e=>{
89-
e.target.getTooltip().setLatLng(e.latlng);
90-
});
9189
}
9290
}
9391
window.testdata2 = L.dataClassification(d, {
@@ -96,8 +94,8 @@
9694
field: 'population',
9795
pointMode: 'size',
9896
pointSize: {
99-
min: 3.7,
100-
max: 12
97+
min: 3.5,
98+
max: 14
10199
},
102100
classRounding: -4,
103101
legendTitle: 'Population of capitals',
@@ -197,13 +195,13 @@
197195
}).addTo(map);
198196
});
199197

200-
map.fitBounds([[17, -150],[68, -65]]);
198+
map.fitBounds([[17, -140],[68, -65]]);
201199

202200
var infopanel = L.control({position: 'bottomright'});
203201
infopanel.onAdd = function (map) {
204202
var div = L.DomUtil.create('div', 'info');
205203
div.innerHTML +=
206-
'<div style="display: flex; flex-direction: column; max-width: 500px; text-align: center; row-gap: 8px">' +
204+
'<div style="display: flex; flex-direction: column; max-width: 515px; text-align: center; row-gap: 8px">' +
207205
'<div style="font-weight: bold; margin-bottom: 5px;">' +
208206
'Leaflet-dataclassification plugin demo page: "combined"' +
209207
'</div>'+
@@ -216,7 +214,9 @@
216214
'<div>'+
217215
'Single-step data classification, symbology and legend creation for GeoJSON data powered thematic maps.'+
218216
'<br><br>'+
219-
'Project page: <a href="https://github.com/balladaniel/leaflet-dataclassification">https://github.com/balladaniel/leaflet-dataclassification</a>'+
217+
'Demos: <a href="./points_c.html">points_c</a>, <a href="./points_s.html">points_s</a>, <a href="./lines_c.html">lines_c</a>, <a href="./lines_w.html">lines_w</a>, <a href="./polygons_c.html">polygons_c</a>, <a href="./polygons_c2.html">polygons_c2</a>, <a href="./polygons_h.html">polygons_h</a>'+
218+
'<br><br>'+
219+
'Project page: <b><a href="https://github.com/balladaniel/leaflet-dataclassification">https://github.com/balladaniel/leaflet-dataclassification</a></b>'+
220220
'</div>'+
221221
'<a href="https://github.com/balladaniel/leaflet-dataclassification" target="_blank"><img src="banner.png" style="max-width: 100%;"></img></a>'+
222222
'</div>';

0 commit comments

Comments
 (0)