When bringing in a leaflet map via AJAX, none of the features are available to the JS.

This is because the JS is added in an Drupal AJAX insert command on the whole page, so the leaflet behavior runs for this insert, and tries the process the map, but it doesn't find the map, and the only thing it does is clear out the features.
Then, when the map is finally inserted, the behavior runs and tries to create a map, but there are no features.

We can just move the features clearing code to within the code that uses it.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Steven Jones created an issue. See original summary.

Steven Jones’s picture

Status: Active » Needs review
FileSize
769 bytes
samuel.mortenson’s picture

I'm seeing similar issues when using Panels IPE on a block that contains a Leaflet Map - the current patch doesn't fix my problem, but completely removing this logic does. @steven-jones - could you try out my patch and see if it also resolves your problem? If not, I'll open a new issue and hide it from the issue summary. Thanks!

beltofte’s picture

We have a similar problem with a view block that use some exposed filters. The view is not configured to use AJAX it self, but ajax.js is still called. Maybe because of big_pipe being enabled. The error is:

TypeError: features is null[Read more]  jquery.min.js:14:21
	Drupal.Leaflet.prototype.add_features http://local.dev/core/assets/vendor/jquery/jquery.min.js:14:21
	attach/</< http://local.dev/core/assets/vendor/jquery/jquery.min.js:13:13
	each http://local.dev/core/assets/vendor/jquery/jquery.min.js:2:2859
	each http://local.dev/core/assets/vendor/jquery/jquery.min.js:2:843
	attach/< http://local.dev/core/assets/vendor/jquery/jquery.min.js:7:9
	each http://local.dev/core/assets/vendor/jquery/jquery.min.js:2:2909
	attach http://local.dev/core/assets/vendor/jquery/jquery.min.js:6:7
	Drupal.attachBehaviors http://local.dev/core/misc/drupal.js:160:11
	insert http://local.dev/core/misc/ajax.js:1084:9
	Drupal.Ajax.prototype.success http://local.dev/core/misc/ajax.js:864:9
	bigPipeProcessPlaceholderReplacement http://local.dev/core/modules/big_pipe/js/big_pipe.js:46:9
	each http://local.dev/core/assets/vendor/jquery/jquery.min.js:2:2859
	each http://local.dev/core/assets/vendor/jquery/jquery.min.js:2:843
	bigPipeProcessDocument http://local.dev/core/modules/big_pipe/js/big_pipe.js:68:5
	bigPipeProcess/timeoutID<

Looks like @samuel.mortenson' patch from #3 is solving the issue.

GaëlG’s picture

I had the same problem but on a leaflet attachment display attached to a unformatted list block display. With no AJAX. #3 fixed it.

itamair’s picture

itamair’s picture

#3 applied to dev

itamair’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.