riatelab / magrit

Thematic cartography entirely in the browser ♥
https://magrit.cnrs.fr
GNU General Public License v3.0
123 stars 18 forks source link

How to set the "hand lock" button to be unlocked #119

Closed ArmelVidali closed 1 year ago

ArmelVidali commented 1 year ago

Hello,

Do you know how I can set the locker to be unlocked by default everywhere in magrit ?

I could'nt find how and ended up calling the handle_click_hand function but it is not really stable.

Thanks

mthh commented 1 year ago

Hi,

Indeed, the 'hand lock' button is re-locked during various actions (dragging layout features on the map, etc.).

Do you want this lock to remain unlocked at all times? (with or without the possibility for the user re-lock it ?) Or just have it unlocked when you start the application, and then keep the current behavior ?

I've probably got a quick fix for each case, I'll just have to look at the code a bit :sweat_smile:

ArmelVidali commented 1 year ago

I'm trying to have it unlocked when the application starts, with the possibility for the user to relock it later (I have set a map element to be visibile only when the locker is unlocked).

I managed to do it in another branch but I can't remember how ❓

mthh commented 1 year ago

I'll take a look at it and let you know (tonight or tomorrow).

mthh commented 1 year ago

When Magrit opens, the lock is open (so one can pan/zoom on the map). When a target layer is added (this isn't the case for layout layers), the map extent is fitted to the added layer extent and the lock closes automatically at this point.

To prevent the lock from being locked when a target layer is added (which I think is what you want), you can make the following change:

Corresponding git diff:

diff --git a/client/js/layers.js b/client/js/layers.js
index 435c8819..29446d59 100644
--- a/client/js/layers.js
+++ b/client/js/layers.js
@@ -15,7 +15,7 @@ import {

 import {
   ask_join_now, askTypeLayer, binds_layers_buttons,
-  center_map, handle_click_hand,
+  center_map,
   remove_layer_cleanup, scale_to_lyr,
   update_section1, update_section1_layout,
 } from './interface';
@@ -394,7 +394,6 @@ export function add_layer_topojson(text, options = {}) {
     if (_app.current_functionnality !== undefined) {
       fields_handler.fill(lyr_name_to_add);
     }
-    handle_click_hand('lock');

     // If the target layer is a point layer, slightly change the tooltip for the "grid"
     // functionnality:

Hope this helps !

ArmelVidali commented 1 year ago

It works perfectly thank you !