TypeError: Button with this name already exists #1303
Unanswered
lDonKaban
asked this question in
Questions & Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am using react-leaflet + typescript. When creating a custom button or copying an existing one, I get this error (TypeError: Button with this name already exists), but if I use the function to generate a random name, 2 buttons will be created in the toolbar. Please tell me how to fix this?
`const map = useMap();
map.pm.Toolbar.copyDrawControl('Rectangle', {
name: 'RectangleCopy',
block: 'custom',
title: 'test',
});
map.pm.addControls({
position: 'topright',
drawCircle: false,
drawMarker: false,
drawCircleMarker: false,
drawPolyline: false,
drawRectangle: false,
drawText: false,
cutPolygon: false,
rotateMode: false,
oneBlock: true,
});
map.pm.setGlobalOptions({
snapDistance: 15,
allowSelfIntersection: false,
templineStyle: { color: '#183079', dashArray: '5, 5' },
hintlineStyle: { color: '#183079', dashArray: '5, 5' },
pathOptions: { color: '#183079', dashArray: '5, 5' },
});
`
Beta Was this translation helpful? Give feedback.
All reactions