Leaflet Map


Add a map generated with LeafletJS: an open-source JavaScript library for mobile-friendly interactive maps. Map tiles are provided by default through OpenStreetMap, or MapQuest (with an app key). Can be set per map with shortcode attributes or through the dashboard settings.


Height, width, latitude, longitude and zoom are the basic attributes:

[leaflet-map height=250 width=250 lat=44.67 lng=-63.61 zoom=5]

However, you can also just give it an address, and Google (by default) will look it up for you:

[leaflet-map address="Oslo, Norway"]

The default URL requires attribution by its terms of use. If you want to change the URL, you may define a new attribution, or remove the attribution. You can define this site-wide in the admin, or you can set this per map in the shortcode (0 for disabled):

[leaflet-map attribution=0]


[leaflet-map attribution="Copyright @bozdoz"]

Look at other examples on the Shortcode Helper in the Leaflet Map admin section.


Add a marker to any map by adding [leaflet-marker] after any [leaflet-map] shortcode. You can adjust the lat/lng in the same way, as well as some other basic functionality (popup message, draggable, visible on load). Also, if you want to add a link to a marker popup, use this syntax: [leaflet-marker]Message here: click here[/leaflet-marker] and add a link like you normally would with the WordPress editor.

Lines and other Shapes

Add a line to the map by adding [leaflet-line]. You can specify the postions with a list separated by semi-colon ; or bar | using lat/lng: [leaflet-line latlngs="41, 29; 44, 18"] or addresses: [leaflet-line addresses="Istanbul; Sarajevo"], or x/y coordinates for image maps.

Or you can add a geojson shape via a url (work in progress): [leaflet-geojson src="https://example.com/path/to.geojson"]

Image Maps

Alternatively, you could use a plain image for visitors to zoom and pan around with [leaflet-image src="path/to/image/file.jpg"]. See screenshots 3 – 5 for help setting that up.

Check out the source code on GitHub!

Shoot me a question @bozdoz.


  • Put the shortcode into the post.
  • See the shortcode play out on the front end.
  • For [leaflet-image] upload an image, and copy the URL from the right-hand side
  • For [leaflet-image] paste that image URL into an attribute titled source: example: src="http://lorempixel.com/1000/1000/".
  • See the [leaflet-image] on the front end.
  • If you use [leaflet-marker draggable=true], then you can drag the marker where you want it, open a developers console, and see the specific shortcode to use.
  • Add geojson via URL: [leaflet-geojson src="https://example.com/path/to.geojson"]
  • MapQuest requires an app key, get it from their website; alternatively, you can use OpenStreetMap as a free tile service (remember to add an attribution where necessary).


  1. Choose to add a new plugin, then click upload
  2. Upload the leaflet-map zip
  3. Activate the plugin through the ‘Plugins’ menu in WordPress
  4. Use the shortcodes in your pages or posts: e.g. [leaflet-map] and [leaflet-marker]


Installation Instructions
  1. Choose to add a new plugin, then click upload
  2. Upload the leaflet-map zip
  3. Activate the plugin through the ‘Plugins’ menu in WordPress
  4. Use the shortcodes in your pages or posts: e.g. [leaflet-map] and [leaflet-marker]
How do I change the style for lines/geojson?

Pass the style attributes to the respective shortcodes (see all options on LeafletJS):

[leaflet-line color="red" weight=10 dasharray="2,15" addresses="Halifax, NS; Tanzania" classname=marching-ants]
My map now says direct tile access has been discontinued (July 11, 2016); can you fix it?

Yes. Update to the newest plugin version, and reset defaults in settings. You can choose to use MapQuest by signing up and supplying an app key, or use the default OpenStreetMap tiles (with attribution). See Screenshot 8.

Can I add geojson?

Yes, just give it a source URL: [leaflet-geojson src="https://example.com/path/to.geojson"] It will also support leaflet geojson styles or geojson.io styles. Add a popup message with [leaflet-geojson popup_text="hello!"], or add HTML by adding it to the content of the shortcode: [leaflet-geojson]<a href="#">Link here, or use text from a feature property, like {title}</a>[/leaflet-geojson] or identify a geojson property with popup_property, and each shape will use its own popup text if available.

Can I add kml/gpx?

Sure!? Use the same attributes as leaflet-geojson (above), but use the [leaflet-kml] or [leaflet-gpx] shortcode.

Can I add a message to a marker?

Yes: [leaflet-marker message="Hello there!" visible="true"], where visible designates if it is visible on page load. Otherwise it is only visible when clicked.

Can I use your plugin with a picture instead of a map?

Yes: Use [leaflet-image src="path/to/image/file.jpg"]. See screenshots 3 – 5 for help setting that up.

Can I use my own self-hosted Leaflet files?

Yes: It’s been added to the dashboard options!

How can I add a link to a marker?

Use the marker format [leaflet-marker]Click here![/leaflet-marker] and add a hyperlink like you normally would with the WordPress editor.

Can I add a line to the map?

