{"id":60425,"date":"2026-03-27T17:05:07","date_gmt":"2026-03-27T16:05:07","guid":{"rendered":"https:\/\/jesusyesares.com\/?p=60425"},"modified":"2026-11-27T18:22:19","modified_gmt":"2026-11-27T17:22:19","slug":"how-to-install-and-set-up-leaflet-map","status":"publish","type":"post","link":"https:\/\/jesusyesares.com\/en\/visualizacion-datos\/how-to-install-and-set-up-leaflet-map\/","title":{"rendered":"How to install and set up Leaflet Map in WordPress from scratch"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Want to put a map on your WordPress site without relying on Google Maps, without paying for an API and without touching a single line of code? That&#8217;s exactly what we&#8217;ll cover in this tutorial.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We&#8217;ll install the <strong>Leaflet Map<\/strong> plugin, create a map from scratch, add markers with popups and publish the map on a WordPress page.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For the demo we&#8217;ll use <strong><a href=\"https:\/\/wordpress.org\/playground\/\" target=\"_blank\" rel=\"noopener\">WordPress Playground<\/a><\/strong>, an official tool that gives you a working WordPress site in your browser without installing anything at all. If you already have your own WordPress site, the steps are exactly the same.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To create a new WordPress site with Playground, just go to <a href=\"https:\/\/playground.wordpress.net\" target=\"_blank\" rel=\"noopener\">playground.wordpress.net<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">At the end of the post you&#8217;ll find a video (in Spanish) with the full explanation.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What Leaflet Map is<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">I don&#8217;t think I need to explain it. In short, Leaflet Map is <a href=\"https:\/\/wordpress.org\/plugins\/leaflet-map\/\" target=\"_blank\" rel=\"noopener\">a free WordPress plugin<\/a> that uses the <strong>Leaflet.js<\/strong> library, which is open source and one of the most widely used in the world for interactive web maps.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Unlike Google Maps:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>You don&#8217;t need a Google account.<\/li>\n\n\n\n<li>You don&#8217;t need a credit card.<\/li>\n\n\n\n<li>There&#8217;s no visit limit that generates costs.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">It has been in the WordPress directory for more than ten years, has over 30,000 active installations and a very high rating. It&#8217;s a mature, stable and well-maintained plugin.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you want to know more about what Leaflet.js is and why it&#8217;s the best option for maps in WordPress, here&#8217;s <a href=\"https:\/\/jesusyesares.com\/en\/visualizacion-datos\/leaflet-map-wordpress-plugin\/\" data-type=\"post\" data-id=\"60018\">the full post where I explain what Leaflet Map is<\/a>. And in this other one I <a href=\"https:\/\/jesusyesares.com\/en\/visualizacion-datos\/what-is-leaflet-javascript-library\/\" data-type=\"post\" data-id=\"1647\">explain what Leaflet is<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Installing the Leaflet Map plugin<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Installation is the same as for any free plugin from WordPress.org:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Go to <strong>Plugins &gt; Add New<\/strong>.<\/li>\n\n\n\n<li>In the search box type: <strong>Leaflet Map<\/strong>.<\/li>\n\n\n\n<li>Click <strong>Install Now<\/strong>.<\/li>\n\n\n\n<li>Once installed, click <strong>Activate<\/strong>.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Configuring the default settings (Settings)<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The first step is to go to <strong>Leaflet Map &gt; Settings<\/strong>. This is where you define the options that will apply by default to every map you create.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">There are lots of options, but to get started you only need to change two:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Default center coordinates<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The <strong>Default Latitude<\/strong> and <strong>Default Longitude<\/strong> fields define the center of the map when it loads. You can enter the coordinates of your city or of the geographic area you&#8217;re interested in.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example, to center the map on Granada:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Latitude:<\/strong> 37.18<\/li>\n\n\n\n<li><strong>Longitude:<\/strong> -3.60<\/li>\n<\/ul>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\ud83d\udca1 To get the coordinates of any point, open Google Maps, right-click on the place and copy the coordinates shown as the first item in the context menu.<\/p>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\">Map height<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">By default the maps come out quite flat. Change the height field to <strong>500px<\/strong> so they look good on most pages.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Once you&#8217;ve changed these values, click <strong>Save Changes<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Using the Shortcode Helper to prepare the map<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Go to <strong>Leaflet Map &gt; Shortcode Helper<\/strong>. This section is very useful because it lets you:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>See a map in real time while you adjust the parameters.<\/li>\n\n\n\n<li>Generate the correct shortcode without typing it by hand.<\/li>\n\n\n\n<li>Copy the shortcode, ready to paste into any page or post.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">When you move the map, the center coordinates change. When you change the zoom, the zoom number updates. When you move the marker, its coordinates change. All in real time.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How shortcode stacking works<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Leaflet Map works by <strong>stacking shortcodes<\/strong>: the base map is defined with one shortcode, and the elements you add (markers, layers, etc.) are inserted with additional shortcodes below the first one.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Basic example for a map with one marker:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; light: false; title: ; toolbar: true; notranslate\" title=\"\">\n&#x5B;leaflet-map zoom=12 lat=37.18 lng=-3.60]\n\n&#x5B;leaflet-marker lat=37.1760 lng=-3.5880]\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\">Adding the map to a page<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Copy the map shortcode<\/strong> shown in the Shortcode Helper.<\/li>\n\n\n\n<li>Go to <strong>Pages &gt; Add New<\/strong>.<\/li>\n\n\n\n<li>In the block editor (Gutenberg), click <strong>+<\/strong> to add a block and search for the <strong>Shortcode<\/strong> block.<\/li>\n\n\n\n<li><strong>Paste the map shortcode<\/strong> into the block.<\/li>\n\n\n\n<li>Click <strong>Preview<\/strong> to see the result.<\/li>\n<\/ol>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\u26a0\ufe0f If you use the classic editor instead of Gutenberg, paste the shortcode directly into the text area of the post or page. It works the same way.<\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\">Adding markers with popups<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\nA marker points to a specific spot on the map. It can have a <strong>popup<\/strong> with text that opens when clicked.\n<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How to generate a marker shortcode<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>In the Shortcode Helper, move the marker<\/strong> to the exact point you want to show.<\/li>\n\n\n\n<li><strong>Copy the marker shortcode<\/strong> shown in the panel.<\/li>\n\n\n\n<li><strong>On your page, paste it<\/strong> below the map shortcode.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">\nTo add text to the popup, edit the shortcode like this:\n<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; light: false; title: ; toolbar: true; notranslate\" title=\"\">\n&#x5B;leaflet-marker lat=37.1760 lng=-3.5880]Alhambra&#x5B;\/leaflet-marker]\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">The text between the opening and closing tags is the popup content. The plugin accepts basic HTML, so you can use bold, line breaks and so on:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; light: false; title: ; toolbar: true; notranslate\" title=\"\">\n&#x5B;leaflet-marker lat=37.1760 lng=-3.5880]&lt;b&gt;Alhambra&lt;\/b&gt;&lt;br&gt;Spain&#039;s most visited monument&#x5B;\/leaflet-marker]\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\">Adding more markers<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">To add a second marker (or as many as you need), just repeat the process and add another shortcode below:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: xml; light: false; title: ; toolbar: true; notranslate\" title=\"\">\n&#x5B;leaflet-map zoom=13 lat=37.18 lng=-3.60]\n\n&#x5B;leaflet-marker lat=37.1760 lng=-3.5880]&lt;b&gt;Alhambra&lt;\/b&gt;&#x5B;\/leaflet-marker]\n\n&#x5B;leaflet-marker lat=37.1767 lng=-3.5994]&lt;b&gt;Granada Cathedral&lt;\/b&gt;&#x5B;\/leaflet-marker]\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">You can add as many markers as you need. The Shortcode Helper makes it easy: move the marker to the point you want, copy the shortcode and paste it into your page.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Customizing the map: basic options<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Leaflet Map lets you customize how the map behaves through shortcode parameters and options in Settings. The most useful ones to start with:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Adding or removing the zoom control<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">By default the map doesn&#8217;t show the +\/\u2013 zoom buttons. To add them:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; light: false; title: ; toolbar: true; notranslate\" title=\"\">\n&#x5B;leaflet-map zoom=12 lat=37.18 lng=-3.60 zoomcontrol=1]\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\">Scroll wheel<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The <strong>scroll wheel<\/strong> option lets you zoom with the mouse wheel. It&#8217;s convenient for the user, but it can be very annoying on long pages: the visitor is scrolling and suddenly the map starts zooming.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">My recommendation is <strong>not to enable it<\/strong>, unless the map takes up the whole screen or is the main element on the page.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\ud83d\udca1 In Settings you can change these options so they apply to all maps by default, without having to add them to each map&#8217;s shortcode.<\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion and next steps<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In this tutorial we&#8217;ve seen how to:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Install the Leaflet Map plugin from the WordPress directory.<\/li>\n\n\n\n<li>Configure the default options (center coordinates, map height).<\/li>\n\n\n\n<li>Use the Shortcode Helper to prepare the map and copy the shortcode.<\/li>\n\n\n\n<li>Add the map to a WordPress page with the Shortcode block.<\/li>\n\n\n\n<li>Create markers with popups, including basic HTML.<\/li>\n\n\n\n<li>Add several markers to the same map.<\/li>\n\n\n\n<li>Control basic options such as zoom and the scroll wheel.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">All without touching a single line of code.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">But, as you know, Leaflet Map has many more possibilities. So I encourage you to explore the Shortcode Helper and start trying them out. I&#8217;ll be writing more about this plugin, which I like so much.<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Como instalar el plugin Leaflet Map en WordPress\" width=\"500\" height=\"281\" src=\"https:\/\/www.youtube.com\/embed\/1TLo6W2jtK4?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n<span hidden class=\"__iawmlf-post-loop-links\" data-iawmlf-links=\"[{&quot;id&quot;:305,&quot;href&quot;:&quot;https:\\\/\\\/wordpress.org\\\/playground&quot;,&quot;archived_href&quot;:&quot;https:\\\/\\\/web-wp.archive.org\\\/web\\\/20260326102751\\\/https:\\\/\\\/wordpress.org\\\/playground\\\/&quot;,&quot;redirect_href&quot;:&quot;https:\\\/\\\/wordpress.org\\\/playground\\\/&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-08-20 03:58:30&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-08-25 10:36:47&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-09-09 07:43:52&quot;,&quot;http_code&quot;:200}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-09-09T07:43:52+00:00&quot;,&quot;http_code&quot;:200},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:307,&quot;href&quot;:&quot;https:\\\/\\\/playground.wordpress.net&quot;,&quot;archived_href&quot;:&quot;https:\\\/\\\/web-wp.archive.org\\\/web\\\/20260327160748\\\/https:\\\/\\\/playground.wordpress.net\\\/&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-08-25 10:36:47&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-08-31 05:54:07&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-09-09 07:43:51&quot;,&quot;http_code&quot;:200}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-09-09T07:43:51+00:00&quot;,&quot;http_code&quot;:200},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:306,&quot;href&quot;:&quot;https:\\\/\\\/wordpress.org\\\/plugins\\\/leaflet-map&quot;,&quot;archived_href&quot;:&quot;&quot;,&quot;redirect_href&quot;:&quot;https:\\\/\\\/wordpress.org\\\/plugins\\\/leaflet-map\\\/&quot;,&quot;checks&quot;:[],&quot;broken&quot;:false,&quot;last_checked&quot;:null,&quot;process&quot;:&quot;pending&quot;}]\"><\/span>","protected":false},"excerpt":{"rendered":"<p>Want to put a map on your WordPress site without relying on Google Maps, without paying for an API and without touching a single line of code? That&#8217;s exactly what we&#8217;ll cover in this tutorial. We&#8217;ll install the Leaflet Map plugin, create a map from scratch, add markers with popups and publish the map on [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":60426,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_ayudawp_aiss_exclude":false,"_ayudawp_aiss_exclude_summary":false,"_ayudawp_aiss_summary":"We'll install the Leaflet Map plugin, create a map from scratch, add markers with popups and publish the map on a WordPress page. Leaflet Map works by stacking shortcodes: the base map is defined with one shortcode, and the elements you add (markers, layers, etc.) are inserted with additional shortcodes below the first one. My recommendation is not to enable it, unless the map takes up the whole screen or is the main element on the page. \ud83d\udca1 In Settings you can change these options so they apply to all maps by default, without having to add them to each map's shortcode.","_ayudawp_aiss_summary_provider":"extractive","_ayudawp_aiss_summary_hash":"c6725472b10a1a60341fefaff9a86b5443e339bd","footnotes":""},"categories":[338],"tags":[339,342,340,341],"class_list":["post-60425","post","type-post","status-publish","format-standard","has-post-thumbnail","category-visualizacion-datos","tag-leaflet-map","tag-leafletjs","tag-mapas","tag-wordpress"],"openstation_lock":null,"openstation_contributors":[],"openstation_attached_media":[60426,60018,1647],"permalink_manager":null,"_links":{"self":[{"href":"https:\/\/jesusyesares.com\/en\/wp-json\/wp\/v2\/posts\/60425","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jesusyesares.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jesusyesares.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jesusyesares.com\/en\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/jesusyesares.com\/en\/wp-json\/wp\/v2\/comments?post=60425"}],"version-history":[{"count":1,"href":"https:\/\/jesusyesares.com\/en\/wp-json\/wp\/v2\/posts\/60425\/revisions"}],"predecessor-version":[{"id":60546,"href":"https:\/\/jesusyesares.com\/en\/wp-json\/wp\/v2\/posts\/60425\/revisions\/60546"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/jesusyesares.com\/en\/wp-json\/wp\/v2\/media\/60426"}],"wp:attachment":[{"href":"https:\/\/jesusyesares.com\/en\/wp-json\/wp\/v2\/media?parent=60425"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jesusyesares.com\/en\/wp-json\/wp\/v2\/categories?post=60425"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jesusyesares.com\/en\/wp-json\/wp\/v2\/tags?post=60425"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}