Integrating with react-leaflet
?
#6
Closed
charlieforward9
started this conversation in
Ideas
Replies: 1 comment 2 replies
-
The integration happens automatically. When import { LeafletEventHandlerFnMap } from "leaflet";
import { useMapEvents } from "react-leaflet/hooks";
import { useLeafletEditable } from "leaflet-editable-hook";
const onCreated: LayerEventHandlerFn = (e) => {
console.log(e);
};
//These two hooks do the same thing.
useMapEvents({
"editable:created": onCreated,
});
useLeafletEditable({
events: {
onCreated,
},
}); I propose removing the redundant event handlers from the hook props, and expose this hook functionality exclusively for its edit control functions: At minimum, we should be able to call the hook without passing in events: useLeafletEditable(); //Expected 1 arguments, but got 0. index.d.ts(53, 3): An argument for 'options' was not provided. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Docs: https://react-leaflet.js.org/docs/api-map/
Considering the presence of the
useMapEvents
hook, I am curious about the value of integrating the Leaflet.Editable functionality within the react-leaflet API and rely on code-splitting/tree-shaking, etc to ensure that the editable methods/handlers do not end up in thebuild
files of projects that do not depend on it.In other words, if someone wants to use this editable code, the
MapContainer
would have the toggle to enable it and that would attach all the other MapEvents to theuseMapEvent
hook.The return value of the hook would have to be discussed. It may be better to return a new hook with the edit controls, such as
useMapEdit
and pass the config into this.Beta Was this translation helpful? Give feedback.
All reactions