All notable changes to this project are documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

Unreleased

0.4.0 - 2026-11-30

Components push only the events they are given, <.sky> draws MapLibre's sky, and <.deckgl_layer> works on maplibre-gl 6 as well as 5, through deck.gl 9.4's @deck.gl/maplibre. <.flow_layer> is new: particles that travel along a vector field, such as wind or ocean currents. <.geojson_layer> takes a URL as its data, and promote_id; the JavaScript API has a guide of its own, and a new export, followMap. An application written for 0.3.0 needs changes: Upgrading from 0.3.0 lists them, the likeliest first, and each item under Breaking, in the same order, has the details and its migration.

Upgrading from 0.3.0

  1. Give each component the events your LiveView handles (#45). Without events a component pushes nothing, so handle_event/3 clauses written for 0.3.0 are no longer called: <.map id="map" events={["map:moved"]} />. events={:all} keeps a component as it was in 0.3.0, and a catch-all handle_event/3 clause is no longer needed.
  2. A layer that asks for no layer:feature_* event shows no pointer cursor over its features (#45): give a layer whose features are clicked the feature event you handle, events={["layer:feature_clicked"]}.
  3. With <.deckgl_layer>, replace @deck.gl/mapbox with @deck.gl/maplibre and bring the deck.gl packages to 9.4 (#11), or an esbuild build that bundles deck.gl stops. deck.gl then works on maplibre-gl 6 too, from 6.9.1.
  4. Give <.sky> MapLibre's sky properties (sky_color for atmosphere_color, say), and handle sky:enabled and sky:disabled where you handled sky:added and sky:removed (#14). The old attributes are ignored, without a warning through import MaplibreX.Components.
  5. Draw a <.custom_layer> that used a preset with <.flow_layer> and a vector field instead (#87): preset, or a missing shader, raises.
  6. Expect deckgl:drag_end only for a drag that started on one of the layer's objects, as deckgl:drag_start is (#11).
  7. Read the data of <.geojson_layer> and <.deckgl_layer> from data-geojson and data-records, not data-config, in tests or code that read the rendered markup (#47).
  8. Expect an ArgumentError, not a Jason.DecodeError, for a <.geojson_layer> data string that is not JSON, unless it starts with { (#102).
  9. Call requireMap where a missing map should be logged: MapManager.get and useMap no longer warn (#109).

Breaking

  • A component pushes to the LiveView only the events its events attribute names, and none without it (#45). In 0.3.0 a component given no events pushed every event it emitted, and a LiveView with no handle_event/3 clause for one of them crashed on it: a plain <.map> did on map:loaded. Now a LiveView needs a clause only for the events it asks for, and the others cost no round trip. events takes a list of the component's event names, as in 0.2.1 and 0.3.0, or :all for every event the component emits. Its default is [], and nil means [] too. A name the component does not push, or a value that is neither a list nor :all, raises an ArgumentError when the component renders, naming the events it does push; each component's docs list them. Names are checked when the component renders, not at compile time: attr cannot check the names in a list, nor take both a list and :all, so the attribute is now :any. A new value applies from the next event on, without recreating the map or the component. It applies to every component that pushes events: map, marker, popup, geolocate_control, fullscreen_control, terrain_control, terrain, sky, deckgl_layer, geojson_layer, flow_layer, the layer components and the source components.

    Migration from 0.3.0. Give each component the events your LiveView handles: <.map id="map" events={["map:moved", "map:clicked"]} />. events={:all} keeps the 0.3.0 behaviour of a component, one attribute at a time; a LiveView that uses it keeps its catch-all handle_event/3 clause. A catch-all clause is no longer needed otherwise, and dropping it lets a misspelt handle_event/3 clause show. Markup written by hand for a hook, without the component, pushes nothing unless its data-config has an events key: "all", or a list of names.

  • A layer shows the pointer cursor over its features only while it asks for a feature event, one of layer:feature_clicked, layer:feature_mouseenter and layer:feature_mouseleave (#45). This applies to geojson_layer and to the layer components that push feature events: circle_layer, line_layer, fill_layer, symbol_layer and fill_extrusion_layer. In 0.3.0 they showed it whatever their events. The hover listeners that set it now attach only for a feature event (see Changed), so a layer that asks for none, whose features do nothing when clicked, shows the map's own cursor over them.

    Migration from 0.3.0. A layer whose features the user clicks asks for the event its LiveView handles, which brings the pointer back: <.circle_layer id="stops" map_id="map" source_id="stops" events={["layer:feature_clicked"]} />.

  • <.deckgl_layer> draws with MapLibreOverlay from @deck.gl/maplibre, and works on maplibre-gl 6 (#11). In 0.3.0 it used MapboxOverlay from @deck.gl/mapbox, which reads the internal map.transform that maplibre-gl 6 removed, so the component refused to load on v6 and an application that used it had to pin maplibre-gl to ^5.0.0. deck.gl 9.4 added @deck.gl/maplibre for maplibre-gl 5 and 6, so the optional @deck.gl/* peer dependencies now start at 9.4 (^9.4.0), and @deck.gl/maplibre replaces @deck.gl/mapbox among them. The overlay is interleaved as before, the attributes are unchanged, and so are the events and their payloads but for deckgl:drag_end (below). Without @deck.gl/maplibre (with only @deck.gl/mapbox installed, say), or with an @deck.gl/core older than 9.4, the layer logs an error that names the packages to install, and pushes it as deckgl:error. With maplibre-gl 6, use 6.9.1 or later: before it, the MapLibre layers drawn after a deck.gl layer, such as the labels above a layer given before_id, can change size or disappear (visgl/deck.gl#10700, fixed in maplibre-gl 6.9.1).

    Migration from 0.3.0. Replace @deck.gl/mapbox with @deck.gl/maplibre, and bring the other deck.gl packages to 9.4:

    npm uninstall --prefix assets @deck.gl/mapbox
    npm install --prefix assets @deck.gl/core@^9.4.0 @deck.gl/layers@^9.4.0 \
                                @deck.gl/aggregation-layers@^9.4.0 @deck.gl/maplibre@^9.4.0
    

    Before that, an esbuild profile that bundles deck.gl stops with Could not resolve "@deck.gl/maplibre". A profile that marks deck.gl external (--external:@deck.gl/*), for an application without it, needs no change. A maplibre-gl pinned to ^5.0.0 for deck.gl's sake can now be upgraded to 6.9.1 or later, with the worker step of the README.

  • <.sky> sets MapLibre's sky, and takes MapLibre's sky properties as its attributes (#14). In 0.3.0 it drew no sky on any supported maplibre-gl version: its hook added a layer of type "sky" with Mapbox GL sky paint properties, and MapLibre has no such layer type. Its sky is a property of the style, which the component now sets with map.setSky(). The attributes are the properties of MapLibre's sky specification, in snake_case: sky_color, horizon_color and fog_color take a color string, fog_ground_blend, horizon_fog_blend, sky_horizon_blend and atmosphere_blend a number from 0 to 1, and each takes a MapLibre expression as a list, such as ["interpolate", ["linear"], ["zoom"], 0, 1, 12, 0]. An attribute not given, or nil, has MapLibre's default; any other value raises an ArgumentError. The Mapbox attributes type, atmosphere_sun, atmosphere_sun_intensity, atmosphere_color, atmosphere_halo_color, gradient_center, gradient_radius and gradient are removed, with no deprecation, as they never drew anything. One left in a template raises nothing and is ignored, so the sky has MapLibre's default for each property; through import MaplibreX.Components, which delegates to the component, the compiler does not warn about it either (it does with import MaplibreX.Components.Sky). The events are named as the terrain component's: sky:enabled, once, the first time the component sets its sky, and sky:disabled, when it is removed and takes its sky off, both with no payload keys; sky:added and sky:removed are gone, and an events list that names them raises. Like terrain, the sky can come before or after its map, follows its attributes in place, comes back after a map style change and on a map rendered again under its id, and goes with the component, which leaves the map with no sky. MapLibre draws the sky above the horizon only: on a flat map it shows from a pitch of about 69 degrees, past MapLibre's default maximum pitch of 60, so the map needs a max_pitch too.

    Migration from 0.3.0. Replace the attributes with MapLibre's: <.sky map_id="map" type="atmosphere" atmosphere_color="#87ceeb" /> becomes <.sky map_id="map" sky_color="#87ceeb" />; remove the Mapbox attributes that have no MapLibre counterpart. handle_event/3 clauses for sky:added and sky:removed become clauses for sky:enabled and sky:disabled, and the events list names those.

  • <.custom_layer> has no presets (#87). Its ocean_currents and wind_flow presets promised a flow but drew round points of one colour at fixed places, which read no data and never moved. They are presets of the new <.flow_layer> now (see Added), which moves particles along a vector field. <.custom_layer> takes no preset attribute, and needs both vertex_shader and fragment_shader: a preset, or a missing shader, raises an ArgumentError when the component renders, saying where the presets went.

    Migration from 0.3.0. A layer drawn with a preset becomes a <.flow_layer> with that preset, given the field the flow follows: a u/v image, its bounds and the ranges of its channels (see the <.flow_layer> docs for the image format).

    <%!-- 0.3.0 --%>
    <.custom_layer id="currents" map_id="ocean" preset="ocean_currents" />
    
    <%!-- 0.4.0 --%>
    <.flow_layer
      id="currents"
      map_id="ocean"
      preset="ocean_currents"
      field="/fields/currents.png"
      bounds={[-180.0, -80.0, 180.0, 80.0]}
      u_range={[-2.0, 2.0]}
      v_range={[-2.0, 2.0]}
    />

    A layer that gave its own shaders and a preset for the uniforms it did not set gives those uniforms in uniforms instead: the presets' were u_color: [0.2, 0.6, 0.9], u_opacity: 0.8, u_point_size: 3.0 (ocean_currents) and u_color: [0.9, 0.9, 0.9], u_opacity: 0.6, u_point_size: 2.0 (wind_flow).

  • deckgl:drag_end is pushed for a drag that started on an object of the layer, as deckgl:drag_start and deckgl:drag are, with that layer's id (#11). In 0.3.0 the overlay's own callback pushed it at the end of any drag on the map, without a layerId when the drag did not start on one of the layer's objects. Each layer now carries its own picking callbacks, which deck.gl calls for the layer it picked.

    Migration from 0.3.0. A deckgl:drag_end clause that stood for the end of any drag on the map, a pan say, handles the map's map:moved instead; a clause for a drag of the layer's objects gets its layerId every time.

  • <.geojson_layer> renders its data in an attribute of its own, data-geojson, and <.deckgl_layer> in data-records, no longer in data-config (#47), so that a change to another attribute does not send the data again (see Changed). The components' attributes are unchanged, and markup written by hand for their hooks, with the data in data-config as 0.3.0 rendered it, keeps working: only code that reads the data back from the rendered markup is affected.

    Migration from 0.3.0. Code that reads the data from the rendered data-config, in its source.data for <.geojson_layer> or its data for <.deckgl_layer> (a test that decodes it, say), reads data-geojson or data-records instead, which hold the data alone, as JSON.

  • A <.geojson_layer> data string that is neither JSON nor a URL raises an ArgumentError naming the forms data takes (#102); in 0.3.0 it raised a Jason.DecodeError. JSON text that starts with { and does not decode still raises a Jason.DecodeError, and a string that starts with http://, https:// or /, which raised one in 0.3.0, is now a URL (see Added).

    Migration from 0.3.0. Code that rescues, or a test that asserts, a Jason.DecodeError for such a string expects an ArgumentError instead.

  • MapManager.get(mapId), and useMap(mapId), which is the same, return undefined for an id with no map without logging anything (#109). In 0.3.0 each miss logged a console warning, so code that asks whether a map exists yet, polling say, flooded the console; MapManager.get(mapId) !== undefined is now the quiet way to ask. requireMap(mapId) is unchanged: with no map it warns, then throws an Error, both naming the id. No component looked its map up with get: they wait for it with whenReady and followMap, so what they log is unchanged.

    Migration from 0.3.0. Code that counted on the warning to show a wrong id calls requireMap(mapId) where the map has to exist, or logs the miss itself.

Added

  • <.flow_layer>: particles that travel along a vector field, such as wind or ocean currents, leave trails and are coloured by speed (#86). The field is an image whose red and green channels hold the eastward and northward components of the flow, scaled between u_range and v_range, over geographic bounds; the component's docs describe the format precisely enough to produce one. particles, speed_factor, trail, particle_size, opacity and color_ramp set how it is drawn, and the wind_flow and ocean_currents presets set them for a kind of flow. Every attribute follows the assigns without rebuilding the layer: a new field (a new forecast hour, another variable) replaces the old one once it has loaded, and the particles carry on from where they are. It has before_id, min_zoom and max_zoom, comes back after a style change and on a map rendered again under its id, repaints the map continuously only while it draws within its zoom range, and releases its GPU resources and its repaint when it goes. It draws on Mercator and on the globe and needs WebGL 2. When asked for, it pushes flow:clicked with the flow at a clicked point (u, v, speed, and the direction the flow goes towards, in degrees clockwise from north) and flow:error when its field cannot be loaded. bounds, the outer edges of the image's pixels, may go up to 5 degrees past the poles and west of 180°W (#111): a grid with points on the poles and at 180°W, such as a 1° weather model grid, has pixels centred there, whose edges lie half a pixel beyond, as in [-180.5, -90.5, 179.5, 90.5].
  • followMap is exported from the package entry (#101), with the types of its callbacks, MapAttach and MapDetach, and MapReadyCallback, the type of the callback of MapManager.whenReady. followMap(mapId, attach) calls attach with the map registered under mapId as soon as there is one, and, when that map is removed, calls what attach returned with true, then attach again with the map rendered under the id in its place. The function it returns stops following, and calls what attach returned with false. It is how the components stay on a <.map> rendered again under the same id (behind :if, say); in 0.3.0 application code had to rebuild it from MapManager.whenNextRegistered.
  • <.geojson_layer> takes a URL as data (#102): an http:// or https:// URL, or a path from the root of the site, such as ~p"/data/quakes.geojson". The browser fetches it (MapLibre's setData with a URL), so a large data set served as a file or from an endpoint no longer has to go through the LiveView; it must come from the same site, or from one whose CORS headers let the page fetch it. A string that starts with http://, https:// or / is a URL, as no JSON text can start that way; any other string is JSON text, as before, and one that is neither raises (see Breaking). A new URL, or a switch between data and a URL, goes to the source with setData, as new data does.
  • <.geojson_layer> takes promote_id, the name of a feature property that MapLibre takes each feature's id from, passed to the source as promoteId (#108). Feature state then addresses a feature by that property, a UUID string say, without a top-level id on every feature: promote_id="uuid" and map.setFeatureState({source: "<id>-source", id: feature.properties.uuid}, ...). It excludes generate_id, whose ids follow the order of the data: giving both raises an ArgumentError, and so does a promote_id that is not a non-empty string. A new promote_id replaces the source under the layer, as a new generate_id does, which drops its feature state.

Changed

  • <.geojson_layer> sends its data to the browser only when the data changes (#47). LiveView sends an attribute again when an assign it is rendered from changes, and in 0.3.0 the data was part of data-config, rendered from every attribute: a change to any of them, such as a paint property driven by a slider, sent the whole data set to the browser again, which parsed it again. Now such a change sends data-config without the data, and the hook leaves the source as it is; new data sends data-geojson alone, which the hook gives to the source with setData, leaving paint, layout and filter alone. With 500 points (57 KB of GeoJSON), a change to heatmap-radius sent 102 KB and now sends 450 bytes. See Breaking for code that reads the rendered markup.
  • <.deckgl_layer> sends its data to the browser only when the data changes (#47), in data-records, as <.geojson_layer> does. A change to props or another attribute no longer sends the data again: with 500 records (20 KB of JSON), a change to getRadius sent 31 KB and now sends 461 bytes. The new deck.gl layer also gets the same data object. deck.gl rebuilds every attribute buffer of a layer given a new data object, which in 0.3.0 happened on every update; now it recomputes only what the change needs. deck.gl does not compare accessor functions, so an accessor given as a property name, such as "getPosition" => "coordinates" or ["get", "coords"], now has an update trigger of its own, which changes with the name: a new name is still applied without new data. The update_triggers given to the component apply as before.
  • <.deckgl_layer> follows the map registered under its map_id, as the other components do (#11): it can come before or after its map, and its layer moves to a <.map> removed and rendered again under the same id. In 0.3.0 it had to come after its map, logged "not found" otherwise, and stayed on the removed map. deckgl:layer_loaded still goes out once, the first time the layer is on a map.
  • A layer component attaches its click listener only while it asks for layer:feature_clicked, and its hover listeners only while it asks for one of layer:feature_clicked, layer:feature_mouseenter and layer:feature_mouseleave (#45). MapLibre runs a layer's hover listeners on every pointer move over the map, so a layer that asks for none no longer costs that; the pointer cursor, which the hover listeners set, goes with them (see Breaking). A source component attaches its sourcedata and sourcedataloading listeners, which MapLibre fires for every tile of every source, only while it asks for source:data, and its error listener only while it asks for source:error. Both follow a new events value at once. The map's own listeners, and those of markers, popups, controls and deck.gl layers, stay attached: they fire once per gesture or per user action, or keep state the component needs.
  • pushToLiveView of the exported EventDispatcher (the map hook's dispatcher, or one from createEventDispatcher, both internal exports: see the JavaScript API guide), called without a reply callback, is the way the map pushes its own events, so it follows the map's events too: for a map given none it now sends nothing. With a callback it is a request of the application's own and is sent whatever the map's events, as before, and so is pushToLiveViewTarget; both are still dropped quietly when they cannot be delivered.

Fixed

  • Several <.deckgl_layer> components on one map draw together (#11). They share the map's one deck.gl overlay, which the first one creates and the last one to go takes off the map, so a component that replaces another in one patch (behind :if, say) leaves the map with its own layer, whether LiveView mounts it before or after it destroys the other. MapLibreOverlay allows one interleaved overlay per map, and refuses a second one with "MapLibreOverlay supports one interleaved overlay per map"; in 0.3.0, with @deck.gl/mapbox, a second component took over the first one's deck.gl instance and replaced its layers. An update of a component replaces its own layer only, and its removal leaves the others drawn. Layers drawn in the same place, on top of the map or under the same before_id, are drawn in the order of their components in the template, the later over the earlier, whatever order they mount in. A picked object is pushed by the component whose layer it is, as that component's events ask. A component with the id of a deck.gl layer already on the map gets no layer, and pushes a deckgl:error that names the id; the other layer stays.
  • Quick basemap switches no longer make maplibre-gl throw "Length of new data is N, which doesn't match current length of 0" from its render loop (#94). The fault is in maplibre-gl (seen with 5.24.0, with or without terrain, and without MaplibreX). It happens when tile data arrives after the last frame and a style diff then removes the layers it belongs to: maplibre-gl still uploads that data, without the opacities of its labels. A diff that brings back layers with the same ids before the tile has reloaded then throws. Theme switches between two styles that share no label layer ids, such as OpenFreeMap's liberty and dark, do this. Terrain makes it more likely: MaplibreX diffs those styles in while the map draws 3D frames, which are slow (#78). Before it lets maplibre-gl diff a new style in, the map hook now draws one frame of the current style (map.redraw()), so that data is drawn before its layers go, and maplibre-gl never reaches the path that throws. This happens only on the diff path, for the style change still current: a style rebuilt from scratch, or the late response to a change another one replaced, draws no extra frame. If that frame throws, the error is logged and the style change goes on, diffed in as before.

Documentation

  • A JavaScript API guide, in the HexDocs extras and linked from the README (#101). It says what of the maplibrex package is public and covered by the version number (MapHooks, MapManager with whenReady, whenNextRegistered, get and isRegistered, useMap, requireMap, followMap and the types of their callbacks), with the signature and behaviour of each, and which exports are internal. It gives the ids of the sources and layers each component keeps on the map, and the rules for application code that touches them: a component re-applies a paint, layout or filter property, or its data, when the rendered value changes, and puts its layer and source back after a style change; feature state is the application's, and is gone whenever a component's source is added again, which every style change does, diffed in or rebuilt; and sources and layers the application adds go with a style change. Its code samples run in the test suite, and its signatures are checked against the API.
  • The README's installation section names the keys MapHooks adds to an application's hooks (MapHook, MarkerHook and the others), and says what happens when the application has a hook of its own under one of them (#110): one of the two is dropped, silently, by whichever spread comes last. With ...MapHooks last the components keep working; with the application's hooks last, <.map> mounts the application's MapHook and no map appears. A test checks the list against the keys of MapHooks, so it follows a hook added or renamed.

0.3.0 - 2026-11-29

Markers, popups, the control components, custom_layer and the map's own attributes now follow their assigns after mount, as layers, sources and terrain have since 0.2.0. The map can open with a camera flight (fly), stay behind a loading curtain (curtain) until its first render is complete, and be drawn as a globe (projection). No component attribute, hook name, event name or payload key was removed or renamed, and the new attributes are optional. Several fixes change behaviour an application can notice: see Changed. sky does not work, and components still push every event they emit: see Known issues.

Added

  • An opening camera flight for <.map>, fly (#56), proposed by @tmbb in #1: the map opens far out and, once its first render is complete, flies to its camera, the opening known from Google Earth. <.map center={[-9.14, 38.72]} zoom={11} fly /> starts from [80, -20] at zoom 0.8, over the Indian Ocean, and flies for 2800 ms; fly={%{from: %{center: ..., zoom: ..., bearing: ..., pitch: ...}, duration: ...}} changes either, and speed (instead of duration) and curve are MapLibre's flight options. duration and speed together, an unknown option or an invalid value raise an ArgumentError. The flight lands where the map would open without fly: its center, zoom, bearing and pitch, the configured defaults, or its bounds. It runs once per mount and gives way: with prefers-reduced-motion: reduce the map opens at its camera and does not fly; the user moving the map or a camera command stops it, or keeps it from starting; a camera the LiveView changes before or during the flight wins, and the map goes there at once. The map's own map:moved, rendered back by the LiveView, does not cut it. It ends with one map:moved where the map lands; there is no new event. fly is read at mount only, and leaves the projection alone (the flight looks best on a globe: see projection below). Off by default: a map without fly renders and behaves exactly as before.
  • A projection attribute for <.map> (#68), so that a map can be a globe with any basemap: <.map projection="globe" />. It takes the name of one of MapLibre's projections, as a string or an atom ("globe", "mercator", "vertical-perspective"; names are not checked, MapLibre warns about one it does not know and draws mercator), or a map, passed to MapLibre as its projection specification, for an expression. The map sets it with map.setProjection once its style has loaded, and again on every new style (a new style, set_style/2, map:set_style), since MapLibre 5 and 6 replace it with the new style's own projection on every style change. It follows the attribute after mount; without it again, the map goes back to the projection its style declares, or mercator. With fly, the projection is in place before the flight starts. Any other value raises an ArgumentError. Without projection (or with nil or false) the style decides, exactly as before, and the map makes no projection call.
  • A loading curtain for <.map>, curtain (#57), proposed by @tmbb in #1: an opaque cover with a loader over the map until its first render is complete, so that the visitor does not see the tiles arrive and be redrawn; it then fades out. <.map curtain /> renders it inside the map element, from the first paint; the map element keeps its id, hook and class, and the JS commands still reach it. curtain={%{timeout: ..., label: ...}} sets the longest it covers the map (8000 ms unless given: the map is shown as it is if its first render has not completed by then) and the status text for assistive technology ("Loading map"); an unknown option or an invalid value raises an ArgumentError. It also lifts at once when the style cannot be loaded. The <:loader> slot replaces the built-in loader, a CSS ring. The styles are in maplibrex.css, and applications restyle them with --maplibrex-curtain-background (Canvas unless set, the page background of a light or dark color-scheme), --maplibrex-loader-color and --maplibrex-curtain-fade (300 ms). While the curtain covers the map, the map element has aria-busy="true"; with prefers-reduced-motion: reduce there is no fade and the loader does not turn. With fly, the flight starts once the curtain is gone. curtain is read at mount only: the curtain never comes back, on a new style or anything else, and it pushes no event. Off by default: a map without curtain renders and behaves exactly as before, and the .maplibrex-map.loading rules are unchanged.
  • A focus_after_open attribute for <.popup>, and popup_focus_after_open for the popup of a <.marker> (#75): with false, the popup opens without taking the keyboard focus. MapLibre moves the focus into a popup as it opens, to its first link, button or field (or its close button), which takes it from the page control that opened it (the next Space or Enter then acts on the popup's button) or from a field the visitor is typing in when the server opens a popup. It is MapLibre's focusAfterOpen option, which MapLibre reads only when it creates a popup, so a change after mount rebuilds the popup, open if it was, as the other such options do. Both default to true: popups take the focus exactly as before.
  • New attributes and JavaScript functions that came with fixes, described under Fixed: debug on <.map> (#21); show_user_location and position_options on <.geolocate_control> (#40, #76); the --maplibrex-control-active-background, --maplibrex-control-active-hover-background and --maplibrex-control-radius custom properties of maplibrex.css (#39); and MapManager.isRegistered(mapId, map) and the optional map argument of MapManager.unregister(mapId, map) (#82).

Changed

Behaviour that an application written for 0.2.1 can notice. Most of it comes with a fix: each item names its issue, and that issue's entry under Fixed has the details.

  • A <.map> without zoom opens at zoom 10 (default_zoom), where it opened at 0, and one without style gets the configured default_style, where it had no style; a style that becomes nil after mount switches to the default style (#25).
  • A mounted <.map> follows changes to bounds, max_bounds, min_zoom, max_zoom, min_pitch, max_pitch, interactive and attribution_control, which it ignored; a map outside a new zoom or pitch range moves into it and pushes map:moved (#26).
  • On a globe, a new center given alone keeps the map's zoom, where MapLibre changed it with the latitude (#74).
  • fly_to/4, fit_bounds/3 and the pushed map:fly_to no longer animate for a visitor who asks for reduced motion, unless given essential: true (#61).
  • A map without debug no longer turns off the logging that window.__MAPLIBREX_DEBUG__ turned on (#21).
  • For a layer, source or terrain component mounted during a map style change, layer:added, source:added and terrain:enabled come once the new style is in place, and so does source:removed for a source component removed during one (#51).
  • With 3D terrain on, a style change diffs the new style in instead of rebuilding it: the map is flat while a style URL is fetched, and what a diff keeps (images added with map.addImage, a custom layer) is kept (#78).
  • An open <.popup> whose map is removed no longer pushes popup:closed, and opens again on the next map rendered under that id (#82).
  • A <.marker> whose popup_text and popup_html are empty at mount has no popup, where it had one that opened empty (#36).
  • A <.popup> the user closed no longer opens again on an unrelated re-render, and a popup removed from the page no longer pushes popup:closed (#37).
  • A <.popup> without a position stays closed when asked to open and pushes no popup:opened; the browser console warns instead (#65).
  • In the MapLibre popup, the children of a <.popup>'s slot are inside a <maplibrex-popup-body> element, so a child selector such as .maplibregl-popup-content > p no longer matches them; while the popup is open its slot is not in the component's element; the library defines the custom elements maplibrex-popup-body and maplibrex-popup-placeholder; and in browsers without Node.moveBefore an <iframe> or a playing video in a popup restarts when the popup re-renders (#66).
  • The JS commands of geojson_layer and popup (GeoJSONLayer.set_data/2, Popup.open/2 and the others) act in the browser and no longer push an event to the LiveView (#22).
  • Several controls in one map corner are stacked in the order of the template, the first nearest the corner, where they were stacked in the order they were added; while a control, control_group or control_button is not on a map, its content stays hidden in the component's element (#3).
  • An <.attribution_control> takes the place of the map's own attribution control instead of adding a second one (#58).
  • show_user_heading={false} on <.geolocate_control> no longer hides the location dot (show_user_location={false} does), and geolocate:user_location_updated carries the user's position, for every position while the control tracks the user, instead of the map's centre on every move (#40).
  • A <.geolocate_control> without fit_bounds_options stops at zoom 15 when it fits the map to the user's position, and a position request that gets no answer within 6 seconds ends with geolocate:location_error (code 3), where it waited with no limit (#76).
  • With a <.terrain> and a <.terrain_control> on one map, the terrain control decides while it is there; terrain_control:toggled for a click comes once the terrain is really on or off (#19).
  • maplibrex.css lays the buttons of a horizontal <.control_group> out in a row and gives active buttons (any with maplibregl-ctrl-active) a tinted background; the buttons at the ends of every map control on the page, MapLibre's own included, get the control's rounded corners, and their focus ring follows the control's 8px radius (#39).
  • A <.control_button> given active has aria-pressed; the attribute's default is now nil instead of false, which configures the button as false did.
  • <.raster_tile_source tms={true}> requests its tiles in TMS order (scheme: "tms"); with a server that is in fact XYZ the tiles are now drawn flipped, so drop tms there (#24).
  • <.deckgl_layer before_id=...> draws its layer under that MapLibre layer, where it drew it on top (#10).
  • min_zoom and max_zoom on <.custom_layer> now hide the layer outside its zoom range, a before_id that is not on the map puts the layer on top with a warning, and the uniforms of update_uniforms_<id> are merged over the current ones instead of replacing them (#34).
  • After a style change a <.custom_layer> goes back to its place in the layer order, above the new basemap, and a layer component added before it goes back under it (#27).
  • A <.custom_layer> drawn with a preset draws the uniforms it is not given with the preset's defaults instead of 0 (#80).
  • maplibrex.css no longer defines keyframes named spin (they are now maplibrex-loading-spin): an application that animated something with spin and relied on maplibrex.css for it has to define it (#72).

Fixed

Map

  • A <.map> without center, zoom or style ignored the configured defaults, default_center, default_zoom and default_style (#25). Without center the map did not appear at all: MapLibre 5 and 6 throw in the map constructor when given a null centre. Without zoom it opened at zoom 0, and without style it had no style. Now such a map opens at the configured centre and zoom, [0, 0] and 10 unless configured, with the configured style; nil counts as not given. A map with bounds still opens on its bounds. After mount, a center or zoom that is not given, or becomes nil, leaves the map where it is, as before. A style that becomes nil now switches to the configured default style, where the map was given no style before. With default_center: nil and default_zoom: nil in the configuration, such a map opens at the camera of its style instead.
  • A mounted <.map> ignored changes to bounds, max_bounds, min_zoom, max_zoom, min_pitch, max_pitch, interactive and attribution_control: it kept the values it was created with (#26). Each one now applies when it changes, so a LiveView that changes one of these assigns sees the map follow it. New zoom and pitch limits and max bounds apply at once, and a map outside a new zoom or pitch range moves into it (and pushes map:moved). A limit no longer given goes back to what a map created without it has, zoom 0 to 22 and pitch 0 to 60 (#59): the minimum zoom is 0, as at mount, not the -2 that MapLibre's setMinZoom(null) sets, at which a globe shrinks to about 30 px and a mercator map stops zooming out at about -0.5 while its zoom-out button does nothing (min_zoom={-2} gives -2). Max bounds no longer given are lifted. New bounds fit the map to them at once, with no animation and no padding, as when the map opens; bounds no longer given leave the map where it is. interactive turns all of MapLibre's interaction handlers off and on, also on a map created with interactive={false}, and attribution_control removes and adds the attribution control. The <.map> docs now say what a change to each attribute does after mount; class is still read only when the map mounts.
  • On a globe (projection="globe", or a style that declares one), a new center changed the zoom (#74): MapLibre's globe changes the zoom with the latitude of a centre given alone, to keep the planet's apparent size, so a map moved from Madrid to Nairobi at zoom 11 landed at 11.393 and reported that in map:moved. This comes from MapLibre GL JS 5 and 6, and the same call made directly shows it. Now a new center keeps the zoom the map has, as on a flat map (a new zoom in the same update still applies). On a mercator map nothing changes. Visible change: an app with a globe that changes only the center now keeps the zoom instead of seeing it drift with the latitude. The pushed map:fly_to and map:jump_to events still reach MapLibre as they are: one without a zoom gets the globe's zoom. A new zoom limit (#26 above) also moves a globe into its range at once, with one map:moved, although MapLibre's globe constrains its zoom with transforms that get the new limit only afterwards; during a flight or a gesture MapLibre keeps the move to the new range.
  • The camera commands animated for every visitor, also for one whose system asks for reduced motion (#61): fly_to/4, fit_bounds/3 and the server-pushed map:fly_to passed essential: true to MapLibre, which then plays the animation whatever prefers-reduced-motion says. Now they leave the choice to MapLibre, as the opening flight (fly) does: for a visitor who asks for reduced motion the map goes to its new camera at once, with no animation, and for everyone else it flies as before. An application marks a command essential with fly_to(map_id, center, zoom, essential: true), fit_bounds(map_id, bounds, essential: true), or essential: true in the payload of map:fly_to and map:fit_bounds. Visible change: visitors with reduced motion on no longer see these animations unless the command is marked essential. The events are the same: the jump still ends with one map:moved.
  • debug={true} on a <.map>, documented in the README, did nothing (#21): the component had no debug attribute, so the value was rendered as a plain HTML attribute and never reached the hook. And every map that mounted turned debug output off, also when window.__MAPLIBREX_DEBUG__ had turned it on, so that flag only worked until the first map appeared. Now debug is an attribute (default false): the library logs its lifecycle messages while any map on the page has it, or while the window flag is set, and a map without it leaves them alone. It follows the attribute after mount. A map without debug renders the same data-config as before.
  • A <.map> removed less than 150 ms after it last moved still pushed that move's map:moved once it was gone (#67): the event waits 150 ms for the map to settle, and removing the map did not cancel it. The server got an event for a map that no longer existed, and a LiveView that keeps the position in its assigns and had just replaced the map (same id) rendered the old map's position to the new one. Now a removed map pushes nothing more. The other map events are pushed as they happen and were not affected.
  • A camera value the LiveView rendered back with float noise, such as the centre -3.703800000000001 MapLibre reports for a flight to -3.7038, counted as a new value from the server unless the map itself had just reported it (#67). A map with fly that replaced one with the same id right after it landed, in a LiveView that keeps the position in its assigns, got the old map's centre rendered to it, abandoned its flight and jumped. Now a center, zoom, bearing or pitch that differs from the one before only by float noise, or by the rounding of map:moved, is the same value, and the flight goes on. Longitudes are compared around the world, so a centre the map reported past 180 degrees and the server wraps back is still the map's own. The centre's tolerance is now half a millionth of a degree (about 5.5 cm) instead of a millionth: a centre the server rounds to 6 decimals is still the map's own, and one the LiveView moves by a millionth of a degree (about 11 cm) is applied, where it could be taken for the map's own before.
  • A <.map> element that LiveView replaced with a new one under the same id in one patch left no map registered under that id (#82). LiveView mounts the new element before it destroys the old one, and the old map's hook then unregistered the id, taking the new map with it: every component mounted afterwards waited for its map forever, and the controls of the components that outlived the old map never came onto the new one. Now the map hook unregisters its map only while it is still the one registered under its id, and before it removes the map, and the controls move to the map registered in its place. In JavaScript, MapManager.unregister(mapId, map) takes the map as an optional second argument, for that check, and MapManager.isRegistered(mapId, map) is new.
  • Layers, sources and terrain were not added to a <.map> rendered again under the same id while their components stayed on the page (#82): a map behind :if turned off and on, or an element LiveView replaced, came back with its style only. They waited for their map once, at mount, and stayed with the map that was removed. Now every layer and source component (geojson_layer and custom_layer included), terrain and the terrain of a terrain_control follow the map registered under their map_id: they are put on the new map as they are rendered then, with their click and hover events and the source events, which no longer come from the removed map. layer:added, source:added, layer:source_loaded and terrain:enabled are not pushed again for the new map, as for a style change that puts them back, and the removed map pushes no layer:removed, source:removed or terrain:disabled.
  • Markers and popups did not come back on a <.map> rendered again under the same id either (#82): like layers, they waited for their map once. Now a <.marker> is added to the new map where it was (where the user dropped it, unless lng_lat has changed since), with its popup open if it was, and a <.popup> that was open when its map went opens on the new map, with its slot content. Behaviour change: an open <.popup> whose map is removed no longer pushes popup:closed (MapLibre closed it with the map, and a LiveView that kept open in its assigns then kept it closed on the new map): it keeps its open state, and opens again on the next map under its id.

Style changes and terrain

  • One update that changed the map's style and a layer, source or terrain component too (a theme switch that also restyles a hillshade layer, say) made MapLibre throw TypeError: Cannot read properties of undefined (reading 'shaderPreludeCode') from its render loop while terrain was on (#51). The component's change reached the outgoing style, before or after the map's setStyle depending on where the component is rendered, and MapLibre then drew a frame while it rebuilt the style. Now, while a style change is in progress (a new style, set_style/2 or the map:set_style event), the layer, source, terrain and GeoJSON layer components leave the map alone: a change they get meanwhile waits, only the last one counts, and it is applied once the new style is in place, on top of the component put back on it. A component mounted or removed meanwhile is added or removed then (a removed terrain is turned off at once). The end state is the one the two changes reach one after the other. This holds whichever order LiveView updates the hooks in. A style change that fails, or that another one replaces, holds the components no longer than that, and none holds them for more than 5 seconds. Event names and payloads are unchanged; for a component mounted during a style change, layer:added, source:added and terrain:enabled now come once the new style is in place, and so does source:removed for a source component removed during one. Changes rendered in the same reply as a push_event("map:set_style", ...) still reach the map before the style change, as LiveView patches the page before it dispatches events: change the style assign instead to have them wait.
  • A <.terrain> removed while the map was loading a style it rebuilds from scratch (right after any basemap switch with terrain on, before the fix of #78 below; now after a style change made by application code, say) logged [MaplibreX] Could not disable terrain: Error: Style is not done loading. and never pushed terrain:disabled (#60): it turned the terrain off with map.setTerrain(null), which MapLibre refuses until the new style has loaded. The map ended up right, as the new style's load takes the terrain off itself. Now the removal leaves the terrain to that load, without a warning, and pushes terrain:disabled once, as any other removal does. A <.terrain_control> removed or switched off at that moment is quiet too.
  • With 3D terrain on (a <.terrain>, or a <.terrain_control> switched on), every style change (a new style, set_style/2 or map:set_style) logged MapLibre's warning Unable to perform style diff: TypeError: Cannot read properties of undefined (reading '_checkLoaded'). Rebuilding the style from scratch. and rebuilt the whole style instead of diffing it (#78). With continuous repaint on (an animated <.custom_layer>, or map.repaint set by the application), or with changes in quick succession, MapLibre also threw TypeError: Cannot read properties of undefined (reading 'shaderPreludeCode') from its render loop, as it drew frames while the rebuilt style loaded. The cause is in MapLibre GL JS 5 and 6: its style diff runs the terrain operation as map.setTerrain.apply(style, ...), which always throws, so any diff that sees a terrain fails. Now the terrain component takes its terrain off right before the change, MapLibre diffs the new style in as it does without terrain, and the terrain is set again once the new style and its DEM source are in place (terrain:enabled is not pushed again). Continuous repaint is paused while a change is in progress and given back once it is done, failed or timed out. Changes in quick succession end on the style last asked for, and the terrain (set once), continuous repaint and the components wait for that style, also when MapLibre applies the response to an earlier style URL after it: once it has aborted one style request, MapLibre GL JS 5 and 6 lose track of the next one, which a later setStyle then no longer aborts, so its style arrived whenever it came and could replace the last one, with or without terrain. Such a late style is no longer taken in. A styledata the outgoing style fires while a style URL is fetched no longer ends the change early either. A terrain removed during the change stays off and pushes terrain:disabled once. Visible changes: with terrain on, the map is flat while a style URL is fetched, and its terrain comes back once the new style is in, where the map used to stay in 3D during the fetch and then go blank while MapLibre rebuilt the style; and since the style is now diffed, what a diff keeps is kept with terrain on too (images added with map.addImage; a custom layer, which goes back to its place without being added again). A terrain set by application code (map.setTerrain) or declared by the style itself is left to MapLibre, which still warns and rebuilds the style for it.

Markers and popups

  • A <.marker> popup (popup_text or popup_html) opened on top of its own marker, hiding it, so a second click landed on the popup and could not close it (#35). The hook created the popup with an offset key whose value was undefined, which keeps MapLibre from giving a marker's popup the offset that puts it above the pin. The popup now opens above the marker, as a plain MapLibre marker's does.
  • A <.marker> popup was fixed to what the marker had at mount (#36): popup_text or popup_html given after mount gave no popup, and removing them left the old popup and its text. The popup now follows them: one given after mount adds the popup, a new value replaces its content (an open popup stays open, and text and HTML can be swapped), and nil or "" for both removes it, closing it if it is open. An empty popup_text gives way to popup_html; at mount, an empty value now gives no popup, where it gave one that opened empty. The docs described a popup slot that the component does not have; they now describe popup_text and popup_html instead, and point to <.popup> for popup content written in HEEx.
  • A <.marker> rendered before its map, or whose map is rendered later, never appeared: the hook logged that the map was not found. It now waits for the map and adds the marker, with its current attributes, as soon as the map is on the page.
  • A <.popup> with its default anchor, "auto", made MapLibre throw TypeError: Cannot read properties of undefined (reading 'x') at mount (#37): MapLibre has no "auto" anchor, and lets the popup pick one only when none is given. The popup appeared, but the hook's setup was cut short, so it no longer followed its assigns. "auto" and nil now give MapLibre no anchor. Every attribute now follows its assigns after mount: a new lng_lat moves the popup, new slot content replaces its content, and max_width and offset change in place; anchor, close_button, close_on_click, close_on_move and class_name, which MapLibre reads only when a popup is created or opened, replace the popup with a new one, with the same content and position, open if the old one was, and no popup:closed or popup:opened for the swap. The open state is applied when open or lng_lat changes: a popup the user closed no longer opens again on an unrelated re-render (it did with an explicit anchor), and a new lng_lat with open still true opens it there. The popup waits for its map, as the marker does, and a popup removed from the page no longer pushes popup:closed. The docs no longer show Popup.set_content/2, which does not exist: the content follows the slot.
  • A <.popup> without a position could be opened without showing anything (#65): Popup.toggle/1, popup:open without lng_lat, or open={true} with no lng_lat made MapLibre mark it open with nothing on the map, and pushed popup:opened; the next toggle then "closed" a popup nobody saw, so a toggle button seemed to do nothing on its first click. Now a popup that has no position stays closed when asked to open, pushes nothing, and the browser console warns, naming the popup. Its position is the last lng_lat, or the last one Popup.open/2 or Popup.set_location/2 (or their server commands) gave it: open turned true, or a toggle, after set_location opens it there, and a lng_lat given later with open={true} opens it, as before. A lng_lat the LiveView no longer gives takes the position away, so a later toggle no longer reopens the popup where it was. A marker's popup takes its position from the marker and is unchanged.
  • A <.popup>'s slot existed twice in the page (#66): the hook copied the HTML of the component's hidden element into the MapLibre popup, so every id in it was there twice, a <label for> or a JS command aimed at an id found the hidden copy, and a phx-hook element in it was mounted twice, once on each copy, the visible one never updated. The popup now shows the slot's own elements: they move into the MapLibre popup while it is open and back into the component's element when it closes, and LiveView patches them where they are. Ids are unique, and phx-click, forms (phx-change, phx-submit), phx-hook elements and JS commands in a popup work, through re-renders, the popup closing and reopening, a basemap switch and a rejoin; an input being typed in keeps its focus when the popup re-renders. A popup removed from the page takes its content along (hooks in it are destroyed); when the map goes first, the content goes back into the popup's element, still patched, its hooks alive. Visible changes: in the MapLibre popup the slot's children are inside a <maplibrex-popup-body> element and the component's [data-popup-content] element, both display: contents, so the layout is the same but a child selector such as .maplibregl-popup-content > p no longer matches them; [data-popup-content] is rendered with style="display: contents;"; while the popup is open its slot is not in the component's element, where a <maplibrex-popup-placeholder> takes its place; the library defines those two custom elements. In browsers without Node.moveBefore, an <iframe> or a playing video in a popup restarts when the popup re-renders. In a LiveComponent, as before, bindings in a popup need phx-target={@myself} unless the map is in the same component, since the popup shows its content inside the map's element. Phoenix.LiveViewTest still finds the content where the component renders it.
  • The JS commands of geojson_layer and popup did nothing in the browser (#22): GeoJSONLayer.set_paint_property/3, set_layout_property/3, set_filter/2, set_data/2, show/1 and hide/1, and Popup.open/2, close/1, toggle/1 and set_location/2 returned JS.push, which sends the event to the LiveView, where no handler is defined (an unhandled event crashes the LiveView). They now act in the browser, like the map's fly_to/4: each one dispatches a DOM event to the component's element (maplibrex:layer_set_paint_property, maplibrex:popup_open and so on), with the payload of the server command of the same name as its detail, and the component's hook applies it, with the same effect as that server command. No event reaches the LiveView. The server commands (layer:set_paint_property, popup:open, ... sent with push_event/3) work as before. Names and arities are unchanged. A LiveView that wrote a handle_event/3 clause to echo these events back with push_event/3 no longer receives them; the clause can go.

Controls

  • The control components kept the options they were mounted with (#3): navigation_control, scale_control, fullscreen_control, geolocate_control, attribution_control, terrain_control, control, control_group and control_button read their attributes once, and zoom_range kept using the min and max it was mounted with on every zoom after an update. They now share one lifecycle and follow their assigns: a new position moves the control to its new corner, the same control with whatever state it has (a geolocate control keeps tracking, a terrain control keeps its terrain); an option MapLibre reads only when it creates a control replaces the control with a new one, in the same place (show_compass, show_zoom and visualize_pitch; container_id; compact and custom_attribution; track_user_location, show_accuracy_circle and show_user_location, below); and the others apply to the same control (unit and max_width of scale_control, fit_bounds_options, the terrain control's terrain_source_id and exaggeration, the class of control and control_group, which now reaches the control's container, and orientation). A geolocate control that was following the user when a change replaces it goes on following, with no event for the swap; one that stops tracking because track_user_location became false pushes geolocate:tracking_stopped. A render that changes nothing changes nothing, and a map style change leaves every control alone. Each component's docs say what a change to each attribute does; id and map_id are read at mount. Visible changes: a control rendered before its map, or on a map rendered later, now appears once the map is there, where it logged that the map was not found; a control whose map is removed and rendered again with the same id comes back on the new map; several controls in one corner are now stacked in the order they come in the template, the first nearest the corner, also when one of them is rendered later, replaced or moved there (they were stacked in the order they were added, MapLibre's, so a control rendered later went farthest from the corner; controls the map or the application add stay where MapLibre puts them); a map removed before its controls no longer logs Cannot read properties of undefined (reading 'off') for each of them; while a control, control_group or control_button is not on a map, its content stays hidden in the component's element, also after its map is removed; and a control_button without a tooltip no longer gets an empty title after an update. The control_group examples now give the nested control_button components their required id and map_id.
  • An <.attribution_control> added a second attribution control to its map (#58): <.map> shows one of its own unless attribution_control is false, and nothing said to turn it off. Now a map shows one attribution control: the component's takes the place of the map's own for as long as it is on the page, whether it is rendered before or after the map, and the map's own comes back when the component goes (if the map's attribution_control is still true; turning it on while a component is there adds nothing). Of two <.attribution_control> on one map, the one mounted first is shown and the other once it goes, with a console warning. A template that passed attribution_control={false} to get a single control, as the workaround was, keeps working.
  • <.geolocate_control> hid the user's location dot with show_user_heading={false} and reported the map's centre as the user's location (#40). The hook passed show_user_heading to MapLibre as showUserLocation, which is the dot, and pushed geolocate:user_location_updated with map.getCenter() on every moveend while the camera followed the user (so also for a zoom by hand), from a listener it never removed. Now show_user_heading is not passed to MapLibre, which draws no heading in versions 5 and 6, so it has no effect; the new show_user_location attribute (default true) is MapLibre's option for the dot, and follows its assign like the others. geolocate:user_location_updated now comes from the control's own geolocate event: it is pushed for every position while the control tracks the user (track_user_location), also while the user has moved the map away and the camera no longer follows, with the position the browser gave, in the same coords as geolocate:location_found. Visible changes: show_user_heading={false} no longer hides the dot (pass show_user_location={false} for that); geolocate:user_location_updated carries the user's position instead of the map's centre, and its coords now also has accuracy, altitude, altitudeAccuracy, heading, speed and timestamp, documented with the events; it is no longer pushed when the map moves, and it is now pushed for the positions that come while the camera does not follow. The coords fields are now documented.
  • <.geolocate_control> replaced two of MapLibre's defaults with its own (#76). Without fit_bounds_options it sent %{}, which MapLibre takes as given: the map could zoom in past MapLibre's maxZoom: 15 when it went to the user's position. And it created every control with positionOptions: {enableHighAccuracy: true} and nothing else, which replaces MapLibre's position options as a whole: no timeout, so a position request could wait for ever, and maximumAge 0, the browser's default. Now an option the template does not give, or gives as %{}, is not sent, and MapLibre's own apply: maxZoom: 15 for the fit, and timeout: 6000 and maximumAge: 0 for the position, which is still asked for with enableHighAccuracy: true, as before. A new position_options attribute sets the position options; each key given replaces its default and the others keep theirs, so position_options={%{enableHighAccuracy: false}} asks for a position of normal accuracy and keeps the timeout. fit_bounds_options given still replace MapLibre's, as before. Both follow the attribute after mount, on the same control; one no longer given goes back to its default. Visible changes: a control without fit_bounds_options stops at zoom 15 when it fits the map to the user's position; and a position request that gets no answer within 6 seconds, where it used to wait with no limit, now ends with geolocate:location_error (code 3, timeout). Give position_options={%{timeout: ...}} for a longer wait.
  • A <.geolocate_control show_accuracy_circle={false}> that had located the user left an element on the map each time it was removed or replaced. MapLibre GL JS 5 and 6 create the accuracy circle with the location dot and place it with every position, whatever showAccuracyCircle, but take it away only when that option is true; the circle stayed, 1px wide, following every move of the map. The hook now takes it off the map with the control.
  • On maplibre-gl 6, <.geolocate_control> threw on every position and reported errors without their code and message (#91): geolocate:location_found and geolocate:user_location_updated never reached the LiveView, and geolocate:location_error came with code and message undefined. maplibre-gl 6 copies a position or an error onto the control's event with Object.entries, which takes only an object's own properties, and a browser keeps coords, timestamp, code and message on the prototype; maplibre-gl 5 copied them with for...in, which finds them. The hook now takes the position or the error from the event when it has them, as on 5, and otherwise from what the browser handed the control's _onSuccess and _onError callbacks, which fire the event; it asks the browser for nothing more. The three events carry the same payloads on 5 and 6. On a MapLibre whose control has neither callback and whose events carry nothing, the event is not pushed and the console gets one warning.
  • <.terrain_control enabled={true}> failed at mount and left terrain on when removed (#19). It set the terrain while the control was added, usually before the style had loaded and the DEM source was there, so MapLibre threw, the control pushed terrain_control:error and showed the terrain on while the map had none, and nothing retried; and removing the control left the terrain it had turned on, with no button left to turn it off. The control now keeps its terrain with the machinery of <.terrain>: switched on, at mount, by a click or by a new enabled, the terrain goes on as soon as the style and the source can take it, in any template order, follows terrain_source_id and exaggeration, and comes back after a basemap switch; switched off, or with the control removed, the terrain it turned on goes off. terrain_control:toggled is now pushed for a click once the terrain is really on or off, and not for a click MapLibre refuses, which pushes terrain_control:error and leaves the button off; a change of enabled from the LiveView pushes none, as before. The button now has aria-pressed. With a <.terrain> on the same map, the terrain control decides while it is there: <.terrain> stands by (its terrain goes off, also while the control is off) and its terrain comes back when the last terrain control leaves the map, with no new terrain:enabled or terrain:disabled. Visible changes: terrain_control:toggled for a click on a map whose DEM source is not there yet now comes once the source is, and the second toggled of a click whose change failed is gone; a page with both components now shows the terrain the control asks for (no terrain while it is off), where the two used to overwrite each other.
  • <.control_button> components placed in a <.control_group>, as its docs show, became controls of their own, in their own corner, and the group stayed empty (#38). A button in a <.control_group> or a <.control> is now shown inside it, in the order of the template, and moves with it; it follows its label, icon, tooltip, active and class and its phx-click (and the other forwarded bindings) through re-renders, as a button on its own does; a click pushes its event once. Its position does not count there. Markup changes: the content element of <.control> and <.control_group> has a data-maplibrex-control-content attribute, and the element of <.control_button> has the class maplibrex-control-button, which maplibrex.css uses to draw MapLibre's separator between two nested buttons; a nested button's element is shown with display: contents.
  • <.control_group orientation="horizontal"> looked the same as a vertical group, and an active <.control_button> the same as any other (#39): the hook added control-group-horizontal and maplibregl-ctrl-active, and no stylesheet had a rule for either. maplibrex.css now lays a horizontal group's buttons out in a row, separated on the left, and gives an active button (any button in a map control with maplibregl-ctrl-active) a tinted background, kept while it is hovered or pressed (MapLibre's own hover and press rules are more specific than a plain active rule), which --maplibrex-control-active-background restyles, and --maplibrex-control-active-hover-background its hover shade (by default the active background when that is set, else a shade darker than the default tint). The buttons at the ends of a control, and a control's only button, now have the control's rounded corners on their side (the left and right ends of a horizontal group), focused or not, so that their background and focus ring stay inside those corners; --maplibrex-control-radius (default 8px) rounds the control and them. The group's content element has the classes maplibrex-control-group and maplibrex-control-group-horizontal (or -vertical) for this, next to control-group-horizontal, which stays. Visible changes: horizontal groups and active buttons, including buttons an application marks with maplibregl-ctrl-active itself, now look different; and the buttons at the ends of every control on the page, MapLibre's own included, have rounded corners, so a hovered one no longer shows square corners outside the control's, and its focus ring follows the control's 8px where MapLibre's rule gave it 4px.
  • An active <.control_button> looked active but did not say so to assistive technology. A button given active (true or false) is now a toggle button: its <button> has aria-pressed="true" or aria-pressed="false", as the terrain control's has. A button without active is not a toggle and has no aria-pressed; for this the attribute's default is now nil instead of false, which looks and configures the hook as false did.
  • <.zoom_range> declared min and max as integers (#77), so a fractional zoom level such as min={10.5}, which the hook has always handled, raised a compile-time warning in a template that imports the component's module. Both now take any number. The README still said that markers and popups have to come after their map; since this release they wait for it, and the README says so.

Layers and sources

  • <.raster_tile_source tms={true}> requested its tiles in XYZ order all the same (#24): MapLibre has no tms source property, it reads the TMS row order from scheme: "tms", and the component passed tms through. Now tms={true} sends scheme: "tms", so the tiles of a TMS server are no longer drawn upside down; a scheme given too wins over it. The component no longer sends a tms key. An app that gave tms={true} to a server that is in fact XYZ now sees its tiles flipped: drop tms there.
  • <.deckgl_layer> accepted before_id and drew the layer on top of the map all the same (#10): the value reached the hook's config but not the deck.gl layer. Now the layer gets it as its beforeId, and deck.gl draws it under that MapLibre layer (the overlay is interleaved, the mode that honours it); a beforeId given in props still works, and before_id wins over it. A deck.gl layer without before_id is drawn on top, as before. An app that gave before_id now sees its layer under that one.
  • A mounted <.custom_layer> ignored every change to its attributes (#34): the component stored its data-config with Map.put/3, which LiveView's change tracking does not see, so the attribute was rendered once and never sent again; and the hook, given a new config, only read its uniforms. The component now uses assign/3, and the layer follows its attributes: a new uniforms is drawn from the next frame (adding or removing u_time starts or stops the animation), a new before_id moves the layer, a new min_zoom or max_zoom sets its zoom range in place (a bound no longer given adds the layer again), and a new preset, vertex_shader or fragment_shader replaces the layer in its place with one drawn with the new shaders. Shaders that cannot be used are logged and leave the layer as it is. The layer is now kept with the machinery of the layer components, which changes what an application can see: min_zoom and max_zoom were ignored, also at mount, and now hide the layer outside its zoom range; a <.custom_layer> rendered before its <.map>, or mounted while the map loaded tiles, was never added, and now is as soon as the map can take it; a before_id that is not on the map made MapLibre refuse the layer, and now puts it on top, with a warning, until that layer appears; removed during a style change, the layer goes once the new style is in place; and removed after its map (a live navigation), it leaves the map alone, where maplibre-gl 5 logged an error. A layer removed, replaced or added again deletes its WebGL program and buffer, and no map listener is left behind. The update_uniforms_<id> event, which the hook has always handled, is now documented: the uniforms it carries are merged over the current ones, where they replaced them, and kept until the uniforms attribute changes.
  • A <.custom_layer> ended up under the basemap after a style change (#27). A custom layer is not part of the style document, so MapLibre's style diff (a new style, set_style/2 or map:set_style) neither removed nor moved it, and added the new style's layers above it: the layer was drawn under the whole new basemap, and nothing moved it back. Now it goes back to its place once the new style is in place: on top, or under its before_id (on top, with a warning, while the new style lacks that layer, and under it again once a style has it), and among the layer components in the order they were first added in, so a layer component added before it goes back under it, where it went above it before. While a style URL is fetched the layer stays where it is. A style rebuilt from scratch (one that declares a terrain of its own, say) drops it, and it is added again, deleting the WebGL program and buffer of its earlier add. With terrain on, the style is diffed too since #78. Only the style changes MaplibreX makes are followed: after a map.setStyle called by application code, the layer stays where MapLibre leaves it.
  • Removing one animated <.custom_layer> (one with u_time) froze every other animated custom layer on the same map until the map moved (#81): each layer set MapLibre's map.repaint, one flag for the whole map, to true while it animated and to false when it went or stopped animating, also over a repaint the application had turned on itself. Now the layers share one owner of the flag: the map draws every frame while at least one animated layer is on it, and when the last one goes, or stops animating, repaint is what the application had set (its value before the first animated layer came, or one it set since).
  • A <.custom_layer preset="ocean_currents"> (or "wind_flow") without uniforms drew nothing (#80): the presets declare default uniforms, but nothing read them, so the layer was drawn with an opacity and a point size of 0. Now a layer drawn with a preset's shaders draws with the preset's defaults (u_color, u_opacity and u_point_size; the values are in the custom_layer docs), and each uniform given in uniforms or pushed with update_uniforms_<id> replaces its default, the others keeping theirs. Visible change: a preset layer that set only some of the three uniforms (an opacity, say) now draws the others with the preset's values instead of 0, so it shows where it used to be invisible.

Stylesheet

  • maplibrex.css defined global keyframes named spin (#72), the name Tailwind's animate-spin uses. Keyframes are global, so the stylesheet loaded last won: either every animate-spin element of the application turned about a point shifted by half its size (the library's keyframes include translate(-50%, -50%)), or the .maplibrex-map.loading spinner turned off its centre. The library's keyframes are now maplibrex-loading-spin: the .loading spinner still turns about its centre, and the application's animate-spin is its own again. An application that animated something with spin and relied on maplibrex.css to define it now has to define it. The stylesheet also drops .maplibrex-map > .maplibregl-map { width: 100%; height: 100% }, which matched nothing: MapLibre adds maplibregl-map to the map element itself, which .maplibrex-map already sizes, and a rule on that element with both classes would have beaten an application's own size class next to maplibrex-map. No page looks different for it. The stylesheet's comments are now all in English.

Documentation

  • The event docs of the source components, sky and marker now give each event with its payload keys (#28). vector_tile_source, raster_tile_source and raster_dem_source list source_data_type (MapLibre's sourceDataType, absent while data is loading), which was missing, say that data_type is always "source", which they gave as "source" or "metadata", and give the tile of source:data and source:error; raster_dem_source listed source:data and source:error without their keys. Their source:data examples read source_data_type. sky says its two events carry no keys, and marker that its four carry markerId and lngLat. (image_source and video_source list the events their hooks push since 0.2.1, and marker documents popup_text and popup_html since this release.)
  • Every HEEx example in the docs now compiles when pasted into a template (#29). The geojson_layer examples passed paint and layout maps without braces (paint=%{...}, now paint={%{...}}), a HEEx syntax error; the custom_layer shader example gave uniforms={%{...}}; and the fit_bounds/3 example put an Elixir assignment in its markup. A test now finds the examples in the README and in the docs of every module, compiles each one, and fails on a syntax error or a compiler warning, an undeclared attribute or a value of the wrong type among them.
  • The <.map> docs gave the range of max_pitch as 0-85; MapLibre GL JS 5 and 6 accept up to 180 (#59).

Known issues

  • <.sky> draws no sky, on any supported maplibre-gl version (#14). Its hook adds a layer of type "sky" with Mapbox GL sky paint properties, and MapLibre has no such layer type: its sky is a style property, set with map.setSky(), with other keys. MapLibre refuses the layer with a style validation error, which the map logs and pushes as map:error; the hook pushes sky:added all the same, and changes to the attributes and the removal of the component do nothing. The component's docs say so at the top. Its attributes follow Mapbox's sky, so the fix is expected to change them.
  • A component given no events list pushes every event it emits to the LiveView it is rendered in, and a LiveView with no handle_event/3 clause that matches one of them crashes on the first such event (#45): Phoenix raises FunctionClauseError (or UndefinedFunctionError without any handle_event/3), the LiveView process exits, and the browser reconnects to a newly mounted LiveView, without the old assigns. A plain <.map> does this with map:loaded once it has loaded. Give each component the events it should push, or keep a catch-all clause, def handle_event(_event, _params, socket), do: {:noreply, socket}, after the other handle_event/3 clauses. The README's installation step 6 and the MaplibreX docs now say this.

0.2.1 - 2026-11-26

Component attributes, hook names, event names and payload keys are unchanged, and a component given no events list pushes every event, as before. One change in behaviour is visible: a layer or source component no longer removes a layer or source that was already on the map when it mounted. See Changed.

Added

  • An optional events attribute on every component that pushes events to the LiveView (#45, in part): a list of event names, such as events={["map:moved", "map:clicked"]}. When it is given, the component pushes only those events, so a LiveView no longer needs a handle_event/3 clause for the others and they cost no round trip; an empty list pushes none. Without it, every event is pushed, as before. It applies to map, marker, popup, geolocate_control, fullscreen_control, terrain_control, terrain, sky, deckgl_layer, geojson_layer, the layer components and the source components. #45 stays open for 1.0, when components will push only the events asked for.
  • mix maplibrex.copy_worker, which copies maplibre-gl 6's worker files (maplibre-gl-worker.mjs, and maplibre-gl-shared.mjs when the installed release has it) from assets/node_modules/maplibre-gl/dist to priv/static/assets/js (#48); --from and --to change those. With maplibre-gl 5, or without maplibre-gl, it copies nothing, says why and succeeds, so it is safe in the assets.build and assets.deploy aliases of any application. It replaces the copy_maplibre_worker/1 function the README had applications paste into their mix.exs; an application that has it can keep it or switch to the task.

Changed

  • A layer or source component whose id is already on the map when it mounts, from the map style, your own code or another component, no longer removes that layer or source when the component is removed (#46). In 0.2.0 it did, so a component sharing an id with a basemap layer deleted that part of the basemap when it went away. The component still takes the layer or source over: it applies later changes to its attributes that MapLibre can make in place (paint, layout, filter, zoom range and before_id for layers; new tiles, URL, image or coordinates for sources) and logs one console warning saying that the id was already in use. It pushes no layer:added/layer:removed or source:added/source:removed for it, and a change that would mean removing it (a new source_id or source_layer, a zoom bound that is no longer set, a source change MapLibre cannot make in place) is not applied, with a console warning. This covers the source and layer of geojson_layer too.
  • What a component removes now follows what it added. Once a map style change drops a layer or source the component took over and the component adds it itself, it is the component's own: layer:added or source:added is pushed then, and the component removes it, and pushes layer:removed or source:removed, when it goes. The other way round, when a style change puts a layer or source with the same id in place of the component's own, the component leaves the style's on the map; it still pushes layer:removed or source:removed for its own. terrain likewise turns off only the terrain it set, not one with the same settings that a style change loaded.

Fixed

  • Events that could not be delivered surfaced as unhandled promise rejections (Uncaught (in promise) in the browser console), one per event pushed while the LiveView was disconnected, for example while the socket reconnected after a deploy (#23). Every hook now pushes through one helper that drops such events quietly: they are notifications, and nobody waits for them.
  • The docs of image_source and video_source listed events their hooks never push (source:loaded, video:loaded, video:error), and those of vector_tile_source, raster_tile_source, raster_dem_source and sky left out events they do push (#28, in part). Each component's docs now list the events it pushes, the names the events attribute takes.
  • A map whose LiveView keeps its position in the assigns, as the README shows (assign(socket, center: center, zoom: zoom) on map:moved), was moved again to the position it had just reported when the re-render arrived, and so pushed map:moved twice for one move by the user (#49). When the re-render arrived while the user was still moving the map, it pulled the map back to where the user had been. Now one move pushes one map:moved, and the map is never moved by its own position coming back: a centre, zoom, bearing or pitch it reported in map:moved or map:zoom_changed is not applied while the server's answer to that event is pending, and neither is a value where the map already is (within a millionth of a degree for the centre, 0.005 for zoom, bearing and pitch, the rounding of map:moved). A centre, zoom, bearing or pitch the LiveView changes to is applied as before, also one the map reported earlier, and the JS commands and push_event commands move the map as before; each still pushes one map:moved where the map ends.
  • The Hex package shipped the bundle's source map, priv/static/assets/js/maplibrex.js.map (about 300 KB, which nothing loads), only because mix assets.deploy had left it on the publisher's machine (#50). The package now lists the bundle, priv/static/assets/js/maplibrex.js, by name instead of all of priv/static, so what it contains no longer depends on the publisher's working tree. The bundle is built as before.
  • push_event(socket, "map:fly_to", ...), "map:jump_to" and "map:fit_bounds" passed bearing, pitch and maxZoom to MapLibre even when the payload did not have them. MapLibre reads a key that is present as set, so a command without them could rotate, tilt or zoom the map to an invalid value. Only the options that were sent are passed now.

Documentation

  • The README's installation steps 3 and 4 are shorter (#48). Step 3 shows only what to add to the esbuild profile Phoenix generates (the assets/node_modules entry in NODE_PATH, and --external:@deck.gl/* without deck.gl) instead of a whole profile to paste over it, which also changed the application's esbuild version and flags. Step 4 adds mix maplibrex.copy_worker to the asset aliases and keeps the setWorkerUrl line. Both were checked in an application freshly generated by mix phx.new (Phoenix 1.8.8), with maplibre-gl 5.24.1 and 6.19.0.
  • The README and the MaplibreX and map docs show the events attribute where they introduce events. The catch-all handle_event/3 clause stays the advice for LiveViews with components that are not given events.

0.2.0 - 2026-11-26

Layers, sources and terrain now stay on the map for as long as their components live. Component attributes, hook names, event names and payload keys are unchanged, but some behaviour you can notice has changed: some events arrive at a different moment or no longer at all, some console messages are gone, and content nested in <.map> is now rendered after the map element. See Changed.

Added

  • Source components apply changes after mount. New tiles or url on vector_tile_source, raster_tile_source and raster_dem_source, a new image url and new coordinates on image_source, and new coordinates on video_source are applied to the source in place. Any other change replaces the source: every layer using it, from a component, the basemap or your own code, is taken off and put back at its place in the layer order. If MapLibre refuses the new source, the previous one is put back, and source:error is pushed when MapLibre threw.
  • geojson_layer follows every attribute: min_zoom, max_zoom, before_id, type and the clustering attributes as well as data, paint, layout and filter. What the server commands layer:set_paint_property, layer:set_layout_property, layer:set_filter and layer:set_data set now survives map style changes and re-renders that leave that property alone; a re-render that changes the same property, or a later command, wins.
  • MapManager.whenReady(mapId, callback) in the JavaScript API calls back with the map as soon as it is registered (at once if it already is) and returns a function that cancels the wait.

Changed

  • Content nested in <.map> is rendered right after the map element, as its sibling, instead of inside it (#15). The map element itself is unchanged, and so is a map with nothing nested in it. Visible content in the slot (a legend, say) is no longer inside the map container: it is laid out after the map instead of over it, and it is not part of the map in fullscreen. To show your own content on the map, use control, control_button or control_group, or position it in a wrapper of your own; the MaplibreX.Components.Map docs show both.
  • layer:added, source:added and terrain:enabled are pushed once, when the layer, source or terrain is actually on the map for the first time. That can be well after the component mounts (once its map, its style or its source is there), and they are not pushed again when a style change or an update puts the item back. In 0.1.1 layer:added was also pushed when MapLibre had refused the layer.
  • source:removed is pushed only once the source is really gone (#18). A source component removed while layers still use the source now leaves the source on the map until the last of those layers is removed, then removes it and pushes source:removed. In 0.1.1 MapLibre refused the removal while source:removed was pushed anyway.
  • layer:removed and source:removed are also pushed when the component's map was removed before the component; 0.1.1 skipped them then.
  • A source or layer component whose id is already on the map (from the map style or from your own code) takes it over: it applies its own updates to it and removes it when the component is removed. Until the component adds the source or layer itself (after a map style change drops it, for example), it pushes no source:added/source:removed or layer:added/layer:removed for it. A layer taken over this way still reports clicks and hovers with layer:feature_*. In 0.1.1 a source component logged Source "<id>" already exists and left the source alone, and a layer component pushed layer:added although MapLibre had refused the duplicate layer.
  • Layer, source, geojson_layer and terrain components no longer log Map "<id>" not found when they mount before their map: they wait for it.
  • A layer whose source is not on the map yet logs one console warning (none when a source component with that id is about to add it) and is added once the source appears. A before_id naming a layer that is not on the map logs one warning; the layer is added on top and moves under that layer once it appears. In 0.1.1 both layers stayed off the map.
  • terrain no longer logs an error and pushes terrain:error when its raster_dem_source is not on the map yet: it logs one warning (none when a source component is about to add the source) and turns the terrain on once the source appears. terrain:error now means MapLibre failed to set the terrain. terrain:disabled is pushed only when the component turns its own terrain off; a terrain set since by something else is left on.
  • Fewer map:error events and [MaplibreX] Map error console messages: the components no longer make MapLibre refuse a layer whose id is already on the map, a before_id naming a missing layer, or the removal of a source that layers still use.

Fixed

  • Layer and source components ignored assign changes after mount (#3, for layers and sources). The nine layer components now apply new paint, layout, filter, min_zoom, max_zoom and before_id in place; a paint or layout property or a filter removed from the assigns goes back to its default, and a new source_id or source_layer, or a zoom bound that is no longer set, re-adds the layer. Sources: see Added. terrain now applies a new source_id or exaggeration at any time; it dropped them while tiles were loading. Controls still ignore assign changes (#3 stays open for them), and so does the map for bounds, max_bounds, the zoom and pitch limits, interactive and attribution_control (#26).
  • Changing the map style removed every source, layer and terrain added by components (#4). Layer, source, geojson_layer and terrain components now put their content back after any style change, as currently configured. After a basemap switch a component layer with no before_id is on top again, one with a before_id is under that layer, and component layers keep the order they were first added in.
  • A layer mounted before its source was never added (#5); a terrain mounted before its DEM source reported an error and stayed off. Both now wait for the source, however late it comes.
  • Layers, sources and terrain mounted after the map's first load while tiles were still loading could be skipped: they waited for a load event that had already fired (#12). They are now added as soon as the style accepts them.
  • Components nested in <.map> were never patched: they kept their first assigns, and nested components behind :if or :for never mounted or unmounted (#15). They now behave like components rendered next to the map.
  • A map given a style object (an Elixir map rather than a URL) as its style called setStyle again on every change to any other map assign, and MapLibre's style diff dropped every source and layer the components had added (#16). The style is now compared by value and applied only when it really changes.
  • Layer, source, geojson_layer and terrain components mounted before their map gave up for good (#17). They now attach once the map is registered, whatever the template order. Markers, popups and controls still need their map to be rendered first.
  • A source removed while a layer still used it stayed on the map but reported source:removed (#18); see Changed.
  • geojson_layer often never sent layer:source_loaded: its one-time sourcedata listener was taken by whichever source reported first, and it outlived the hook (#20). It is now pushed once, when the layer's own source has loaded, from a listener removed with the hook.
  • The README's installation steps did not work in an application generated by mix phx.new (#41, #42). They now add assets/node_modules to esbuild's NODE_PATH, mark deck.gl as external when it is not installed, serve maplibre-gl v6's worker files, and cover path: dependencies.

0.1.1 - 2026-11-25

Bugfix release. There are no breaking changes.

Fixed

  • control, control_button and control_group never became map controls, and zoom_range never reacted to the zoom: their hooks (ControlHook, ControlButtonHook, ControlGroupHook, ZoomRangeHook) were implemented but missing from MapHooks and the named exports (#2). control_button also now forwards its phx-click, phx-click-away, phx-keydown, phx-keyup, phx-focus and phx-blur bindings, with phx-value-*, phx-key, phx-target, phx-debounce, phx-throttle and phx-disable-with, to its button, which the map moves out of the component's wrapper element. phx-window-* bindings stay on the wrapper, where they already work.
  • Controls survive LiveView re-renders: a re-render of control, control_button or control_group put the control's content back into the component's hidden wrapper, leaving an empty box on the map. The content now stays on the map with its newly rendered state, and removing the component removes it from the map (#2).
  • geojson_layer left its click and hover listeners attached when destroyed, so remounting a layer with the same id pushed every feature event more than once (#6).
  • Layer feature events were inconsistent between components (#7). Every layer:* event now carries both "layer_id" (canonical, as the other layer components already sent) and "layerId" (kept so existing geojson_layer handlers keep matching). The README and the MaplibreX moduledoc listed layer:feature_click; the emitted event is layer:feature_clicked, and the docs now say so.
  • marker attached its drag listeners only when it was draggable at mount, so enabling draggable later produced no marker:drag_* events (#8). Updates to color, scale, anchor, offset, pitch_alignment and rotation_alignment are now applied (color, scale and anchor rebuild the marker, keeping position, popup and drag state), marker:dragging is throttled to one event per 50 ms, and marker:drag_end always carries the final position. A rebuild requested while the user drags the marker waits for the drag to end, so it never cuts the drag or its marker:drag_end short, and a lng_lat sent during a drag is not applied.
  • Server-pushed map events (map:fly_to, map:jump_to, map:fit_bounds, map:set_style, map:set_bearing, map:set_pitch, map:reset_north, map:zoom_in, map:zoom_out) were applied by every map on the page (#9).

Added

  • Server-pushed map events accept an optional id in the payload. A map ignores an event whose id is not its own; without an id every map reacts, as before.

Development

  • Hook tests: vitest with a maplibre-gl mock, run with npm test in assets/ and in CI.

0.1.0 - 2026-08-24

First public release.

Components

Core

  • map — MapLibre GL JS map with reactive center, zoom, bearing, pitch, style and bounds

Overlays

  • marker — markers with drag & drop and attached popups
  • popup — standalone popups with HTML content and programmatic control

Layers

  • geojson_layer — generic GeoJSON rendering with clustering and feature events
  • circle_layer, line_layer, fill_layer, symbol_layer, heatmap_layer, fill_extrusion_layer, background_layer, hillshade_layer, raster_layer

Sources

  • vector_tile_source, raster_tile_source, raster_dem_source, image_source, video_source

Controls

  • navigation_control, scale_control, fullscreen_control, geolocate_control, attribution_control, terrain_control
  • control, control_button, control_group, zoom_range — building blocks for custom controls

3D & terrain

  • terrain — 3D terrain with configurable exaggeration
  • sky — atmospheric sky layer for 3D views

Advanced integrations

  • deckgl_layer — deck.gl layers, lazy-loaded on first use
  • custom_layer — custom WebGL layers with user-supplied GLSL shaders

Fixed

  • Source components no longer send minzoom, maxzoom, tileSize, scheme or encoding unless set explicitly. They defaulted to MapLibre's own values and were serialised unconditionally, which overrode whatever the TileJSON declared — a terrarium DEM was decoded as Mapbox Terrain-RGB and rendered as spikes, and maxzoom: 22 requested tiles servers do not have.

  • map accepts min_pitch and max_pitch. MapLibre caps pitch at 60 and silently clamps anything above it, so a 3D terrain view asking for 70 was flattened with no indication why.

  • map's numeric attributes are no longer typed :integer. zoom={3.5}, bearing={-17.6} and fractional pitch are all valid MapLibre values.

  • The map container is rendered with phx-update="ignore". Without it, any LiveView re-render that touched the map element's dynamics patched the container away: MapLibre kept rendering into a detached node while the page showed an empty <div>. LiveView still merges data-* attributes onto ignored elements, so reactivity is unaffected.

  • FullscreenControl events are subscribed on the control rather than on the map. FullscreenControl is its own Evented and never fires through the map, so fullscreen:entered and fullscreen:exited had never reached LiveView.

Architecture

  • TypeScript hook layer with a singleton MapManager and a bidirectional EventDispatcher
  • Map commands (fly_to, jump_to, fit_bounds, set_style, zoom_in, zoom_out, reset_north) run client-side via Phoenix.LiveView.JS.dispatch/3, with no server round-trip
  • map:moved is debounced by 150 ms to cut socket traffic during continuous pan and zoom
  • deck.gl is dynamically imported the first time a deckgl_layer mounts. The layer factory and overlay manager resolve their constructors through the lazy loader rather than importing them, so the split actually holds — an earlier static import in deckgl-manager and deckgl-layer-factory had been pulling all of deck.gl into the main chunk
  • Debug logging is gated behind window.__MAPLIBREX_DEBUG__ or a map's debug attribute; warnings and errors always reach the console
  • 405 tests covering rendered component output, attribute validation and edge cases

Compatibility

  • Requires Elixir 1.15 or later. phoenix_live_view requires it, so the earlier ~> 1.14 requirement was never actually satisfiable.

  • Supports maplibre-gl >=5.0.0 <7.0.0. Verified in a browser against v5.24.0 and v6.6.0: all nine demo pages render, and reactivity, marker add/remove, client-side map commands and paint updates all behave the same on both.

  • <.deckgl_layer> requires maplibre-gl v5. @deck.gl/mapbox reads the internal map.transform that v6 removed, so a deck.gl layer under v6 raises a message naming the constraint instead of failing inside deck.gl with Cannot read properties of undefined (reading '_nearZ').

  • Sources use import * as maplibregl from 'maplibre-gl': v6 is ESM-only and dropped the default export. The namespace import works on both majors.

Packaging

  • Ships a prebuilt ESM bundle at priv/static/assets/js/maplibrex.js (~65 KB, 12 KB gzipped)
  • maplibre-gl and the @deck.gl/* packages are peer dependencies rather than bundled, so an application never loads two copies of MapLibre GL