

Map block with three markers added.
CartoBlocks for Leaflet adds a native Gutenberg block that wraps the Leaflet Map plugin shortcodes. Configure your map visually in the block editor — the plugin generates the correct shortcodes automatically, and the frontend is rendered entirely by Leaflet Map.
Core map features:
[leaflet-wms]) — toggle in Tile Layer panel; configure source URL, layer name, and CRS.[leaflet-image]) — replace tiles with a flat image (floor plans, diagrams, custom maps) on L.CRS.Simple.Markers ([leaflet-marker]):
Lines and polygons ([leaflet-line]):
Circles ([leaflet-circle]):
Data layers ([leaflet-geojson], [leaflet-gpx], [leaflet-kml]):
{property} interpolation, popup property, table view.Image and video overlays ([leaflet-image-overlay], [leaflet-video-overlay]):
Developer-friendly:
.pot file included).Requirements:
The JavaScript and CSS files shipped in the build/ directory of this plugin
are compiled with webpack (via @wordpress/scripts): the JavaScript from the
JSX sources and the CSS from the SCSS sources. The human-readable source code
is publicly available in the plugin’s development repository:
https://github.com/jesusyesares/cartoblocks-for-leaflet
The uncompiled sources (.js and .scss) live in the src/ directory of
that repository. To build the plugin from source:
git clone https://github.com/jesusyesares/cartoblocks-for-leaflet.gitnpm installbuild/: npm run buildThis plugin connects to one external service: the Nominatim geocoding API
operated by the OpenStreetMap Foundation. It is used only in the block
editor, and only when you click the address search button to look up the
coordinates of a place name. It is never called on the frontend of your site
and is never called automatically.
When you perform an address search, the text you type into the search field is
sent to https://nominatim.openstreetmap.org/search so it can be matched
against OpenStreetMap data and returned as a list of candidate locations. The
request also includes your site URL and administrator contact email in the
User-Agent header, following Nominatim’s usage policy for attribution. No other
personal data is transmitted. If you have configured a Nominatim contact email
in the Leaflet Map plugin settings, that value is used instead.
Note: GeoJSON, GPX, and KML data layers, and any map tiles, are loaded by the
Leaflet Map plugin (and your browser) from whatever URLs you enter. Those
requests are made by the Leaflet Map plugin, not by CartoBlocks for Leaflet.
Note: if “Use WMS tile source” is enabled but the WMS Source field is left
empty, the Leaflet Map plugin falls back to a free public demo WMS service
operated by terrestris GmbH (ows.mundialis.de). That service displays a
watermark and is also a third-party request — provide your own WMS URL to
avoid it.
GPX data layers from the Media Library may not render.
When a .gpx file is uploaded to the WordPress Media Library and used as the
source of a GPX data layer, the track may fail to draw, while GeoJSON and KML
layers work in the same setup. This is an upstream limitation in the Leaflet
Map plugin, not in CartoBlocks for Leaflet: its GeoJSON/GPX/KML loader reads the
response as XML (responseXML), which the browser only populates when the file
is served with an XML Content-Type (text/xml, application/xml, or a
+xml subtype). Many web servers serve .gpx as text/plain or
application/octet-stream, so the track is never parsed. The same behaviour
occurs when using the Leaflet Map plugin’s [leaflet-gpx] shortcode directly.
Workarounds: serve the GPX file from a host that sets an XML Content-Type
(e.g. application/gpx+xml), or configure your web server to serve .gpx as
XML. GeoJSON and KML layers are unaffected.
Check out the source code and more details on GitHub!