openlayers-8.x-4.x-dev/js/openlayers.behaviors.js
js/openlayers.behaviors.js
(function ($, Drupal, drupalSettings, once) {
"use strict";
Drupal.behaviors.openlayers = {
attach: function (context, settings) {
$.each(settings.openlayers.maps, function(m, data) {
const map_elements = $(once('openlayers-map', '#' + m));
map_elements.each(function () {
Drupal.openlayersPluginManager.attach(context, settings);
var map_id = $(this).attr('id');
if (drupalSettings.openlayers.maps[map_id] !== undefined) {
Drupal.openlayers.processMap(map_id, context);
}
});
});
},
detach: function (context, settings) {
Drupal.openlayersPluginManager.detach(context, settings);
}
};
})(jQuery, Drupal, drupalSettings, once);
