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
- Give each component the
eventsyour LiveView handles (#45). Withouteventsa component pushes nothing, sohandle_event/3clauses 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-allhandle_event/3clause is no longer needed. - 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"]}. - With
<.deckgl_layer>, replace@deck.gl/mapboxwith@deck.gl/maplibreand 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. - Give
<.sky>MapLibre's sky properties (sky_colorforatmosphere_color, say), and handlesky:enabledandsky:disabledwhere you handledsky:addedandsky:removed(#14). The old attributes are ignored, without a warning throughimport MaplibreX.Components. - Draw a
<.custom_layer>that used apresetwith<.flow_layer>and a vector field instead (#87):preset, or a missing shader, raises. - Expect
deckgl:drag_endonly for a drag that started on one of the layer's objects, asdeckgl:drag_startis (#11). - Read the data of
<.geojson_layer>and<.deckgl_layer>fromdata-geojsonanddata-records, notdata-config, in tests or code that read the rendered markup (#47). - Expect an
ArgumentError, not aJason.DecodeError, for a<.geojson_layer>datastring that is not JSON, unless it starts with{(#102). - Call
requireMapwhere a missing map should be logged:MapManager.getanduseMapno longer warn (#109).
Breaking
A component pushes to the LiveView only the events its
eventsattribute names, and none without it (#45). In 0.3.0 a component given noeventspushed every event it emitted, and a LiveView with nohandle_event/3clause for one of them crashed on it: a plain<.map>did onmap:loaded. Now a LiveView needs a clause only for the events it asks for, and the others cost no round trip.eventstakes a list of the component's event names, as in 0.2.1 and 0.3.0, or:allfor every event the component emits. Its default is[], andnilmeans[]too. A name the component does not push, or a value that is neither a list nor:all, raises anArgumentErrorwhen 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:attrcannot 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-allhandle_event/3clause. A catch-all clause is no longer needed otherwise, and dropping it lets a misspelthandle_event/3clause show. Markup written by hand for a hook, without the component, pushes nothing unless itsdata-confighas aneventskey:"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_mouseenterandlayer:feature_mouseleave(#45). This applies togeojson_layerand to the layer components that push feature events:circle_layer,line_layer,fill_layer,symbol_layerandfill_extrusion_layer. In 0.3.0 they showed it whatever theirevents. 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 withMapLibreOverlayfrom@deck.gl/maplibre, and works on maplibre-gl 6 (#11). In 0.3.0 it usedMapboxOverlayfrom@deck.gl/mapbox, which reads the internalmap.transformthat 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/maplibrefor maplibre-gl 5 and 6, so the optional@deck.gl/*peer dependencies now start at 9.4 (^9.4.0), and@deck.gl/maplibrereplaces@deck.gl/mapboxamong them. The overlay is interleaved as before, the attributes are unchanged, and so are the events and their payloads but fordeckgl:drag_end(below). Without@deck.gl/maplibre(with only@deck.gl/mapboxinstalled, say), or with an@deck.gl/coreolder than 9.4, the layer logs an error that names the packages to install, and pushes it asdeckgl: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 givenbefore_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/mapboxwith@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.0Before 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.0for 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 withmap.setSky(). The attributes are the properties of MapLibre's sky specification, in snake_case:sky_color,horizon_colorandfog_colortake a color string,fog_ground_blend,horizon_fog_blend,sky_horizon_blendandatmosphere_blenda 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, ornil, has MapLibre's default; any other value raises anArgumentError. The Mapbox attributestype,atmosphere_sun,atmosphere_sun_intensity,atmosphere_color,atmosphere_halo_color,gradient_center,gradient_radiusandgradientare 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; throughimport MaplibreX.Components, which delegates to the component, the compiler does not warn about it either (it does withimport MaplibreX.Components.Sky). The events are named as the terrain component's:sky:enabled, once, the first time the component sets its sky, andsky:disabled, when it is removed and takes its sky off, both with no payload keys;sky:addedandsky:removedare gone, and aneventslist that names them raises. Liketerrain, 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 amax_pitchtoo.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/3clauses forsky:addedandsky:removedbecome clauses forsky:enabledandsky:disabled, and theeventslist names those.<.custom_layer>has no presets (#87). Itsocean_currentsandwind_flowpresets 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 nopresetattribute, and needs bothvertex_shaderandfragment_shader: apreset, or a missing shader, raises anArgumentErrorwhen 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
uniformsinstead: the presets' wereu_color: [0.2, 0.6, 0.9],u_opacity: 0.8,u_point_size: 3.0(ocean_currents) andu_color: [0.9, 0.9, 0.9],u_opacity: 0.6,u_point_size: 2.0(wind_flow).deckgl:drag_endis pushed for a drag that started on an object of the layer, asdeckgl:drag_startanddeckgl:dragare, 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 alayerIdwhen 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_endclause that stood for the end of any drag on the map, a pan say, handles the map'smap:movedinstead; a clause for a drag of the layer's objects gets itslayerIdevery time.<.geojson_layer>renders its data in an attribute of its own,data-geojson, and<.deckgl_layer>indata-records, no longer indata-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 indata-configas 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 itssource.datafor<.geojson_layer>or itsdatafor<.deckgl_layer>(a test that decodes it, say), readsdata-geojsonordata-recordsinstead, which hold the data alone, as JSON.A
<.geojson_layer>datastring that is neither JSON nor a URL raises anArgumentErrornaming the formsdatatakes (#102); in 0.3.0 it raised aJason.DecodeError. JSON text that starts with{and does not decode still raises aJason.DecodeError, and a string that starts withhttp://,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.DecodeErrorfor such a string expects anArgumentErrorinstead.MapManager.get(mapId), anduseMap(mapId), which is the same, returnundefinedfor 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) !== undefinedis now the quiet way to ask.requireMap(mapId)is unchanged: with no map it warns, then throws anError, both naming the id. No component looked its map up withget: they wait for it withwhenReadyandfollowMap, 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 betweenu_rangeandv_range, over geographicbounds; the component's docs describe the format precisely enough to produce one.particles,speed_factor,trail,particle_size,opacityandcolor_rampset how it is drawn, and thewind_flowandocean_currentspresets set them for a kind of flow. Every attribute follows the assigns without rebuilding the layer: a newfield(a new forecast hour, another variable) replaces the old one once it has loaded, and the particles carry on from where they are. It hasbefore_id,min_zoomandmax_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 pushesflow:clickedwith the flow at a clicked point (u,v,speed, and thedirectionthe flow goes towards, in degrees clockwise from north) andflow:errorwhen 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].followMapis exported from the package entry (#101), with the types of its callbacks,MapAttachandMapDetach, andMapReadyCallback, the type of the callback ofMapManager.whenReady.followMap(mapId, attach)callsattachwith the map registered undermapIdas soon as there is one, and, when that map is removed, calls whatattachreturned withtrue, thenattachagain with the map rendered under the id in its place. The function it returns stops following, and calls whatattachreturned withfalse. 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 fromMapManager.whenNextRegistered.<.geojson_layer>takes a URL asdata(#102): anhttp://orhttps://URL, or a path from the root of the site, such as~p"/data/quakes.geojson". The browser fetches it (MapLibre'ssetDatawith 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 withhttp://,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 withsetData, as new data does.<.geojson_layer>takespromote_id, the name of a feature property that MapLibre takes each feature's id from, passed to the source aspromoteId(#108). Feature state then addresses a feature by that property, a UUID string say, without a top-levelidon every feature:promote_id="uuid"andmap.setFeatureState({source: "<id>-source", id: feature.properties.uuid}, ...). It excludesgenerate_id, whose ids follow the order of the data: giving both raises anArgumentError, and so does apromote_idthat is not a non-empty string. A newpromote_idreplaces the source under the layer, as a newgenerate_iddoes, 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 ofdata-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 sendsdata-configwithout the data, and the hook leaves the source as it is; newdatasendsdata-geojsonalone, which the hook gives to the source withsetData, leaving paint, layout and filter alone. With 500 points (57 KB of GeoJSON), a change toheatmap-radiussent 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), indata-records, as<.geojson_layer>does. A change topropsor another attribute no longer sends the data again: with 500 records (20 KB of JSON), a change togetRadiussent 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. Theupdate_triggersgiven to the component apply as before.<.deckgl_layer>follows the map registered under itsmap_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_loadedstill 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 oflayer:feature_clicked,layer:feature_mouseenterandlayer: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 itssourcedataandsourcedataloadinglisteners, which MapLibre fires for every tile of every source, only while it asks forsource:data, and itserrorlistener only while it asks forsource:error. Both follow a neweventsvalue 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. pushToLiveViewof the exportedEventDispatcher(the map hook'sdispatcher, or one fromcreateEventDispatcher, 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'seventstoo: 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'sevents, as before, and so ispushToLiveViewTarget; 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.MapLibreOverlayallows 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 samebefore_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'seventsask. A component with the id of a deck.gl layer already on the map gets no layer, and pushes adeckgl:errorthat 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
maplibrexpackage is public and covered by the version number (MapHooks,MapManagerwithwhenReady,whenNextRegistered,getandisRegistered,useMap,requireMap,followMapand 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
MapHooksadds to an application'shooks(MapHook,MarkerHookand 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...MapHookslast the components keep working; with the application's hooks last,<.map>mounts the application'sMapHookand no map appears. A test checks the list against the keys ofMapHooks, 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, andspeed(instead ofduration) andcurveare MapLibre's flight options.durationandspeedtogether, an unknown option or an invalid value raise anArgumentError. The flight lands where the map would open withoutfly: itscenter,zoom,bearingandpitch, the configured defaults, or itsbounds. It runs once per mount and gives way: withprefers-reduced-motion: reducethe 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 ownmap:moved, rendered back by the LiveView, does not cut it. It ends with onemap:movedwhere the map lands; there is no new event.flyis read at mount only, and leaves the projection alone (the flight looks best on a globe: seeprojectionbelow). Off by default: a map withoutflyrenders and behaves exactly as before. - A
projectionattribute 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 withmap.setProjectiononce its style has loaded, and again on every new style (a newstyle,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. Withfly, the projection is in place before the flight starts. Any other value raises anArgumentError. Withoutprojection(or withnilorfalse) 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 itsid, 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 anArgumentError. 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 inmaplibrex.css, and applications restyle them with--maplibrex-curtain-background(Canvasunless set, the page background of a light or darkcolor-scheme),--maplibrex-loader-colorand--maplibrex-curtain-fade(300 ms). While the curtain covers the map, the map element hasaria-busy="true"; withprefers-reduced-motion: reducethere is no fade and the loader does not turn. Withfly, the flight starts once the curtain is gone.curtainis 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 withoutcurtainrenders and behaves exactly as before, and the.maplibrex-map.loadingrules are unchanged. - A
focus_after_openattribute for<.popup>, andpopup_focus_after_openfor the popup of a<.marker>(#75): withfalse, 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'sfocusAfterOpenoption, 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 totrue: popups take the focus exactly as before. - New attributes and JavaScript functions that came with fixes, described
under Fixed:
debugon<.map>(#21);show_user_locationandposition_optionson<.geolocate_control>(#40, #76); the--maplibrex-control-active-background,--maplibrex-control-active-hover-backgroundand--maplibrex-control-radiuscustom properties ofmaplibrex.css(#39); andMapManager.isRegistered(mapId, map)and the optionalmapargument ofMapManager.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>withoutzoomopens at zoom 10 (default_zoom), where it opened at 0, and one withoutstylegets the configureddefault_style, where it had no style; astylethat becomesnilafter mount switches to the default style (#25). - A mounted
<.map>follows changes tobounds,max_bounds,min_zoom,max_zoom,min_pitch,max_pitch,interactiveandattribution_control, which it ignored; a map outside a new zoom or pitch range moves into it and pushesmap:moved(#26). - On a globe, a new
centergiven alone keeps the map's zoom, where MapLibre changed it with the latitude (#74). fly_to/4,fit_bounds/3and the pushedmap:fly_tono longer animate for a visitor who asks for reduced motion, unless givenessential: true(#61).- A map without
debugno longer turns off the logging thatwindow.__MAPLIBREX_DEBUG__turned on (#21). - For a layer, source or terrain component mounted during a map style
change,
layer:added,source:addedandterrain:enabledcome once the new style is in place, and so doessource:removedfor 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 pushespopup:closed, and opens again on the next map rendered under that id (#82). - A
<.marker>whosepopup_textandpopup_htmlare 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 pushespopup:closed(#37). - A
<.popup>without a position stays closed when asked to open and pushes nopopup: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 > pno longer matches them; while the popup is open its slot is not in the component's element; the library defines the custom elementsmaplibrex-popup-bodyandmaplibrex-popup-placeholder; and in browsers withoutNode.moveBeforean<iframe>or a playing video in a popup restarts when the popup re-renders (#66). - The JS commands of
geojson_layerandpopup(GeoJSONLayer.set_data/2,Popup.open/2and 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_grouporcontrol_buttonis 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), andgeolocate:user_location_updatedcarries 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>withoutfit_bounds_optionsstops 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 withgeolocate: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:toggledfor a click comes once the terrain is really on or off (#19). maplibrex.csslays the buttons of a horizontal<.control_group>out in a row and gives active buttons (any withmaplibregl-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>givenactivehasaria-pressed; the attribute's default is nownilinstead offalse, which configures the button asfalsedid. <.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 droptmsthere (#24).<.deckgl_layer before_id=...>draws its layer under that MapLibre layer, where it drew it on top (#10).min_zoomandmax_zoomon<.custom_layer>now hide the layer outside its zoom range, abefore_idthat is not on the map puts the layer on top with a warning, and the uniforms ofupdate_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.cssno longer defines keyframes namedspin(they are nowmaplibrex-loading-spin): an application that animated something withspinand relied onmaplibrex.cssfor it has to define it (#72).
Fixed
Map
- A
<.map>withoutcenter,zoomorstyleignored the configured defaults,default_center,default_zoomanddefault_style(#25). Withoutcenterthe map did not appear at all: MapLibre 5 and 6 throw in the map constructor when given a null centre. Withoutzoomit opened at zoom 0, and withoutstyleit had no style. Now such a map opens at the configured centre and zoom,[0, 0]and 10 unless configured, with the configured style;nilcounts as not given. A map withboundsstill opens on its bounds. After mount, acenterorzoomthat is not given, or becomesnil, leaves the map where it is, as before. Astylethat becomesnilnow switches to the configured default style, where the map was given no style before. Withdefault_center: nilanddefault_zoom: nilin the configuration, such a map opens at the camera of its style instead. - A mounted
<.map>ignored changes tobounds,max_bounds,min_zoom,max_zoom,min_pitch,max_pitch,interactiveandattribution_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 pushesmap: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'ssetMinZoom(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. Newboundsfit 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.interactiveturns all of MapLibre's interaction handlers off and on, also on a map created withinteractive={false}, andattribution_controlremoves and adds the attribution control. The<.map>docs now say what a change to each attribute does after mount;classis still read only when the map mounts. - On a globe (
projection="globe", or a style that declares one), a newcenterchanged 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 inmap:moved. This comes from MapLibre GL JS 5 and 6, and the same call made directly shows it. Now a newcenterkeeps the zoom the map has, as on a flat map (a newzoomin the same update still applies). On a mercator map nothing changes. Visible change: an app with a globe that changes only thecenternow keeps the zoom instead of seeing it drift with the latitude. The pushedmap:fly_toandmap:jump_toevents still reach MapLibre as they are: one without azoomgets the globe's zoom. A new zoom limit (#26 above) also moves a globe into its range at once, with onemap: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/3and the server-pushedmap:fly_topassedessential: trueto MapLibre, which then plays the animation whateverprefers-reduced-motionsays. 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 withfly_to(map_id, center, zoom, essential: true),fit_bounds(map_id, bounds, essential: true), oressential: truein the payload ofmap:fly_toandmap: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 onemap:moved. debug={true}on a<.map>, documented in the README, did nothing (#21): the component had nodebugattribute, 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 whenwindow.__MAPLIBREX_DEBUG__had turned it on, so that flag only worked until the first map appeared. Nowdebugis an attribute (defaultfalse): 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 withoutdebugrenders the samedata-configas before.- A
<.map>removed less than 150 ms after it last moved still pushed that move'smap:movedonce 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 (sameid) 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.703800000000001MapLibre 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 withflythat replaced one with the sameidright 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 acenter,zoom,bearingorpitchthat differs from the one before only by float noise, or by the rounding ofmap: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, andMapManager.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:ifturned 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_layerandcustom_layerincluded),terrainand the terrain of aterrain_controlfollow the map registered under theirmap_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_loadedandterrain:enabledare not pushed again for the new map, as for a style change that puts them back, and the removed map pushes nolayer:removed,source:removedorterrain: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, unlesslng_lathas 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 pushespopup:closed(MapLibre closed it with the map, and a LiveView that keptopenin 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
styleand a layer, source or terrain component too (a theme switch that also restyles a hillshade layer, say) made MapLibre throwTypeError: 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'ssetStyledepending 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 newstyle,set_style/2or themap:set_styleevent), 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:addedandterrain:enablednow come once the new style is in place, and so doessource:removedfor a source component removed during one. Changes rendered in the same reply as apush_event("map:set_style", ...)still reach the map before the style change, as LiveView patches the page before it dispatches events: change thestyleassign 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 pushedterrain:disabled(#60): it turned the terrain off withmap.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 pushesterrain:disabledonce, 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 newstyle,set_style/2ormap:set_style) logged MapLibre's warningUnable 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>, ormap.repaintset by the application), or with changes in quick succession, MapLibre also threwTypeError: 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 asmap.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:enabledis 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 latersetStylethen 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. Astyledatathe 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 pushesterrain:disabledonce. 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 withmap.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_textorpopup_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 anoffsetkey whose value wasundefined, 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_textorpopup_htmlgiven 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), andnilor""for both removes it, closing it if it is open. An emptypopup_textgives way topopup_html; at mount, an empty value now gives no popup, where it gave one that opened empty. The docs described apopupslot that the component does not have; they now describepopup_textandpopup_htmlinstead, 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 defaultanchor,"auto", made MapLibre throwTypeError: 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"andnilnow give MapLibre no anchor. Every attribute now follows its assigns after mount: a newlng_latmoves the popup, new slot content replaces its content, andmax_widthandoffsetchange in place;anchor,close_button,close_on_click,close_on_moveandclass_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 nopopup:closedorpopup:openedfor the swap. The open state is applied whenopenorlng_latchanges: a popup the user closed no longer opens again on an unrelated re-render (it did with an explicitanchor), and a newlng_latwithopenstilltrueopens it there. The popup waits for its map, as the marker does, and a popup removed from the page no longer pushespopup:closed. The docs no longer showPopup.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:openwithoutlng_lat, oropen={true}with nolng_latmade MapLibre mark it open with nothing on the map, and pushedpopup: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 lastlng_lat, or the last onePopup.open/2orPopup.set_location/2(or their server commands) gave it:openturnedtrue, or a toggle, afterset_locationopens it there, and alng_latgiven later withopen={true}opens it, as before. Alng_latthe 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 aJScommand aimed at an id found the hidden copy, and aphx-hookelement 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, andphx-click, forms (phx-change,phx-submit),phx-hookelements 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, bothdisplay: contents, so the layout is the same but a child selector such as.maplibregl-popup-content > pno longer matches them;[data-popup-content]is rendered withstyle="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 withoutNode.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 needphx-target={@myself}unless the map is in the same component, since the popup shows its content inside the map's element.Phoenix.LiveViewTeststill finds the content where the component renders it. - The JS commands of
geojson_layerandpopupdid nothing in the browser (#22):GeoJSONLayer.set_paint_property/3,set_layout_property/3,set_filter/2,set_data/2,show/1andhide/1, andPopup.open/2,close/1,toggle/1andset_location/2returnedJS.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'sfly_to/4: each one dispatches a DOM event to the component's element (maplibrex:layer_set_paint_property,maplibrex:popup_openand so on), with the payload of the server command of the same name as itsdetail, 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 withpush_event/3) work as before. Names and arities are unchanged. A LiveView that wrote ahandle_event/3clause to echo these events back withpush_event/3no 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_groupandcontrol_buttonread their attributes once, andzoom_rangekept using theminandmaxit was mounted with on every zoom after an update. They now share one lifecycle and follow their assigns: a newpositionmoves 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_zoomandvisualize_pitch;container_id;compactandcustom_attribution;track_user_location,show_accuracy_circleandshow_user_location, below); and the others apply to the same control (unitandmax_widthofscale_control,fit_bounds_options, the terrain control'sterrain_source_idandexaggeration, theclassofcontrolandcontrol_group, which now reaches the control's container, andorientation). 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 becausetrack_user_locationbecamefalsepushesgeolocate: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;idandmap_idare 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 logsCannot read properties of undefined (reading 'off')for each of them; while acontrol,control_grouporcontrol_buttonis not on a map, its content stays hidden in the component's element, also after its map is removed; and acontrol_buttonwithout atooltipno longer gets an emptytitleafter an update. Thecontrol_groupexamples now give the nestedcontrol_buttoncomponents their requiredidandmap_id. - An
<.attribution_control>added a second attribution control to its map (#58):<.map>shows one of its own unlessattribution_controlisfalse, 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'sattribution_controlis stilltrue; 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 passedattribution_control={false}to get a single control, as the workaround was, keeps working. <.geolocate_control>hid the user's location dot withshow_user_heading={false}and reported the map's centre as the user's location (#40). The hook passedshow_user_headingto MapLibre asshowUserLocation, which is the dot, and pushedgeolocate:user_location_updatedwithmap.getCenter()on everymoveendwhile the camera followed the user (so also for a zoom by hand), from a listener it never removed. Nowshow_user_headingis not passed to MapLibre, which draws no heading in versions 5 and 6, so it has no effect; the newshow_user_locationattribute (defaulttrue) is MapLibre's option for the dot, and follows its assign like the others.geolocate:user_location_updatednow comes from the control's owngeolocateevent: 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 samecoordsasgeolocate:location_found. Visible changes:show_user_heading={false}no longer hides the dot (passshow_user_location={false}for that);geolocate:user_location_updatedcarries the user's position instead of the map's centre, and itscoordsnow also hasaccuracy,altitude,altitudeAccuracy,heading,speedandtimestamp, 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. Thecoordsfields are now documented.<.geolocate_control>replaced two of MapLibre's defaults with its own (#76). Withoutfit_bounds_optionsit sent%{}, which MapLibre takes as given: the map could zoom in past MapLibre'smaxZoom: 15when it went to the user's position. And it created every control withpositionOptions: {enableHighAccuracy: true}and nothing else, which replaces MapLibre's position options as a whole: notimeout, so a position request could wait for ever, andmaximumAge0, the browser's default. Now an option the template does not give, or gives as%{}, is not sent, and MapLibre's own apply:maxZoom: 15for the fit, andtimeout: 6000andmaximumAge: 0for the position, which is still asked for withenableHighAccuracy: true, as before. A newposition_optionsattribute sets the position options; each key given replaces its default and the others keep theirs, soposition_options={%{enableHighAccuracy: false}}asks for a position of normal accuracy and keeps the timeout.fit_bounds_optionsgiven 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 withoutfit_bounds_optionsstops 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 withgeolocate:location_error(code 3, timeout). Giveposition_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, whatevershowAccuracyCircle, 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_foundandgeolocate:user_location_updatednever reached the LiveView, andgeolocate:location_errorcame withcodeandmessageundefined. maplibre-gl 6 copies a position or an error onto the control's event withObject.entries, which takes only an object's own properties, and a browser keepscoords,timestamp,codeandmessageon the prototype; maplibre-gl 5 copied them withfor...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_onSuccessand_onErrorcallbacks, 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 pushedterrain_control:errorand 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 newenabled, the terrain goes on as soon as the style and the source can take it, in any template order, followsterrain_source_idandexaggeration, and comes back after a basemap switch; switched off, or with the control removed, the terrain it turned on goes off.terrain_control:toggledis now pushed for a click once the terrain is really on or off, and not for a click MapLibre refuses, which pushesterrain_control:errorand leaves the button off; a change ofenabledfrom the LiveView pushes none, as before. The button now hasaria-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 newterrain:enabledorterrain:disabled. Visible changes:terrain_control:toggledfor a click on a map whose DEM source is not there yet now comes once the source is, and the secondtoggledof 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,activeandclassand itsphx-click(and the other forwarded bindings) through re-renders, as a button on its own does; a click pushes its event once. Itspositiondoes not count there. Markup changes: the content element of<.control>and<.control_group>has adata-maplibrex-control-contentattribute, and the element of<.control_button>has the classmaplibrex-control-button, whichmaplibrex.cssuses to draw MapLibre's separator between two nested buttons; a nested button's element is shown withdisplay: contents.<.control_group orientation="horizontal">looked the same as a vertical group, and anactive<.control_button>the same as any other (#39): the hook addedcontrol-group-horizontalandmaplibregl-ctrl-active, and no stylesheet had a rule for either.maplibrex.cssnow 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 withmaplibregl-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-backgroundrestyles, and--maplibrex-control-active-hover-backgroundits 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(default8px) rounds the control and them. The group's content element has the classesmaplibrex-control-groupandmaplibrex-control-group-horizontal(or-vertical) for this, next tocontrol-group-horizontal, which stays. Visible changes: horizontal groups and active buttons, including buttons an application marks withmaplibregl-ctrl-activeitself, 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 givenactive(trueorfalse) is now a toggle button: its<button>hasaria-pressed="true"oraria-pressed="false", as the terrain control's has. A button withoutactiveis not a toggle and has noaria-pressed; for this the attribute's default is nownilinstead offalse, which looks and configures the hook asfalsedid. <.zoom_range>declaredminandmaxas integers (#77), so a fractional zoom level such asmin={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 notmssource property, it reads the TMS row order fromscheme: "tms", and the component passedtmsthrough. Nowtms={true}sendsscheme: "tms", so the tiles of a TMS server are no longer drawn upside down; aschemegiven too wins over it. The component no longer sends atmskey. An app that gavetms={true}to a server that is in fact XYZ now sees its tiles flipped: droptmsthere.<.deckgl_layer>acceptedbefore_idand 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 itsbeforeId, and deck.gl draws it under that MapLibre layer (the overlay is interleaved, the mode that honours it); abeforeIdgiven inpropsstill works, andbefore_idwins over it. A deck.gl layer withoutbefore_idis drawn on top, as before. An app that gavebefore_idnow sees its layer under that one.- A mounted
<.custom_layer>ignored every change to its attributes (#34): the component stored itsdata-configwithMap.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 usesassign/3, and the layer follows its attributes: a newuniformsis drawn from the next frame (adding or removingu_timestarts or stops the animation), a newbefore_idmoves the layer, a newmin_zoomormax_zoomsets its zoom range in place (a bound no longer given adds the layer again), and a newpreset,vertex_shaderorfragment_shaderreplaces 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_zoomandmax_zoomwere 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; abefore_idthat 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. Theupdate_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 theuniformsattribute 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 newstyle,set_style/2ormap: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 itsbefore_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 amap.setStylecalled by application code, the layer stays where MapLibre leaves it. - Removing one animated
<.custom_layer>(one withu_time) froze every other animated custom layer on the same map until the map moved (#81): each layer set MapLibre'smap.repaint, one flag for the whole map, totruewhile it animated and tofalsewhen it went or stopped animating, also over arepaintthe 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,repaintis 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") withoutuniformsdrew 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_opacityandu_point_size; the values are in thecustom_layerdocs), and each uniform given inuniformsor pushed withupdate_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.cssdefined global keyframes namedspin(#72), the name Tailwind'sanimate-spinuses. Keyframes are global, so the stylesheet loaded last won: either everyanimate-spinelement of the application turned about a point shifted by half its size (the library's keyframes includetranslate(-50%, -50%)), or the.maplibrex-map.loadingspinner turned off its centre. The library's keyframes are nowmaplibrex-loading-spin: the.loadingspinner still turns about its centre, and the application'sanimate-spinis its own again. An application that animated something withspinand relied onmaplibrex.cssto define it now has to define it. The stylesheet also drops.maplibrex-map > .maplibregl-map { width: 100%; height: 100% }, which matched nothing: MapLibre addsmaplibregl-mapto the map element itself, which.maplibrex-mapalready sizes, and a rule on that element with both classes would have beaten an application's own size class next tomaplibrex-map. No page looks different for it. The stylesheet's comments are now all in English.
Documentation
- The event docs of the source components,
skyandmarkernow give each event with its payload keys (#28).vector_tile_source,raster_tile_sourceandraster_dem_sourcelistsource_data_type(MapLibre'ssourceDataType, absent while data is loading), which was missing, say thatdata_typeis always"source", which they gave as"source"or"metadata", and give thetileofsource:dataandsource:error;raster_dem_sourcelistedsource:dataandsource:errorwithout their keys. Theirsource:dataexamples readsource_data_type.skysays its two events carry no keys, andmarkerthat its four carrymarkerIdandlngLat. (image_sourceandvideo_sourcelist the events their hooks push since 0.2.1, andmarkerdocumentspopup_textandpopup_htmlsince this release.) - Every HEEx example in the docs now compiles when pasted into a template
(#29). The
geojson_layerexamples passedpaintandlayoutmaps without braces (paint=%{...}, nowpaint={%{...}}), a HEEx syntax error; thecustom_layershader example gaveuniforms={%{...}}; and thefit_bounds/3example 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 ofmax_pitchas 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 withmap.setSky(), with other keys. MapLibre refuses the layer with a style validation error, which the map logs and pushes asmap:error; the hook pushessky:addedall 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
eventslist pushes every event it emits to the LiveView it is rendered in, and a LiveView with nohandle_event/3clause that matches one of them crashes on the first such event (#45): Phoenix raisesFunctionClauseError(orUndefinedFunctionErrorwithout anyhandle_event/3), the LiveView process exits, and the browser reconnects to a newly mounted LiveView, without the old assigns. A plain<.map>does this withmap:loadedonce it has loaded. Give each component theeventsit should push, or keep a catch-all clause,def handle_event(_event, _params, socket), do: {:noreply, socket}, after the otherhandle_event/3clauses. The README's installation step 6 and theMaplibreXdocs 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
eventsattribute on every component that pushes events to the LiveView (#45, in part): a list of event names, such asevents={["map:moved", "map:clicked"]}. When it is given, the component pushes only those events, so a LiveView no longer needs ahandle_event/3clause for the others and they cost no round trip; an empty list pushes none. Without it, every event is pushed, as before. It applies tomap,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, andmaplibre-gl-shared.mjswhen the installed release has it) fromassets/node_modules/maplibre-gl/disttopriv/static/assets/js(#48);--fromand--tochange those. With maplibre-gl 5, or without maplibre-gl, it copies nothing, says why and succeeds, so it is safe in theassets.buildandassets.deployaliases of any application. It replaces thecopy_maplibre_worker/1function the README had applications paste into theirmix.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_idfor layers; new tiles, URL, image or coordinates for sources) and logs one console warning saying that the id was already in use. It pushes nolayer:added/layer:removedorsource:added/source:removedfor it, and a change that would mean removing it (a newsource_idorsource_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 ofgeojson_layertoo. - 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:addedorsource:addedis pushed then, and the component removes it, and pusheslayer:removedorsource: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 pusheslayer:removedorsource:removedfor its own.terrainlikewise 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_sourceandvideo_sourcelisted events their hooks never push (source:loaded,video:loaded,video:error), and those ofvector_tile_source,raster_tile_source,raster_dem_sourceandskyleft out events they do push (#28, in part). Each component's docs now list the events it pushes, the names theeventsattribute takes. - A map whose LiveView keeps its position in the assigns, as the README
shows (
assign(socket, center: center, zoom: zoom)onmap:moved), was moved again to the position it had just reported when the re-render arrived, and so pushedmap:movedtwice 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 onemap:moved, and the map is never moved by its own position coming back: a centre, zoom, bearing or pitch it reported inmap:movedormap:zoom_changedis 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 ofmap: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 andpush_eventcommands move the map as before; each still pushes onemap:movedwhere 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 becausemix assets.deployhad 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 ofpriv/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"passedbearing,pitchandmaxZoomto 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_modulesentry inNODE_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 addsmix maplibrex.copy_workerto the asset aliases and keeps thesetWorkerUrlline. Both were checked in an application freshly generated bymix phx.new(Phoenix 1.8.8), with maplibre-gl 5.24.1 and 6.19.0. - The README and the
MaplibreXandmapdocs show theeventsattribute where they introduce events. The catch-allhandle_event/3clause stays the advice for LiveViews with components that are not givenevents.
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
tilesorurlonvector_tile_source,raster_tile_sourceandraster_dem_source, a new imageurland newcoordinatesonimage_source, and newcoordinatesonvideo_sourceare 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, andsource:erroris pushed when MapLibre threw. geojson_layerfollows every attribute:min_zoom,max_zoom,before_id,typeand the clustering attributes as well asdata,paint,layoutandfilter. What the server commandslayer:set_paint_property,layer:set_layout_property,layer:set_filterandlayer:set_dataset 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, usecontrol,control_buttonorcontrol_group, or position it in a wrapper of your own; theMaplibreX.Components.Mapdocs show both. layer:added,source:addedandterrain:enabledare 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.1layer:addedwas also pushed when MapLibre had refused the layer.source:removedis 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 pushessource:removed. In 0.1.1 MapLibre refused the removal whilesource:removedwas pushed anyway.layer:removedandsource:removedare 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:removedorlayer:added/layer:removedfor it. A layer taken over this way still reports clicks and hovers withlayer:feature_*. In 0.1.1 a source component loggedSource "<id>" already existsand left the source alone, and a layer component pushedlayer:addedalthough MapLibre had refused the duplicate layer. - Layer, source,
geojson_layerandterraincomponents no longer logMap "<id>" not foundwhen 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_idnaming 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. terrainno longer logs an error and pushesterrain:errorwhen itsraster_dem_sourceis 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:errornow means MapLibre failed to set the terrain.terrain:disabledis pushed only when the component turns its own terrain off; a terrain set since by something else is left on.- Fewer
map:errorevents and[MaplibreX] Map errorconsole messages: the components no longer make MapLibre refuse a layer whose id is already on the map, abefore_idnaming 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_zoomandbefore_idin place; a paint or layout property or a filter removed from the assigns goes back to its default, and a newsource_idorsource_layer, or a zoom bound that is no longer set, re-adds the layer. Sources: see Added.terrainnow applies a newsource_idorexaggerationat any time; it dropped them while tiles were loading. Controls still ignore assign changes (#3 stays open for them), and so does the map forbounds,max_bounds, the zoom and pitch limits,interactiveandattribution_control(#26). - Changing the map style removed every source, layer and terrain added by
components (#4). Layer, source,
geojson_layerandterraincomponents now put their content back after any style change, as currently configured. After a basemap switch a component layer with nobefore_idis on top again, one with abefore_idis 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
terrainmounted 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
loadevent 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:ifor:fornever 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
stylecalledsetStyleagain 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_layerandterraincomponents 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_layeroften never sentlayer:source_loaded: its one-timesourcedatalistener 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 addassets/node_modulesto esbuild'sNODE_PATH, mark deck.gl as external when it is not installed, serve maplibre-gl v6's worker files, and coverpath:dependencies.
0.1.1 - 2026-11-25
Bugfix release. There are no breaking changes.
Fixed
control,control_buttonandcontrol_groupnever became map controls, andzoom_rangenever reacted to the zoom: their hooks (ControlHook,ControlButtonHook,ControlGroupHook,ZoomRangeHook) were implemented but missing fromMapHooksand the named exports (#2).control_buttonalso now forwards itsphx-click,phx-click-away,phx-keydown,phx-keyup,phx-focusandphx-blurbindings, withphx-value-*,phx-key,phx-target,phx-debounce,phx-throttleandphx-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_buttonorcontrol_groupput 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_layerleft 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 existinggeojson_layerhandlers keep matching). The README and theMaplibreXmoduledoc listedlayer:feature_click; the emitted event islayer:feature_clicked, and the docs now say so. markerattached its drag listeners only when it was draggable at mount, so enablingdraggablelater produced nomarker:drag_*events (#8). Updates tocolor,scale,anchor,offset,pitch_alignmentandrotation_alignmentare now applied (color, scale and anchor rebuild the marker, keeping position, popup and drag state),marker:draggingis throttled to one event per 50 ms, andmarker:drag_endalways 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 itsmarker:drag_endshort, and alng_latsent 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
idin the payload. A map ignores an event whoseidis not its own; without anidevery map reacts, as before.
Development
- Hook tests: vitest with a
maplibre-glmock, run withnpm testinassets/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 popupspopup— standalone popups with HTML content and programmatic control
Layers
geojson_layer— generic GeoJSON rendering with clustering and feature eventscircle_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_controlcontrol,control_button,control_group,zoom_range— building blocks for custom controls
3D & terrain
terrain— 3D terrain with configurable exaggerationsky— atmospheric sky layer for 3D views
Advanced integrations
deckgl_layer— deck.gl layers, lazy-loaded on first usecustom_layer— custom WebGL layers with user-supplied GLSL shaders
Fixed
Source components no longer send
minzoom,maxzoom,tileSize,schemeorencodingunless 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, andmaxzoom: 22requested tiles servers do not have.mapacceptsmin_pitchandmax_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 mergesdata-*attributes onto ignored elements, so reactivity is unaffected.FullscreenControlevents are subscribed on the control rather than on the map.FullscreenControlis its ownEventedand never fires through the map, sofullscreen:enteredandfullscreen:exitedhad never reached LiveView.
Architecture
- TypeScript hook layer with a singleton
MapManagerand a bidirectionalEventDispatcher - Map commands (
fly_to,jump_to,fit_bounds,set_style,zoom_in,zoom_out,reset_north) run client-side viaPhoenix.LiveView.JS.dispatch/3, with no server round-trip map:movedis debounced by 150 ms to cut socket traffic during continuous pan and zoom- deck.gl is dynamically imported the first time a
deckgl_layermounts. 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 indeckgl-manageranddeckgl-layer-factoryhad been pulling all of deck.gl into the main chunk - Debug logging is gated behind
window.__MAPLIBREX_DEBUG__or a map'sdebugattribute; 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_viewrequires it, so the earlier~> 1.14requirement 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/mapboxreads the internalmap.transformthat v6 removed, so a deck.gl layer under v6 raises a message naming the constraint instead of failing inside deck.gl withCannot 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-gland the@deck.gl/*packages are peer dependencies rather than bundled, so an application never loads two copies of MapLibre GL