Currently Zooming and Resizing of the map with its markers only happens when the GeoField Map is loaded.

This is undesirable behavior for:

  1. responsive websites where a viewmode can change (ipad)
  2. and as a side-effect it is hard/impossible to trigger recalculation when a map's visibility is changed by custom scripts (a collapse) in themes.

I would like to propose to move the related code in geofield_map.js to a separate function resizeAndZoom().
Secondly I would like to propose to add an 'window.resize' event listener that calls above function.
This solves the viewmode-change behavior issue.

The side-effect can now also be solved easily by themers be adding window.dispatchEvent(new Event('resize')); to custom scripts:

// Collapsable listener in custom theme javascript.
$( ".collapse" ).click(function() {
  // Do stuff with collapsable.
  // ...
});

becomes

// Collapsable listener in custom theme javascript.
$( ".collapse" ).click(function() {
  // Do stuff with collapsable.
  // ...
  
  // Call window.resize() so other scripts can act on it.
  window.dispatchEvent(new Event('resize'));
});
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ndf’s picture

ndf’s picture