Add farm_map library to create and style map instances.

This commit is contained in:
paul121 2020-12-04 08:57:05 -08:00 committed by Michael Stenta
parent 1850c64ee2
commit 000b7b8ea5
3 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1,3 @@
.farm-map {
height: 400px;
}

View File

@ -11,3 +11,12 @@ farmOS-map:
dependencies:
- core/jquery
- core/jquery.once
farm_map:
css:
theme:
css/farm_map.css: { }
js:
js/farm_map.js: { }
dependencies:
- farm_map/farmOS-map

View File

@ -0,0 +1,22 @@
(function ($, Drupal) {
Drupal.behaviors.farm_map = {
attach: function (context, settings) {
var options = {
// TODO: Set the map units.
//units: drupalSettings.farm_map.units,
interactions: {
onFocusOnly: true
},
};
$('.farm-map', context).each(function (index, element) {
$(element).once('farm-map').each(function () {
$(element).attr('tabIndex', 0);
farmOS.map.create($(element).attr('id'), options);
$('.ol-popup-closer', context).click(function () {
$(element).focus();
});
});
});
}
};
}(jQuery, Drupal));