A map block for Gutenberg which uses OpenStreetMap and Leaflet.js. It needs no API keys and works out of the box (or, out of the Block, if you prefer). Benefiting from Gutenberg’s potential, the plugin tries a different take on how to add your locations on the map and rethinks a few things, UX-wise.
Instead of manually adding coordinates for each one of your markers, just click-and-drop them directly on the map. You want to adjust their position? Just drag them wherever you want. And instead of filling-in custom fields to set each marker’s popup content, just open that popup and start writing in it, the Gutenberg way (it supports WYSIWYG editing, with links, images, and all). It even stores the map’s zoom level as you use it so that you don’t have to set it by hand.
- No need for API keys. Just install and use it.
- Support for multiple markers.
- Support for a different icon per marker.
- Support for polygons and polylines.
- Dead-simple interface. Don’t search for coordinates and don’t get overwhelmed by too many fields when using multiple markers. Just point and click on the map to add your marker where you want it and edit it’s popup content directly from there.
- Place search. Find locations by typing keywords.
- Remembers the zoom that you set when adding the markers and stores it so that you don’t set it by hand (which you can do anyway if you prefer).
- Adjust the map height.
- Change the default marker icon with a custom one.
- Enable or disable map dragging.
- Enable or disable touch zoom.
- Enable or disable double-click zoom.
- Enable or disable scroll wheel zoom.
- Set a minimum and maximum limit that the user can zoom on the frontend. Setting the same value to both fields will lock the zoom at that level.
- Support for other Layer Providers: MapBox (using your own API key) and Stamen.
- Option to export locations in a JSON file
- Option to import locations from a JSON file
This plugin provides 1 block.
- OpenStreetMap by Out of the Block A map block for the Gutenberg Editor using OpenStreetMaps and Leaflet that needs no API keys and works out of the box.
- Upload the plugin to your WordPress plugins directory and activate it.
- That’s it. You can go to a post/page that supports the Gutenberg editor and start using the block called “Out of the Block: OpenStreetMap”
Do I need an API key, like with Google Maps?
That’s the point, actually. Just install the plugin and start adding maps. Keep in mind, though, that as stated on the OpenStreetMap Tile Usage Policy, OSM’s own servers are run entirely on donated resources and they have strictly limited capacity. Using them on a site with low traffic will probably be fine. Nevertheless, you are advised to create an account to MapBox and get a free API Key.
How do I add a new location?
To add a location, left-click on the map for a while, until you see the prompt saying “Release to drop a marker here”. On browsers that support it, the cursor transforms from hand to crosshair, to make it even more apparent. As long as the prompt is visible, it means that releasing the click will drop the marker at that spot. That slight delay has been added to prevent you from accidentally adding markers all over the place with every click.
Alternatively, you can use the map’s place search functionality.
How do I remove a location?
Click on the marker to open up its popup. There, you will see the “Remove” button.
I can’t find some of the options like disable dragging, setting zoom levels etc
Check under the “Map behavior” section, at the blocks’ settings at the sidebar on the right. It’s toggled off by default, that’s probably why you missed it.
Contributors & Developers
“Out of the Block: OpenStreetMap” is open source software. The following people have contributed to this plugin.Contributors
“Out of the Block: OpenStreetMap” has been translated into 2 locales. Thank you to the translators for their contributions.
Translate “Out of the Block: OpenStreetMap” into your language.
Interested in development?
Browse the code, check out the SVN repository, or subscribe to the development log by RSS.
- [New] Adds support for different icons per marker.
- Updates the
- Updates compatibility with WordPress 6.2.
- [New] Adds option to export locations to a JSON file
- [New] Adds option to import locations from a previously exported JSON file
- [New] Adds support for polygon shapes
- [New] Adds support for polyline shapes
- [Fix] Improves the drag and drop of markers
- Updates the
- Updates the plugin’s assets and documentation
strpos, for better backwards compatibility with older versions of PHP / WordPress.
- Fixes a bug which broke the admin on WordPress versions prior to 5.9.
- Refactors the build scripts to use the official
create-guten-block, which isn’t supported anymore.
react-leafletto their latest versions (Leaflet 1.9.3 and react-leaflet 4.1.0).
- Adds a new option to set the default coordinates when you add a new block. The plugin will try to guess the default location based on the site’s timezone.
- Fixes a PHP warning in the widgets area of the admin
- Updates translations
- Fixes a PHP warning (more info: https://wordpress.org/support/topic/error-under-php8-2/)
- Fixes a bug where the block’s scripts didn’t load if the block is used in a Widget
- Fixes a bug where the block’s scripts didn’t load when used as a reusable block
- Added Stamen as a Tile Provider
- Fixed a bug with map centering when there is only one location
- Fixed wrong link on attributions
- Added MapBox as a Tile Provider
- Place search functionality added
- Improved marker precision
- Better handling of pinning on mobile devices
- Overall improvements on dragging smoothness
- Fixed a bug during plugin activation.
- First releases