Skip to content

Commit

Permalink
💄 [open-formulieren/open-forms#2177] Hide map edit controls if all in…
Browse files Browse the repository at this point in the history
…teractions are disabled
  • Loading branch information
robinmolen committed Jan 15, 2025
1 parent a684b73 commit 6856d22
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions src/registry/map/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ const Preview: React.FC<ComponentPreviewProps<MapComponentSchema>> = ({component
featureGroupRef.current?.addLayer(event.layer);
};

const editable = Object.values(interactions || {}).find((interaction) => interaction);
return (
<Component
type={component.type}
Expand All @@ -96,21 +97,23 @@ const Preview: React.FC<ComponentPreviewProps<MapComponentSchema>> = ({component
>
<TileLayer {...TILE_LAYER_RD} url={tileLayerUrl()} />
<FeatureGroup ref={featureGroupRef}>
<EditControl
position="topright"
onCreated={onFeatureCreate}
edit={{
edit: false,
}}
draw={{
rectangle: false,
circle: false,
polyline: !!interactions?.polyline,
polygon: !!interactions?.polygon,
marker: !!interactions?.marker,
circlemarker: false,
}}
/>
{editable && (
<EditControl
position="topright"
onCreated={onFeatureCreate}
edit={{
edit: false,
}}
draw={{
rectangle: false,
circle: false,
polyline: !!interactions?.polyline,
polygon: !!interactions?.polygon,
marker: !!interactions?.marker,
circlemarker: false,
}}
/>
)}
</FeatureGroup>
<MapView lat={lat} lng={lng} zoom={zoom} />
</MapContainer>
Expand Down

0 comments on commit 6856d22

Please sign in to comment.