Skip to content

Commit

Permalink
✨ [open-formulieren/open-forms#2177] Change map interactions with com…
Browse files Browse the repository at this point in the history
…ponent property

With the new property `interactions` the component can defined the possible map interactions. Currently supporting 'marker', 'polygon', 'polyline' and 'circle'
  • Loading branch information
robinmolen committed Dec 10, 2024
1 parent 6381152 commit 5f4fb63
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
17 changes: 17 additions & 0 deletions src/components/Map/Map.stories.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,20 @@ export const MapReverseGeoEmpty = {
},
},
};

export const MapWithInteractions = {
args: {
interactions: {
circle: true,
polygon: true,
polyline: true,
marker: true,
},
onGeoJsonFeatureSet: () => {},
},
parameters: {
msw: {
handlers: [mockAddressSearchGet, mockLatLngSearchEmptyGet],
},
},
};
15 changes: 11 additions & 4 deletions src/components/Map/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const LeaftletMap = ({
defaultCenter = DEFAULT_LAT_LNG,
defaultZoomLevel = DEFAULT_ZOOM,
disabled = false,
interactions,
}) => {
const ref = useRef();
const intl = useIntl();
Expand Down Expand Up @@ -126,10 +127,10 @@ const LeaftletMap = ({
}}
draw={{
rectangle: false,
circle: true,
polyline: true,
polygon: true,
marker: true,
circle: !!interactions?.circle,
polyline: !!interactions?.polyline,
polygon: !!interactions?.polygon,
marker: !!interactions?.marker,
circlemarker: false,
}}
/>
Expand Down Expand Up @@ -183,6 +184,12 @@ LeaftletMap.propTypes = {
]).isRequired,
}),
onGeoJsonFeatureSet: PropTypes.func,
interactions: PropTypes.shape({
circle: PropTypes.bool,
polyline: PropTypes.bool,
polygon: PropTypes.bool,
marker: PropTypes.bool,
}),
disabled: PropTypes.bool,
};

Expand Down
1 change: 1 addition & 0 deletions src/formio/components/Map.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export default class Map extends Field {
onGeoJsonFeatureSet={this.onGeoJsonSet.bind(this)}
defaultCenter={defaultCenter}
defaultZoomLevel={zoom || DEFAULT_ZOOM}
interactions={this.component?.interactions}
/>
</ConfigContext.Provider>
</IntlProvider>
Expand Down

0 comments on commit 5f4fb63

Please sign in to comment.