Skip to content

geojson_layer

Stable

Draws GeoJSON data as a fill, line, circle, symbol, heatmap or fill-extrusion layer, with optional clustering and feature events.

Generated from the component's definition in the library, so it always matches the version this demo runs.

Attribute Type Default Description
id required string — Unique identifier for the layer
map_id required string — ID of the map to add the layer to
data required any — GeoJSON data: a map, JSON text, or a URL the browser fetches (see "Data" in the module docs). With an id on every feature, only what changed goes to the map (see "Updating part of the data")
type required string — Layer type: "fill", "line", "circle", "symbol", "heatmap", or "fill-extrusion"
paint map %{} Paint properties for styling the layer
layout map %{} Layout properties for the layer
filter any nil Filter expression to show only specific features
min_zoom integer nil Minimum zoom level to show the layer
max_zoom integer nil Maximum zoom level to show the layer
before_id string nil ID of layer to insert this layer before
source_layer string nil For vector sources, the source layer to use
cluster boolean false Enable point clustering. Defaults to false
cluster_max_zoom integer 14 Maximum zoom to cluster points. Defaults to 14
cluster_radius integer 50 Cluster radius in pixels. Defaults to 50
cluster_properties map nil Aggregate properties for clusters
generate_id boolean false Generate unique IDs for features. Defaults to false
promote_id string nil The name of a feature property that MapLibre takes each feature's id from, such as "uuid"; passed to the source as promoteId. Feature state then addresses a feature by that property, in feature_state and from your own JavaScript: map.setFeatureState({source: "<id>-source", id: feature.properties.uuid}, ...). It excludes generate_id, which numbers the features in order, so that their ids change with the data: giving both raises an ArgumentError. The ids it gives also let the layer give the map only what changed in new data (see "Updating part of the data").
global attributes global — Any other HTML attribute, passed on to the component's element.
events any [] a list of event names, or :all
cursor string nil a CSS cursor to show over the features, such as "pointer"
transition integer nil how long a point feature with an id takes to move to a new position, in milliseconds; nil or 0 jumps
transition_heading string nil the name of the property holding a point's heading, which turns the short way during a move
transition_max_distance any nil the longest move, in metres on the ground: a longer one jumps; nil for no limit
feature_state map nil a map of feature id => map of state, which paint properties read with feature-state
hit_width any nil a number of pixels: the layer answers the pointer within that many pixels of what it draws
hover boolean false whether the feature under the pointer has the feature state hover, set in the browser
cluster_expand_on_click boolean false whether a click on a cluster moves the camera to where it breaks apart, in the browser
label_points boolean false whether the layer keeps a source of points, "<id>-labels", one inside each polygon, for labels

Slots

  • cluster_marker HTML drawn for each cluster, a template filled in the browser from the cluster's properties; needs `cluster`