The Leaflet Choropleth module provides advanced choropleth mapping capabilities for Drupal applications, enabling the visualization of statistical data through color-coded geographic regions. This module seamlessly integrates with the existing Leaflet and Geofield ecosystem to deliver professional-grade thematic mapping functionality.
Installation
Composer Installation
composer require drupal/leaflet_choropleth
Module Installation
Via Drupal Admin UI:
- Navigate to
/admin/modules
- Search for "Leaflet Choropleth"
- Check the module checkbox
- Click "Install"
Via Drush:
drush en leaflet_choropleth
Configuration and Usage
View Style Integration
The module provides a leaflet_choropleth_map view style plugin that
integrates seamlessly with the leaflet_map view style from the leaflet_view
submodule.
This integration adds and enables an additional "Choropleth Map Settings"
section where to configure choropleth-specific settings alongside standard
leaflet mapping options.
Usage requirements and setup
The choropleth visualization applies only to features with polygon or
multipolygon geometry types.
To enable a choropleth map for your data, follow these steps:
- create a leaflet_choropleth_map view that includes Drupal content or
entities with a numeric field (integer or float) to be used as the basis for
the choropleth data visualization
- in the "Choropleth Map Settings" section enable the Choroplath Map option and
set the data source to the desired numeric field
- configure additional settings such as classification methods, color scale,
number of classes, geometries display options, legend configuration and other
display preferences
Classifications and Color Ranges
The module implements a robust plugin system for data classification and color
schemes:
Classification Methods:
- Equal Interval: Divides data into equal-sized ranges
- Geometric Interval: Creates class breaks based on geometric progression
- Natural Breaks (Jenks): Optimizes class boundaries to minimize variance
- Quantile: Divides data into equal-sized groups
- Standard Deviation: Classes based on statistical deviation from mean
- Etc: additional classification methods (custom implementations)
available through the plugin system
Color Ranges:
- Sequential: Single-hue progressions (Blues, Greens, Reds, Grays)
- Diverging: Two-color endpoints with neutral midpoint (Red-Blue)
- Categorical: Distinct colors for categorical data
- Etc: additional color ranges (custom implementations)
available through the plugin system
Legend Configuration
The module provides a configurable legend system that can be:
- Added as a Leaflet Control directly within the map
- Positioned anywhere on the map interface
- Fully customized for styling and content
- Integrated with the choropleth theming system
Theming Integration
Leaflet choropleth layers can be seamlessly integrated and mixed with existing
leaflet mapping features, allowing for:
- Combining choropleth analysis with marker & geometries visualizations
- Multi-layer mapping compositions, with flexible theming and styling options
Dependencies
- Leaflet module (& its Leaflet Views submodule)
Development Status and Roadmap
The Leaflet Choropleth module is being developed and deployed to
the Drupal community for testing and review, with the intention of eventual
integration into the main Leaflet module as a leaflet_choropleth submodule
once thoroughly validated and consolidated by the community.