-
-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not an issue #4
Comments
Glad to hear you're enjoying it! Good news and bad news... I ran into this problem myself a few weeks ago and have a solution, but it relies on a PR that's sat unmerged for several weeks on the main Leaflet Geoman repo. If you want to use it now, you're welcome to pull the library directly from my fork that I vaguely maintain for my personal project. Usage example: <GeomanControls
onMount={() => {
if (!map.pm.Toolbar.controlExists('mergeMode')) {
map.pm.Toolbar.createCustomControl({
name: 'mergeMode',
block: 'custom',
title: 'Merge Polygons',
className: 'leaflet-button-merge',
toggle: true,
actions: [
{
text: 'Merge',
onClick() {
merge()
},
},
'cancel',
],
})
}
}}
/> Pulling package directly from my fork: "dependencies": {
"@geoman-io/leaflet-geoman-free": "github:TurtIeSocks/leaflet-geoman",
}, If you have suggestions on how we could solve this with this library opposed to upstream, I'm open to them :) |
Thanks for your response. i thought you might like this solution better: since the pm instance is already attached to the map instance you can utalize the whenReady in react leaflet to put your code there..... |
@cubecleveland nice idea! Does it work for you? Unfortunately, I still have the My code looks like this:
Also @TurtIeSocks your PR is reviewed: geoman-io/leaflet-geoman#1295 (review) |
Thanks for this wonderful tool. makes the state mgmt much easier in react.
Im converting my DOM based react to use this tool and i have a few questions or suggestions ?
map.pm.Toolbar.copyDrawControl('Rectangle', {
name: 'aaaaa',
block: 'custom',
className: 'save',
onClick: () => {
map.pm.setPathOptions({
color: 'orange',
fillColor: 'green',
fillOpacity: 0.4
});
},
title: 'Display text on hover button',
actions: actions
});
but i need to initalize it once and make sure that geoman doesnt create this button with every render.
I noticed the library doesnt unmount the geoman component from the map once u initialize it.... so even if i take the GeoMAnControls comp out of the view the pm instance remain in the map....
AM i correct, any help would be good!
Thanks!
The text was updated successfully, but these errors were encountered: