All Projects → timwis → Leaflet Choropleth

timwis / Leaflet Choropleth

Licence: mit
Choropleth plugin for Leaflet (color scale based on value)

Programming Languages

javascript
184084 projects - #8 most used programming language

Labels

Projects that are alternatives of or similar to Leaflet Choropleth

Pinpoint
JavaScript library for creating beautifully simple maps in seconds
Stars: ✭ 83 (-39.86%)
Mutual labels:  leaflet
Flutter map marker cluster
Provides beautiful animated marker clustering functionality for flutter_map. Inspired by Leaflet.markercluster
Stars: ✭ 101 (-26.81%)
Mutual labels:  leaflet
React Leaflet Heatmap Layer
A custom layer for heatmaps in react-leaflet
Stars: ✭ 122 (-11.59%)
Mutual labels:  leaflet
Meteor Leaflet
Leaflet.js for Meteor.js
Stars: ✭ 87 (-36.96%)
Mutual labels:  leaflet
Readsb
Readsb is a Mode-S/ADSB/TIS decoder for RTLSDR, BladeRF, Modes-Beast and GNS5894 devices.
Stars: ✭ 91 (-34.06%)
Mutual labels:  leaflet
Leaflet Wfst
OGC WFS-T client layer for Leaflet.
Stars: ✭ 111 (-19.57%)
Mutual labels:  leaflet
Quizzity
A fast-paced geography quiz
Stars: ✭ 80 (-42.03%)
Mutual labels:  leaflet
Leaflet.canvaslayer.field
Load and style Raster files in Leaflet (geotiff & asciigrid)
Stars: ✭ 128 (-7.25%)
Mutual labels:  leaflet
Leaflet.browser.print
A leaflet plugin which allows users to print the map directly from the browser
Stars: ✭ 94 (-31.88%)
Mutual labels:  leaflet
Leaflet Iiif
Leaflet plugin for viewing IIIF images
Stars: ✭ 116 (-15.94%)
Mutual labels:  leaflet
Leaflet Elevation
Leaflet plugin that allows to add elevation profiles using d3js
Stars: ✭ 88 (-36.23%)
Mutual labels:  leaflet
Leaflet Gps
Simple leaflet control plugin for tracking gps position
Stars: ✭ 90 (-34.78%)
Mutual labels:  leaflet
Leaflet Providers
An extension to Leaflet that contains configurations for various free tile providers.
Stars: ✭ 1,603 (+1061.59%)
Mutual labels:  leaflet
Leaflet.layergroup.collision
Leaflet plugin for uncluttering L.Markers using basic collision detection.
Stars: ✭ 82 (-40.58%)
Mutual labels:  leaflet
Kepler
The open source full-stack geosocial network platform
Stars: ✭ 125 (-9.42%)
Mutual labels:  leaflet
Vue Leaflet
vue-leaflet compatible with vue3
Stars: ✭ 82 (-40.58%)
Mutual labels:  leaflet
Leaflet.deflate
Deflates lines and polygons to a marker when their screen size becomes too small in lower zoom levels.
Stars: ✭ 111 (-19.57%)
Mutual labels:  leaflet
Vue2leaflet
Vue 2 components for Leaflet maps
Stars: ✭ 1,809 (+1210.87%)
Mutual labels:  leaflet
Flutter map
A Flutter map widget inspired by Leaflet
Stars: ✭ 1,886 (+1266.67%)
Mutual labels:  leaflet
Leaflet.geodesic
Add-on to draw geodesic lines with leaflet
Stars: ✭ 113 (-18.12%)
Mutual labels:  leaflet

Leaflet Choropleth Build Status js-standard-style

NPM

Choropleth plugin for Leaflet (color scale based on value) - Demo

screenshot

This plugin extends L.geoJson, giving each feature a style.fillColor that corresponds to a specified value in its properties object. For information on how to use L.geoJson, see the Leaflet tutorial and documentation.

While Leaflet provides a choropleth tutorial, that approach requires you to specify exact breakpoints and colors. This plugin uses chroma.js to abstract that for you. Just tell it which property in the GeoJSON to use and some idea of the color scale you want.

Usage

L.choropleth(geojsonData, {
	valueProperty: 'incidents', // which property in the features to use
	scale: ['white', 'red'], // chroma.js scale - include as many as you like
	steps: 5, // number of breaks or steps in range
	mode: 'q', // q for quantile, e for equidistant, k for k-means
	style: {
		color: '#fff', // border color
		weight: 2,
		fillOpacity: 0.8
	},
	onEachFeature: function(feature, layer) {
		layer.bindPopup(feature.properties.value)
	}
}).addTo(map)

Advanced

  • colors: If you prefer to specify your own exact colors, use colors: ['#fff', '#777', ...] instead of scale. Just make sure the number of colors is the same as the number of steps specified.
  • valueProperty: To use computed values (such as standardizing), you can use a function for valueProperty that is passed (feature) and returns a number (example).

Installation

  • via NPM: npm install leaflet-choropleth
  • via Bower: bower install leaflet-choropleth

Include dist/choropleth.js from this repository on your page after Leaflet:

<script src="path/to/leaflet.js"></script>
<script src="path/to/choropleth.js"></script>

Or, if using via CommonJS (Browserify, Webpack, etc.):

var L = require('leaflet')
require('leaflet-choropleth')

Examples

Development

This project uses webpack to build the JavaScript and standard for code style linting.

  • While developing, use npm run watch to automatically rebuild when files are saved
  • Use npm test to run unit tests and code style linter
  • Before committing dist/, use npm run build to optimize and minify for production use
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].