Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom map backgrounds #747

Merged
merged 4 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
return <EmptyDisplay />;
}

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

Check warning on line 192 in src/components/FormStepSummary/ComponentValueDisplay.jsx

View check run for this annotation

Codecov / codecov/patch

src/components/FormStepSummary/ComponentValueDisplay.jsx#L192

Added line #L192 was not covered by tests
};

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
Loading