How to add interactive maps to a WordPress site
For a basic location map, use a Google Maps or My Maps embed inside WordPress’s Custom HTML block. For custom markers, filters, pop-ups or GeoJSON data, you need custom JavaScript or a dedicated map plugin.
- 01Choose the map type
- 02Create or configure the map
- 03Add the manual embed
- 04Build the advanced route manually
- 05Make the map responsive
- 06Test before publishing
What you need
- A WordPress site with editor access
- The map, locations or geographic data you want to display
- A Google Maps, My Maps or mapping-service account if required
- A child theme or custom plugin if you plan to add JavaScript
Choose the map type
Decide whether you need a single location, a route, a collection of places, or a data-rich map with filters and pop-ups. A single location or route can usually be embedded without writing code. Multiple layers, custom shapes, searchable markers and data loaded from a spreadsheet or GeoJSON file usually need custom JavaScript or a map plugin.
Also decide whether visitors need directions, street view, filtering, clustering, accessible text alternatives or links to separate location pages. These choices affect which map service and WordPress method you should use.
Create or configure the map
Build the map in Google Maps, Google My Maps or another mapping service. Add the locations, labels, routes and layers before embedding it. If you use the Google Maps Embed API rather than a standard share embed, create an API key and restrict it to your website’s domain. Google documents map modes for places, directions, street view, views and searches, and requires an API key for the Embed API.
Keep the map focused. A crowded map is difficult to use on a phone, and long marker descriptions often become awkward inside small pop-ups.
Add the manual embed
Edit the WordPress page and insert a Custom HTML block where the map should appear. Paste the iframe code supplied by the map service, then set a sensible height and make the width responsive, such as width=100%. The WordPress editor supports Custom HTML for embed code, but it can remove iframe or script markup when the user does not have the required unfiltered HTML permission.
Publish or preview the page and check the front end, not only the editor preview. If the iframe disappears after saving, ask an administrator to add it, use a controlled embed block or install a map plugin instead of repeatedly pasting code that WordPress sanitises.
Build the advanced route manually
If you need your own markers, shapes, pop-ups or GeoJSON data, load a mapping library and your map code through a child theme or custom plugin. WordPress recommends enqueueing JavaScript with wp_enqueue_script(), normally from the wp_enqueue_scripts action, rather than placing script tags directly in page content.
Your script then creates the map, reads the location data, adds layers and connects marker clicks to pop-ups or filters. This route gives you control, but you must maintain the library, handle API keys, check licensing and fix conflicts when the theme, page builder or another plugin changes the page markup.
Make the map responsive
Place the map inside a container that can shrink with the page, use a deliberate height on small screens and avoid relying on a fixed desktop width. Test scrolling, zooming, marker taps and pop-ups on a phone. Google recommends making embedded maps large enough to interact with comfortably and does not support them below 200 pixels in either dimension.
A common failure is building separate desktop and mobile containers and accidentally loading duplicate maps or shortcodes. Page-builder layouts can also hide the map in one breakpoint while showing it in another, so inspect the responsive settings before changing the map code.
Test before publishing
Check the map while logged out, on a phone, with keyboard navigation and with browser privacy features enabled. Confirm that markers open, links work, the map does not cover nearby content and the page still loads if the external map service is unavailable.
Give the map a useful heading and provide the important locations as text elsewhere on the page. If an API map is blank, check the browser console, API-key restrictions, billing or quota notices, referrer policy and whether a security or consent plugin is blocking the external request.
For many markers, filters, pop-ups, SVG or GeoJSON layers, use MapSVG. It provides an editor for interactive maps and supports SVG, GeoJSON and Google Maps data, so it avoids much of the custom JavaScript work while keeping the map manageable in WordPress.
Let MapSVG do it
Flexible SVG, GeoJSON, and Google Maps support with filters and pop-ups; best for data-rich interactive maps.
Sources
- developers.google.com /maps/documentation/embed/embedding-map?hl=en&utm_source=ope…
- wordpress.org /documentation/article/custom-html/?utm_source=openai
- developer.wordpress.org /reference/functions/wp_enqueue_script/?utm_source=openai
- wordpress.org /support/topic/not-showing-up-on-mobile-5/?utm_source=openai
Questions
- Can I add an interactive map to WordPress without a plugin?
- Yes, you can add a basic interactive map without a plugin by pasting an iframe into a Custom HTML block. This works well for a location, route or simple collection of places. You need custom JavaScript or a map plugin when the map requires your own data, searchable filters, custom shapes, advanced pop-ups or dynamic updates.
- Why does my map disappear after I save the page?
- The map may disappear because WordPress sanitised the iframe or script from the Custom HTML block. Users without the required unfiltered HTML permission can have disallowed markup removed, and security, consent or caching plugins may also block the external map. Add the embed as an administrator, check the rendered page and review blocked requests in the browser console.
- How do I make an embedded map work on mobile?
- Make the iframe width responsive, give it a usable height and test it inside the actual mobile layout. Fixed-width containers, short iframe heights and page-builder breakpoint settings commonly make maps look clipped or invisible. Avoid creating separate desktop and mobile copies unless you have a clear reason, because duplicate maps can load conflicting embeds.
- Do I need a Google Maps API key for WordPress?
- You need an API key when you use the Google Maps Embed API. A map service may also provide a separate share or My Maps iframe, so check the embed method you selected rather than assuming every Google map uses the same setup. Restrict API keys to the domains that should use them and investigate quota or referrer errors when the map is blank.
- What is the fastest way to add a map with filters and pop-ups?
- The fastest practical route is a dedicated map plugin such as MapSVG. Create the map in the plugin, import or draw the locations, configure filters and pop-ups, then insert the generated map into the page. This is quicker than building and maintaining a mapping library, data model, responsive layout and custom JavaScript yourself.