Skip to content

Commit

Permalink
Merge pull request #747 from open-formulieren/feature/2173-custom-map…
Browse files Browse the repository at this point in the history
…-background

Custom map backgrounds
  • Loading branch information
robinmolen authored Dec 12, 2024
2 parents 81cacca + d15d15f commit 0a335fa
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/components/FormStepSummary/ComponentValueDisplay.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ const MapDisplay = ({component, value}) => {
return <EmptyDisplay />;
}

return <Map markerCoordinates={value} disabled />;
return <Map markerCoordinates={value} disabled tileLayerUrl={component.tileLayerUrl} />;
};

const CoSignDisplay = ({component, value}) => {
Expand Down
7 changes: 7 additions & 0 deletions src/components/Map/Map.stories.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,10 @@ export const MapReverseGeoEmpty = {
},
},
};

export const MapWithAerialPhotoBackground = {
args: {
tileLayerUrl:
'https://service.pdok.nl/hwh/luchtfotorgb/wmts/v1_0/Actueel_orthoHR/EPSG:28992/{z}/{x}/{y}.png',
},
};
4 changes: 3 additions & 1 deletion src/components/Map/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ const LeaftletMap = ({
defaultCenter = DEFAULT_LAT_LNG,
defaultZoomLevel = DEFAULT_ZOOM,
disabled = false,
tileLayerUrl = TILE_LAYER_RD.url,
}) => {
const intl = useIntl();
const defaultCoordinates = useDefaultCoordinates();
Expand Down Expand Up @@ -99,7 +100,7 @@ const LeaftletMap = ({
duration: 3000,
}}
>
<TileLayer {...TILE_LAYER_RD} />
<TileLayer {...TILE_LAYER_RD} url={tileLayerUrl} />
{coordinates ? (
<>
<MapView coordinates={coordinates} />
Expand Down Expand Up @@ -133,6 +134,7 @@ LeaftletMap.propTypes = {
markerCoordinates: PropTypes.arrayOf(PropTypes.number),
onMarkerSet: PropTypes.func,
disabled: PropTypes.bool,
tileLayerUrl: PropTypes.string,
};

// Set the map view if coordinates are provided
Expand Down
34 changes: 34 additions & 0 deletions src/components/Summary/Summary.stories.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -496,3 +496,37 @@ export const AddressNLSummaryEmpty = {
await expect(canvas.getByRole('definition')).toHaveTextContent('');
},
};

export const MapSummary = {
render,
args: {
summaryData: [
{
slug: 'maps',
name: 'Maps',
data: [
{
name: 'Map with default tile layer',
value: [52.1326332, 5.291266],
component: {
key: 'map',
type: 'map',
label: 'Map with default tile layer',
},
},
{
name: 'Map with custom tile layer',
value: [52.1326332, 5.291266],
component: {
key: 'map',
type: 'map',
label: 'Map with custom tile layer',
tileLayerUrl:
'https://service.pdok.nl/hwh/luchtfotorgb/wmts/v1_0/Actueel_orthoHR/EPSG:28992/{z}/{x}/{y}.png',
},
},
],
},
],
},
};
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 {
onMarkerSet={this.onMarkerSet.bind(this)}
defaultCenter={defaultCenter}
defaultZoomLevel={zoom || DEFAULT_ZOOM}
tileLayerUrl={this.component.tileLayerUrl}
/>
</ConfigContext.Provider>
</IntlProvider>
Expand Down

0 comments on commit 0a335fa

Please sign in to comment.