diff --git a/src/components/Map/Map.stories.jsx b/src/components/Map/Map.stories.jsx index 62653ac27..16b68f225 100644 --- a/src/components/Map/Map.stories.jsx +++ b/src/components/Map/Map.stories.jsx @@ -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], + }, + }, +}; diff --git a/src/components/Map/index.jsx b/src/components/Map/index.jsx index 8f59fba72..e835ff6fe 100644 --- a/src/components/Map/index.jsx +++ b/src/components/Map/index.jsx @@ -69,6 +69,7 @@ const LeaftletMap = ({ defaultCenter = DEFAULT_LAT_LNG, defaultZoomLevel = DEFAULT_ZOOM, disabled = false, + interactions, }) => { const ref = useRef(); const intl = useIntl(); @@ -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, }} /> @@ -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, }; diff --git a/src/formio/components/Map.jsx b/src/formio/components/Map.jsx index c82cc9bcc..c07851d1b 100644 --- a/src/formio/components/Map.jsx +++ b/src/formio/components/Map.jsx @@ -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} />