Leaflet.heat

repository·gh-pages·Indexed 23 days ago

https://github.com/leaflet/leaflet.heat

A lightweight and fast heatmap plugin for Leaflet version 0.2.0. It utilizes simpleheat and clusters points into a grid for improved performance. Provides the L.heatLayer class for creating heatmap layers with configurable options for opacity, zoom, intensity, radius, blur, and color gradients, along with methods to dynamically update data via setLatLngs and addLatLng.

Tokens
468
Snippets
2
Records
4
Agent score
32%

What's inside leaflet.heat

  1. Configure L.heatLayer options

    gh-pages

    The options object for L.heatLayer accepts the following configuration keys:

    • minOpacity: The minimum opacity the heat will start at.
    • maxZoom: Zoom level where the points reach maximum intensity (intensity scales with zoom). Defaults to the map's maxZoom.
    • max: Maximum point intensity. Defaults to 1.0.
    • radius: Radius of each "point" of the heatmap. Defaults to 25.
    • blur: Amount of blur. Defaults to 15.
    • gradient: Color gradient configuration, e.g. {0.4: 'blue', 0.65: 'lime', 1: 'red'}.
    • pane: Map pane where the heat will be drawn. Defaults to 'overlayPane'.
  2. Manage heatmap data and appearance with methods

    gh-pages

    The heatmap layer instance provides several methods to update the data or visual configuration dynamically:

    • setOptions(options): Sets new heatmap options and redraws the layer.
    • addLatLng(latlng): Adds a new point to the heatmap and redraws it.
    • setLatLngs(latlngs): Resets the heatmap with a new array of points and redraws it.
    • redraw(): Manually triggers a redraw of the heatmap.
  3. Create a heatmap layer with L.heatLayer

    gh-pages

    Use L.heatLayer(latlngs, options) to construct a heatmap layer.

    Each point in the latlngs array can be an array in the format [lat, lng, intensity] or a Leaflet LatLng object. The third value (intensity/altitude) represents the point's weight. Unless the max option is specified, intensity should range between 0.0 and 1.0.

    var heat = L.heatLayer([
    	[50.5, 30.5, 0.2], // lat, lng, intensity
    	[50.6, 30.4, 0.5],
    	...
    ], {radius: 25}).addTo(map);