Choropleth for Leaflet Map
WordPress Plugin: Choropleth for Leaflet Map
by hupe13 · github.com/hupe13/chloropleth-leaflet-map · website
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/hupe13/chloropleth-leaflet-map/archive/refs/heads/main.zipDescription
Code for using the Choropleth plugin for Leaflet (color scale based on value) in WordPress: https://github.com/timwis/leaflet-choropleth.
XSS and why excluded
While fixing a XSS vulnerability in this shortcode, I discovered a bug that has been there for at least two years. For that reason, and since no one has complained, I decided to remove that part from Extensions for Leaflet Map.
This plugin needs Extensions for Leaflet Map version > 5.4 or its Github version > 5.4-260808.
Shortcode
The shortcode has changed!! Do not forget hoverlap!
[leaflet-map fitbounds ....]
[leaflet-geojson src=https://domain.tld/path/to/file.geojson]Property1 {property1}<br>{property2} Property2[/leaflet-geojson]
[choropleth valueProperty="property1" scale="white, red" steps=5 mode=e legend fillopacity=0.8]
[hoverlap]
[zoomhomemap]
Popup Content
Specify the popup content in leaflet-geojson shortcode: To add feature properties to the popups, use the inner content and curly brackets to substitute the values:
You can specify Property1 {property1}<br>{property2} Property2 as you like.
[leaflet-geojson ...]Field A = {field_a}[/leaflet-geojson]
Options
| Option | Default | Description | Example |
| valueproperty | which property in the features to use | property | |
| scale | white, red | a comma separated list of colors for scale - include as many as you like | "white, red, blue" |
| fillopacity | 0.8 | opacity of the colors in scale | 0.8 |
| steps | 5 | number of breaks or steps in range | 5 |
| mode | q | q for quantile, e for equidistant, k for k-means | q |
| legend | 1 | show legend | !legend |
| hover | 1 | get a tooltip on mouse over | !hover |
mode
- quantile maps try to arrange groups so they have the same quantity.
- equidistant: divide the classes into equal groups.
- k-means: each standard deviation becomes a class.
Installation
- First you need to install and configure the plugins Leaflet Map and Extensions for Leaflet Map.
- Download the zip file and upload it via WordPress Admin.
- Activate the plugin.
- Go to Settings - Leaflet Map - Extensions for Leaflet Map - Choropleth Map and get documentation and settings options.
- Watch the repository to get updates.