Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Polygon hatch fills, legend improvements
- new feature: Polygon hatch fill patterns as the way of distinction between class symbols (thanks to https://github.com/samanbey/leaflet-hatchclass). Has three modes: 'width', 'angle' and 'both'. Width mode alters only the alternating stroke widths per class symbol, angle mode only the alternating stroke angle per class symbol, and both alters both properties to make class symbols distinct -- new option `strokeColors`: two colors of the alternating lines, as an array (example: ['darkred', 'none']) -- new option `strokeWidth`: object, with min and max properties, both with a number value, when distinctionMode: 'width' or both'. Defines hatch min/max widths to alternate between, for individual classes (example: {min: 2, max: 10}). Tip: set to -1 to have solid fills on two ends of the symbols' spectrum, only in distinctionMode: 'width' and 'both' -- new option `distinctionMode`: symbol distinction type between classes: 'angle'/'width'/'both' -- new option `angle`: initial angle of lines in pattern -- new option `alternateAngle`: value to increment angle with between hatch fill symbols. Warns if chosen alternating angle may result in very similar of duplicate symbols. -- note: a workaround was needed to apply hatch fill pattern to polygons due to Leaflet ignoring `className` in layer.setStyle(). See Leaflet/Leaflet#2662. Currently, the workaround is fine and is working as expected - new option `polygonMode`: polygon mode now supports two modes: 'color' and 'hatch' (default: 'color') - new option `legendRowGap`: legend symbology row gap in pixels. You can also alter this in the attached CSS file. (default: 3) - `style`/`radius`: defines marker shape radius (size), use only in point/color mode (default: 8, max: 10-12) - due to a smaller redesign of the legend symbology, rows are now contained in a flexbox and now have a row-gap of 3px by default. This results in symbols in polygon modes getting separated a bit. Can be overridden with option `legendRowGap`, or by editing the main CSS file directly (class ".hatchPatch") - function _stylePolygon() renamed to _stylePolygon_color(), to accomodate the existence of _stylePolygon_hatch() - function _svgCreator(): removed hardcoded styling "margin-right: 10px", included in CSS now - legend reflects custom point symbol size (`style`/`radius`) now - reworked legend to support `polygonMode` - legend now constructs its contents individually and appends content with div.appendChild() to the main legend div - added dependency: https://github.com/samanbey/leaflet-hatchclass, included in ./lib/ - updated documentation and inline JSDoc - updated main screenshots, added a new section and screenshot in documentation, showcasing hatch symbol distinction modes - examples: -- renamed example `polygons.html` to `polygons_c.html` -- new example `polygons_h.html`: showcases the use of hatch fill patterns -- new dataset `polygons_hatch_eu_lifeexp_2018.geojson`: for use in `polygons_h.html` -- all: fixed inline comments -- combined: swapped default layer OSM with CARTO Voyager -- lines_c: swapped default layer OSM with CARTO Voyager, modified legend title -- lines_w: swapped default layer OSM with CARTO Positron, modified some options -- points_c: swapped default layer OSM with CARTO Voyager, modified legend title, added style/radius to showcase symbol size altering in point/color mode
- Loading branch information