Use the line format [leaflet-line] with attributes latlngs or addresses separated by semi-colons to draw a line: [leaflet-line addresses="Sayulita; Puerto Vallarta"].

Can I add my own attributions to custom tile layers?

Yes: use the keyword attribution in your shortcode (semi-colon separated list of attributions): [leaflet-map attribution="Tiles courtesy of MapBox; Locations contributed by viewers"]


excellent plugin

I am surprised how few people seem to use webmapping with WordPress. This plugin makes it easy. Congrats and thank you to the developer.

Ein tolles Plugin

einfach zu bedienendes Plugin laßt wenig Wünsche offen, eigene Marker Icons funktionieren gut.
Was mir zur Zeit noch fehlen würde wäre wenn die Icons, die in kml definiert sind auch angezeigt würden. Wenn dann noch MarkerCluster gingen, dann wüßte ich nichts mehr was fehlen könnte.

Read all 10 reviews

Contributors & Developers

“Leaflet Map” is open source software. The following people have contributed to this plugin.


“Leaflet Map” has been translated into 1 locale. Thank you to the translators for their contributions.

Translate “Leaflet Map” into your language.

Interested in development?

Browse the code, check out the SVN repository, or subscribe to the development log by RSS.



  • Fix for plugin settings not being included (somehow)


  • Added functions for translating text
  • Added string interpolation for GeoJSON popups to use feature properties (thanks to @geraldo)


  • Fixes for PHP 7.2: made all method arguments identical
  • Added minified JavaScript files for site speed


  • Added [leaflet-gpx] for GPX format


  • Fix image shortcode ratio


  • Added missing files from 2.8.4


  • Fixed issues with css and js CDN; removed version from querystring
  • Split admin into new class


  • Fix to [leaflet-kml]
  • Standardized src in leaflet-image and leaflet-geojson/kml


  • Fix to image maps
  • Fixes to geocoder
  • Added multi-line popups to markers and geojson/kml


  • Code cleanup
  • Added server-side and client-side methods to prevent WordPress from adding paragraph tags within shortcode tags


  • Added Fit Markers to settings and map shortcode: [leaflet-map fit_markers=1]
  • Moved geojson/kml popup text to the shortcode content instead of a property so that you can use links or other HTML


  • update default Leaflet version (1.1.0 from 1.0.3)


  • added default lat/lngs in the admin; and reordered admin fields to be more user friendly


  • added optional cURL to get geolocations if file_get_contents is not allowed on a server (note: cURL needs to be enabled, obviously)


  • fixed filter_var_array throwing errors in old PHP too


  • Added settings link to plugins page


  • Fix to array_filter on some PHP versions.


  • Fix to possible JavaScript error “Unexpected token <“; only happened when a plugin/theme used wpautop; fix was to remove spaces.


  • Removed unnecessary map counts;


  • Added basic marker icon support (with attributes “iconUrl”, “iconAnchor”, etc.);


  • Changes to map creation which may solve an occasional marker creation JavaScript error
  • Added more attributes to marker shortcode (draggable, title, alt, opacity)
  • Added doubleClickZoom global, database option to globally disable double click zooming (by default), because it’s more inline with disabling scroll zooming by default. Box zooming on the other hand is more intentional


  • Some improvements to the codebase;
  • added the same styling options for lines as there are for geojson;
  • added popups to lines, as there are for markers;
  • added an example to the shortcode admin page for the style attributes on lines;
  • added code and another example for disabling all map interactions (all zooms, keyboard, etc);


  • Added Leaflet 1.0.2 scripts by default (works!);


  • Added KML support [leaflet-kml];


  • Added popup_text and popup_property to leaflet-geojson to bind popups via a shortcode property or geojson properties


  • Added Leaflet and GeoJSON.io styles to geojson shortcode


  • OpenStreetMap.org has an SSL certificate (osm.org didn’t); not a significant upgrade.


  • Changed ajax request to be compatible with some versions of IE.


  • Needed to add support for a MapQuest app key, since they discontinued the direct access of their tiles on July 11, 2016; added an alternate OpenStreetMap tile URL as the new default. Remember to reset options to default values!


  • Added bare geojson support


  • Removed shortcode brackets from leaflet-marker shortcode


  • Fixed slashes in optional map attribution



  • Added htmlspecialchars in admin.php, and custom attributions. Bugfix : removed position in admin menu so it doesn’t overwrite or be overwritten (thanks to @ziodave)


  • Added HTTPS support.


  • Added lines to the map, thanks to @Remigr!


  • Added ability to use hyperlinks in marker messages.


  • Added ability to self-host leaflet files.


  • Uploaded 1.6 to subversion incorrectly!


  • Important fix to conflicts with other plugins!


  • Some helpful js fixes for multiple window onload functions, and added the leaflet-image shortcode!


  • Some fixes for Google geocoding, and switched cookies to db options.


  • Added cookies for Google geocoding to cut back on requests.


  • Added geocoding to map: [leaflet-map address="halifax, ns"].


  • Added messages to markers.


  • First Version. Basic map creation and marker creation.