Events Manager locations map with directions

Events Manager is my events and bookings plugin of choice for WordPress, because it is very flexible, easy to integrate into a theme, and has hooks galore for customising to suit almost any requirement. Its location map doesn’t offer a way to provide directions, however. So, here’s how to replace the Events Manager locations map with WP Flexible Map and get a directions link on location pages.

Thanks to the wonder of custom placeholders, Events Manager makes it easy to add any custom elements you want into its events and locations. The standard locations map is added by using a placeholder, #_LOCATIONMAP. Replacing it just requires a new location placeholder that calls WP Flexible Map instead. I’ve chosen to call it ‘#_LOCATIONMAPWITHDIR’, and I add it into the Single Location Page template like this:


<div class="event-location-map">#_LOCATIONMAPWITHDIR</div>


<h3>Upcoming Events</h3>

Some CSS is needed, so that the map has a size on the page.

div.event-location-map {
    margin:0 0 15px 0;

div.event-location-map .flxmap-container {

Here’s the code that handles that placeholder. NB: both Events Manager and WP Flexible Map need to be installed and activated!

[Edit: updated 2015-08-26, also available as a plugin in a gist]

add_filter('em_location_output_placeholder', 'flxmap_events_manager_location', 10, 3);

* add Events Manager location placeholder for map directions
* @param string $result
* @param EM_Location $location
* @param string $placeholder
* @return string
function flxmap_events_manager_location($result, $location, $placeholder) {
    if ($placeholder === '#_LOCATIONMAPWITHDIR') {
        if (function_exists('flexmap_show_map')) {
            if ($location->location_latitude && $location->location_longitude) {
                $result = flexmap_show_map(array(
                    'center'     => $location->location_latitude . ',' . $location->location_longitude,
                    'title'      => $location->location_name,
                    'directions' => 'true',
                    'width'      => get_option('dbem_map_default_width'),
                    'height'     => get_option('dbem_map_default_height'),
                    'region'     => 'au', // hint which region searches apply to
                    'echo'       => '0',  // return as a string
            else {
                $result = '';

    return $result;

And here it is on the page:

Events Manager locations page with custom map

Job is done, complete with directions.

  • RobertB

    thank you for this tutorial…..I cannot get it to work….you reference in your text ” Single Location Page” template…are you referring to /plugins/events=manager/templates/templates/location-single.php? I don’t really understand this reference in the template page – ////
    * Remember that this file is only used if you have chosen to override location pages with formats in your events manager settings!

    * You can also override the single location page completely in any case (e.g. at a level where you can control sidebars etc.), as described here –

    * Your file would be named single-location.php


    Also, if I am on the correct template page, would I put your code AFTER ///////global $EM_Location;

    /* @var $EM_Location EM_Location */

    echo $EM_Location->output_single();


    Thanks for your help.

    • G’day RobertB,

      The Single Location Page template I refer to above is the one you edit in the admin:

      Events > Settings > Formatting > Locations

      The PHP code above can be placed either in a simple plugin, or in your theme’s functions.php file.



      • RobertB

        Brilliant…thanks Ross for the quick reply….that did the trick….I ALSO added

        #_LOCATIONMAPWITHDIR to the single EVENT template to allow someone to get directions straight from the single event page listing…thanks mill….

  • Patrick Catthoor

    I got this code working perfectly until some time ago when I noticed that maps were no longer showing up.
    I can’t figure out what changed or how to correct the problem.
    Is there anyone else experience this problem? It may have to do with recent updates to WordPress or the WP Flexible Map plugin. For now, I’m again using the standard #_LOCATIONMAP, but I would prefer the map with directions to get working again.
    All suggestions are welcome.

    • I’ve just updated the code, also created a self-contained plugin in a gist if that helps. If it’s still not working, please provide a link.


      • Patrick Catthoor

        Thank you so much Ross for the quick response! Everything is working fine now.

      • Patrick Catthoor

        Thanks Ross, for the quick reply. I got it working again too.
        I experienced that it only works with fixed width. As soon as I try to make the map act responsive by putting 80% in the width field, the map no longer shows up. Any suggestions on how to make the map responsive?

        • G’day Patrick, you need its container to have a deterministic width. i.e. you told the map to be width 80%, but 80% of what? Its container must have width, or both it and the container will have 0 width. If the container has no width, then set that to 100% — which of course also runs the risk of being 100% of 0 if its container, in turn, has no deterministic width :-)

  • Katie

    Yes I came looking because I can no longer see maps. So it appears it is not only me :)

    • I’ve just updated the code, see also the self-contained plugin in a gist if that helps. If it’s still not working, please provide a link.


      • Katie

        That fixed it, thanks so very much :)

        • Katie

          edit But cannot get it to appear on the Single event page (so when using event calendar the date single event to display the map directions…. Thanks so much again

          • G’day Katie, did you replace the #_LOCATIONMAP placeholder with #_LOCATIONMAPWITHDIR in the Single Event Page format? I just tried on my copy and it worked.

          • Katie

            Yes I had, it fixed it on the other page but single event remains blank = maybe it is a sizing issue also… Have tried a number of things but remains blank

          • Can you share a link to the page? I can have a quick look.

          • Katie
          • It’s not adding the script for the map to that page, so it’s not processing the placeholder. Can you please open a support ticket on the support forum and post your Single Event Page format? I’ll have a look at it tomorrow sometime.

          • Katie

            Thanks so much – could you please remove the link above

      • Katie

        edit But cannot get it to appear on the Single event page (so when using event calendar the date single event to display the map directions…. Thanks so much again