I'm trying to get a map to appear in a modal but haven't worked out a solution yet.

I have a list of items and I would like a map with their locations to appear when I click a 'view map' button. I'm using Leaflet maps and Zurb Foundation, although I'm not sure if this affects the solution.

I can get this to sort of work if I include the map block in a the hidden modal div, but I would really only like the map to be loaded on request. (Also there seem to be map resizing issues when it is placed in a modal)

Another approach I tried was to register a path (of a views page) with hook_menu and then load this URL into the modal. This worked BUT included the site header & footer in the modal.

So I guess one solution is how to have just the unthemed views content attached to a path.

Any ideas?

Many thanks, Chris

  • possible duplicate of Drupal 7 - How to get AJAX response displayed in a ctools modal?
    – Felix Eve
    Apr 24, 2014 at 12:50
  • @FelixEve not at all! Firstly, I don't want to use ctools, although if that is a possible solution I'll definitely consider it. Secondly, it isn't really an issue with getting an AJAX response to work - it's using an ajax load. My main problem is getting the content of a block (or just a map) to load into a modal (which at this point is not cTools) Apr 24, 2014 at 13:12
  • 1
    This question appears to be off-topic because it is about code you wrote, for which you want to write better code, or you want to understand why it doesn't work, but you didn't show the code you are using, or the part of the code that is relevant for the question. See Help Center.
    – Mołot
    Apr 24, 2014 at 13:16
  • 1
    @Mołot No code, this is all through Drupal UI using off the shelf modules. I am just trying to find an approach to get a views created map to load into a modal when a button is pressed. So, please can someone offer some help rather than just trying to pick holes in the question... Apr 24, 2014 at 13:21
  • We are not "picking holes". We are trying to understand what you actually did and what you really want, to give you answer you may feasibly use. We need to know what was the results of your search, and research to avoid answering with things you already fount not working, for example...
    – Mołot
    Apr 24, 2014 at 13:25

1 Answer 1


I know this post is old, but for anyone else looking for a quick solution and working in Drupal 8...

Try creating a View Page with the map and markers. Then link to that page with a Modal Link, like so...

<a class="use-ajax" data-dialog-type="modal" href="/your-view-page">View Map</a>

If contextual filters are needed within the view, just add that contextual filter to the href, just as you would that page.

<a class="use-ajax" data-dialog-type="modal" href="/your-view-page/123">View Map</a>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.