A MapLibre layer of any type.
<HoloMap.Layer
id="parcels-fill"
type="fill"
source="parcels"
paint={%{fill_color: "#3b82f6", fill_opacity: 0.4}}
/>Prefer the type-specific components: HoloMap.Layer.Fill,
HoloMap.Layer.Line, HoloMap.Layer.Circle, HoloMap.Layer.Symbol,
HoloMap.Layer.Raster, HoloMap.Layer.Heatmap, HoloMap.Layer.Hillshade,
HoloMap.Layer.ColorRelief, HoloMap.Layer.FillExtrusion and
HoloMap.Layer.Background. They document the paint properties that
apply to them and reject a mismatched type at compile time. Reach for this
one when the type is computed at runtime. A layer drawn by WebGL code of
your own, such as a three.js scene, is a HoloMap.Layer.Custom.
Props
| Prop | Type | Notes |
|---|---|---|
id | string | Required. The layer id, and its identity across re-renders |
type | string | Required here, fixed in the type-specific components |
source | string | The id of a source component |
source_layer | string | Required for vector sources |
paint | map | Paint properties. Atom keys are dasherized: fill_color becomes "fill-color" |
layout | map | Layout properties, dasherized the same way |
filter | list | A MapLibre filter expression |
min_zoom / max_zoom | number | Zoom range |
before_id | string | Insert beneath this layer. Ignored while that layer is absent |
visible | boolean | Convenience for layout.visibility |
metadata | map | Arbitrary data carried on the layer |
expand_cluster_on_click | boolean | A click on a cluster zooms in to where it breaks apart; see below |
Ordering
Layers stack in the order the components appear in the template. That holds
for a layer rendered conditionally, one re-added because its type, source
or source_layer changed, and the layers of a rebuilt source: each goes back
to its place rather than on top. before_id overrides that when a layer has
to sit beneath one it is not written next to, such as a highlight layer under a
label layer that belongs to the base style, for example. It can name a layer
declared further down, or one rendered later, and takes effect once that
layer is on the map. Changing before_id moves the layer.
Events
on_click, on_dbl_click, on_context_menu, on_mouse_enter,
on_mouse_leave, on_mouse_over, on_mouse_out, on_mouse_move,
on_mouse_down, on_mouse_up, on_touch_start, on_touch_end,
on_touch_cancel. In MapLibre GL JS 6, on_mouse_over fires as
on_mouse_enter does, and on_mouse_out as on_mouse_leave.
Handlers receive layer, lng_lat, point and features, which holds the features
under the pointer, each with id, source, source_layer, properties and
geometry:
def action(:parcel_clicked, params, component) do
case params.features do
[%{properties: %{parcel_id: id}} | _rest] -> put_state(component, :selected, id)
[] -> component
end
endExpanding clusters
On a layer that draws the clusters of a clustered HoloMap.Source.GeoJSON,
expand_cluster_on_click makes a click on a cluster ease the camera to the
cluster's point, at the zoom where it breaks apart, as MapLibre's
getClusterExpansionZoom gives it. The browser does it all, with no
action and no round trip:
<HoloMap.Layer.Circle id="clusters" source="stops"
filter={["has", "point_count"]}
expand_cluster_on_click />- A click whose top feature on the layer is not a cluster, one with no
cluster_idproperty, does nothing more, so the layer may draw single points too. on_clickstill hears the click, with the features as they were clicked. It is dispatched first; the camera starts to move once the source's worker has worked out the zoom, a moment later.- The move is MapLibre's
easeTowith its default duration and easing, and it is not configurable here. It is reported to the map'son_move_endand the other move events, as a user's move is. For a move of your own, such as a shorter one, leave this off and callHoloMap.API.expand_cluster/4fromon_click, which takes the options ofHoloMap.API.ease_to/2. - A source that is not clustered has no expansion zoom: the camera stays put, with a console warning.
Summary
Functions
Returns true to indicate that the callee module is a component module (has "use Hologram.Component" directive).
Returns the list of property definitions for the compiled component.
Functions
@spec __is_hologram_component__() :: boolean()
Returns true to indicate that the callee module is a component module (has "use Hologram.Component" directive).
Examples
iex> __is_hologram_component__()
true
Returns the list of property definitions for the compiled component.