@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/[email protected]>
_______________________________________________
rails-dev mailing list
[email protected]
https://lists.openstreetmap.org/listinfo/rails-dev

Reply via email to