Commit Graph

115 Commits

Author SHA1 Message Date
Paul Weidner 17dd03f23c Add farm_map_wkt form element. 2022-06-18 07:52:38 -04:00
Paul Weidner 2be0b852db Only require a name to build map popups #515
This allows popups to be rendered for multipolygon geometries
that will not have a measurement calculated.
2022-03-21 19:21:09 -04:00
Michael Stenta e7b96ada2e Remove "administer farm map" from Manager role permissions. 2022-01-07 09:37:53 -05:00
Michael Stenta 5a3d77447c Fix permission for map settings form (/farm/settings/map). 2022-01-07 09:21:16 -05:00
paul121 64c6bacb89 Decrease whitespace in the map popup. 2021-12-08 13:06:36 -05:00
Michael Stenta b966281d77 Put farm_map_mapbox into "farmOS Maps" group. 2021-09-20 16:10:52 -04:00
Michael Stenta f9ecfbbf91 Popup name is required to show popup.
This fixes an issue introduced in commit fcf32771bd
which broke cluster popups. This still works to fix the issue
that the previous commit sought to fix (do not show popups
while drawing).
2021-09-20 15:07:24 -04:00
Symbioquine 3152895f15 Enable the map side panel with layer switcher by default #442
**Why?** Provide a place for more settings and information
to be included on farmOS maps without introducing more and more
border clutter.
2021-09-12 10:23:03 -07:00
paul121 71159d83c3 Issue #3232237 by paul121: Allow the map widget textarea to be hidden
Add display_raw_geometry setting to the map widget.
2021-09-10 07:17:47 -04:00
paul121 73a4fdc529 Move farmOS-map composer dependency to composer.libraries.json. 2021-09-09 15:03:27 -04:00
Michael Stenta 434b473e14 Move toolbar-toggle map resize event listener JS to farm_ui_theme. 2021-09-06 11:00:51 -04:00
Symbioquine c92fe90985 Refactor most of farm_map.js into factory method #436
**Why?** Allow JS in contrib modules to take advantage of
now decoupled map instantiation code to create canonically
extensible/styled maps where the life-cycle of those maps
is controlled by the contrib module JS code.

For example, a contrib module's controller can return;

```php
return [
  'map-prototype' => [
    '#type' => 'farm_map',
    '#attributes' => [
        'id' => 'example-tool-map-prototype',
        'data-map-instantiator' => 'example-tool',
    ],
  ],
];
```

Then create map instances from custom JS like this;

```js
const mapPrototypeElement = document.getElementById('example-tool-map-prototype');

const mapElement = mapPrototypeElement.cloneNode();
mapElement.removeAttribute('id');

myParentContainer.appendChild(mapElement);

const mapInstance = Drupal.behaviors.farm_map.createMapInstance(mapElement, mapElement, 'example-tool-map-prototype', {});
```
2021-09-03 15:20:26 -04:00
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
Symbioquine 9c94dab9db Decouple FarmMap render element styling and JS instantiation #436
**Why?** It should be possible to leverage the farm_map
module's extension mechanism and default styling without
necessarily giving it full control over when the map
instance gets created.

Currently, the FarmMap render element uses the 'farm-map'
CSS class to inform the JS code in `farm_map.js` that it should
instantiate the map. This is problematic since that CSS class
is also used for styling and there's a bunch of code in the
FarmMap render element and in `farm_map.js` which should
be common to pretty much all farmOS maps.

To fix that, this change introduces a new [data attribute] which
is used instead of the CSS class to signal the JS code in `farm_map.js`
that it should actually instantiate the map.

