[openstreetmap/openstreetmap-website] CRUD interface for moderation zones (PR #7148)

James Milner notifications at github.com
Tue Jun 16 19:52:39 UTC 2026


@JamesLMilner commented on this pull request.

To small comments around idiomatic usage with MapLibre - hope they are helpful!

> +    } else {
+      draw.start();
+      draw.setMode("polygon");
+    }
+  });
+
+  draw.on("finish", (id, { mode, action }) => {
+    if (mode === "polygon") {
+      draw.setMode("select");
+    } else if (mode === "select") {
+      // Nothing to do
+    } else {
+      throw new Error(`Unexpected mode "${mode}" (action: "${action}")`);
+    }
+
+    const feature = draw.getSnapshot().find(obj => obj.id === id);

There is the `getSnapshotFeature` method you could use here if you so wish. May be slightly more ergonomic 🙂 

> +                // center will allow resizing of the aspect ratio from the center
+                // and opposite allows resizing from the opposite corner of the
+                // bounding box of the geometry.
+                resizable: false,
+
+                // Can be deleted
+                deletable: true
+              }
+            }
+          }
+        }
+      })
+    ]
+  });
+
+  map.on("load", () => {

Normally we recommend the `map.once("style.load"` event here, and then create the `draw` instance inside this event. `once` ensures the event handler only fires once, and the `style.load` ensures the `Error: Style is not done loading` error is avoided.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/7148#pullrequestreview-4509787828
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/pull/7148/review/4509787828 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20260616/a6f79725/attachment.htm>


More information about the rails-dev mailing list