heatmap_layer
StableShows the density of points from a source as a heatmap.
Points of interest in central Paris from OpenStreetMap, in OpenFreeMap's tiles: shops, cafés, museums and the like.
- @radius
- 10
- @intensity
- 0.3
- @on_map
- false
<div id="heatmap-layer-example">
<.example_frame error={@map_error} error_id="example-heatmap-map-error">
<.map
id="example-heatmap-map"
center={[2.3488, 48.8606]}
zoom={14}
style={basemap(@theme)}
events={["map:error"]}
class="h-full w-full"
/>
</.example_frame>
<%!-- OpenFreeMap's TileJSON: OpenStreetMap in the OpenMapTiles schema. --%>
<.vector_tile_source
id="example-heatmap-osm"
map_id="example-heatmap-map"
url="https://tiles.openfreemap.org/planet"
events={["source:error"]}
/>
<.heatmap_layer
id="example-heatmap-layer"
map_id="example-heatmap-map"
source_id="example-heatmap-osm"
source_layer="poi"
paint={paint(@radius, @intensity)}
events={["layer:added"]}
/>
<div class="space-y-3 border-t border-line px-4 py-4">
<.form
for={@options}
id="example-heatmap-options"
phx-change="options"
class="grid w-full gap-4 sm:max-w-lg sm:grid-cols-2"
>
<.example_range field={@options[:radius]} label="heatmap-radius" min="2" max="40" />
<.example_range
field={@options[:intensity]}
label="heatmap-intensity"
min="0.1"
max="2"
step="0.1"
/>
</.form>
<.example_note id="example-heatmap-data" icon="hero-map-micro">
{gettext(
"Points of interest in central Paris from OpenStreetMap, in OpenFreeMap's tiles: shops, cafés, museums and the like."
)}
</.example_note>
</div>
<%!-- layer:added sets on_map. --%>
<.example_readout values={[radius: @radius, intensity: @intensity, on_map: @on_map]} />
</div>