3
0
Fork 0
mirror of https://github.com/farmOS/farmOS.git synced 2024-02-23 11:37:38 +01:00
farmOS/modules/core/map/js/farmOS.map.behaviors.geofield.js
Symbioquine 6ce9ec2480 Reduce coupling between map element id and other logic #436
**Why?** There were a bunch of places where farmOS implicitly depends
on the id of the map element to look up settings and access the map
element after the map is instantiated.

This change makes it so there is only one place in the JS that depends
on the map id to dereference the drupalSettings and assign them under
`instance.farmMapSettings` so behaviors can access them.
2021-09-03 15:20:26 -04:00

14 lines
399 B
JavaScript

(function () {
farmOS.map.behaviors.geofield = {
attach: function (instance) {
instance.editAttached.then(() => {
instance.edit.wktOn('featurechange', function(wkt) {
instance.map.getTargetElement().parentElement.querySelector('textarea').value = wkt;
});
});
},
// Make sure this runs after farmOS.map.behaviors.wkt.
weight: 101,
};
}());