The website I am working on uses Leaflet to display several locations on a map within a block on a page. In another block on the page, a list of location details is displayed below the map. The list of details displays 6 at a time, using Views Load More to allow the user to continue to load more results via AJAX. When clicking the "Load More" button the first time, all works well - 6 more items show. However, when attempting to gather more beyond that first load, the following console error occurs:

Uncaught Error: Map container is already initialized.

The error prevents any additional Views Load More from loading, and the page instead reloads with a query string showing additional results (IE - non-AJAX). This isn't ideal, as it's confusing from a UI perspective - loads AJAX the first time, then query string, then AJAX, etc etc

When I remove the map block completely from the page, the Views Load More functionality works as intended - shows 6 more at a time without any issues.

Perhaps it is related to this issue? The patch on that page has since been applied, but it still doesn't work. If I try to console.log container._leaflet_id in leaflet.drupal.js (referencing the patch in that issue), nothing comes back at all in the console, so the script continues on as normal thinking the map doesn't already exist. So clearly the existing map ID is not being passed / is not accessible?

CommentFileSizeAuthor
console-error.png49.03 KBkferencz91
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

kferencz91 created an issue. See original summary.

PixelPie’s picture

Did you manage to fix this? I'm having the same issue.

kferencz91’s picture

@PixelPie, no, I have not been able to fix, unfortunately....

Burlyn84’s picture

I'm having the exact same issue. When will this be fixed?

astringer’s picture

I was having this issue as well, but with Flexslider.

The issue occurred when I update Leaflet from 7.x-1.3 to 7.x-1.4. Reverting back to the previous module version eliminated the error.

Uncaught Error: Map container is already initialized

Seems to be related to this issue:

The patch from #14 in this issue fixed it.

apaderno’s picture

Version: 7.x-1.4 » 7.x-1.x-dev