[data attribute]: https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes
2021-09-03 15:20:26 -04:00
Michael Stenta 8f9123b975 Set popup behavior weight to -100.
...so that behaviors that use instance.popup.on()
(including asset_type_layers) don't need to worry
about setting their weight heavier.
2021-09-03 15:19:03 -04:00
Michael Stenta fcf32771bd Only show popups for features that have a name.
This fixes the annoying issue where a mostly-blank popup
appears while drawing shapes in Geofield widget.
2021-09-03 15:16:33 -04:00
Michael Stenta 71db605a98 Merge geometries from multiple uploaded files together. 2021-09-01 22:47:08 -04:00
Michael Stenta 2b7408e87c Support KMZ files in GeofieldWidget "Import geometry from uploaded files". 2021-09-01 22:47:08 -04:00
Michael Stenta a01cc1a930 Change "Find using files field" to "Import geometry from uploaded files". 2021-09-01 22:47:08 -04:00
Michael Stenta e2a1c112e4 Ensure field wrapper DOM ID is unique with Html::getUniqueId(). 2021-09-01 22:47:08 -04:00
paul121 edc107d74a Add warning messages. 2021-09-01 22:47:08 -04:00
paul121 c123e3d2b4 Disable the find using files field button until a file is uploaded. 2021-09-01 22:47:08 -04:00
paul121 ca13997d69 Add setting to farm_map_geofield field widget to support populating geometry from a form file field. 2021-09-01 22:47:08 -04:00
Michael Stenta 48bd4f9f81 Prefix farm_map.settings router item path with a slash for consistency. 2021-09-01 11:10:15 -04:00
Symbioquine 825d37a729 Add weights to ensure map popup is behavior loaded before use #425
**Why?** In 1.x and 2.x prior to this change we were depending on
the insertion order in JS objects to make sure `instance.popup` got
populated before it is used. This change makes the order of the
behavior attachement deterministic - even with farmOS-map 2.x where
the behaviors get attached asynchronously.
2021-08-23 09:59:36 -04:00
Symbioquine b33feb6293 Upgrade to farmOS-map 2.x #425
**Why?** farmOS-map 2.x provides a slightly cleaner
API and more modular/extensible behavior loading.
2021-08-23 09:59:36 -04:00
paul121 0a94bbb6d9 Render the feature name as a link in popups if a url is provided. 2021-06-09 11:33:34 -04:00
paul121 5136e378e5 Remove todo referencing issue #3197363.
This should have been listed above the next code block.
2021-04-21 08:21:02 -04:00
paul121 ec5156876f Update the map size when the map's field wrapper display state changes. 2021-04-21 08:21:02 -04:00
Michael Stenta 2e43c1a7f2 Remove old color config, logic, and schema. 2021-04-16 08:09:27 -04:00
Michael Stenta e569f74918 Provide a layer style loader service for loading styles based on conditions. 2021-04-16 07:46:59 -04:00
Michael Stenta 7f5050681f Create a simple LayerStyle config entity for creating map layer style definitions. 2021-04-16 07:39:13 -04:00
Michael Stenta 98ffd94b5a Add a third-party setting for asset map layer color. 2021-04-14 08:57:21 -04:00
Michael Stenta 930df73049 Revert "Add a setting to configure if the map popup behavior is enabled."
This reverts commit 19f8851543.
2021-04-08 15:37:23 -04:00
Michael Stenta fe95745153 Remove farmOS-map version from farm_map.libraries.yml.
We don't need to keep this up-to-date alongside the composer.json version constraint.
2021-04-08 15:37:23 -04:00
Michael Stenta c82536d4d0 Move asset_type_layers behavior to farm_ui_map. 2021-04-08 15:37:23 -04:00
Michael Stenta 2e4d0bef1d Move logic for disabling zoom when WKT is present to farm_ui_map. 2021-04-08 15:37:23 -04:00
Michael Stenta 83e6d3abfb Add "all locations" layers to default and geofield maps via farm_ui_map instead of default behaviors. 2021-04-08 15:37:23 -04:00
Michael Stenta b58f4f8b1a Move dashboard map and block to farm_ui_map. 2021-04-08 14:59:39 -04:00
Michael Stenta 07b06b3a5f Move subscriber logic for adding dashboard map asset layers to farm_ui_map. 2021-04-08 11:24:55 -04:00
Michael Stenta 577f04fa0c Patch Geofield to add support for centroid WKT in LatLon formatter (Issue #3207078), and remove custom geofield_centroid formatter. 2021-04-08 11:24:55 -04:00
paul121 19f8851543 Add a setting to configure if the map popup behavior is enabled. 2021-04-08 11:24:55 -04:00
paul121 d2d42f3811 Add an "Other locations" layer to the dashboard map. 2021-04-08 11:24:55 -04:00
paul121 a51c58185a Add layers for location asset types to the dashboard map. 2021-04-08 11:24:55 -04:00
paul121 8b4e1eeb9f Add cache tag on the map type. 2021-04-08 11:24:55 -04:00
paul121 7487a782e0 Remove redundant div. 2021-04-08 11:24:55 -04:00
paul121 e066abfd49 Zoom to WKT if it exists else zoom to all locations vectors. 2021-04-08 11:24:55 -04:00
paul121 b5a56381b4 Use array_replace_recursive to allow overriding of values. 2021-04-08 11:24:55 -04:00
paul121 dd423d2208 Dynamically add asset layers to the dashboard map. 2021-04-08 11:24:55 -04:00
paul121 42d1e75535 Add helper function to get the map target ID. 2021-04-08 11:24:55 -04:00