Skip to content

Conversation

@davidjamesstone
Copy link
Contributor

@davidjamesstone davidjamesstone commented Jan 8, 2026

Proposed change

Add map capability to the LatLong location field using defra-map

Jira ticket: https://eaflood.atlassian.net/browse/DF-680

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Misc. (documentation, build updates, etc)

Checklist

  • You have executed this code locally and it performs as expected.
  • You have added tests to verify your code works.
  • You have added code comments and JSDoc, where appropriate.
  • There is no commented-out code.
  • You have added developer docs in README.md and docs/* (where appropriate, e.g. new features).
  • The tests are passing (npm run test).
  • The linting checks are passing (npm run lint).
  • The code has been formatted (npm run format).

@davidjamesstone davidjamesstone marked this pull request as ready for review January 13, 2026 16:45
}

/**
* @param {MapConfiguration} options - the map options
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be helpful to add a one-line description of what each of these handlers do as not totally obvious why they are needed

function logErrorAndReturnEmpty(err, endpoint) {
const msg = `${getErrorMessage(err)} ${(Boom.isBoom(err) && err.data?.payload?.error?.message) ?? ''}`

logger.error(err, `Exception occured calling OS names ${endpoint} - ${msg}}`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to log these as errors, or just info?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are errors returned from OS api calls. They're unlikely to happen but if they do we should log as errors. This code matches the postcode lookup logging.

*/
export async function find(query, apiKey) {
const endpoint = 'find'
const url = `https://api.os.uk/search/names/v1/find?key=${apiKey}&query=${query}&fq=local_type:postcode%20local_type:hamlet%20local_type:village%20local_type:town%20local_type:city%20local_type:other_settlement&maxresults=8`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the list of types likely to need changing? How did you determine what to include?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These url's were supplied by Dan Leech from the defra-maps team. They come from here and here. They're unlikely to change so I didn't think it necessary to include them as envars

*/
export async function nearest(easting, northing, apiKey) {
const endpoint = 'nearest'
const url = `https://api.os.uk/search/names/v1/nearest?key=${apiKey}&point=${easting},${northing}&radius=1000&fq=local_type:Airfield%20local_type:Airport%20local_type:Bus_Station%20local_type:Chemical_Works%20local_type:City%20local_type:Coach_Station%20local_type:Electricity_Distribution%20local_type:Electricity_Production%20local_type:Further_Education%20local_type:Gas_Distribution_or_Storage%20local_type:Hamlet%20local_type:Harbour%20local_type:Helicopter_Station%20local_type:Heliport%20local_type:Higher_or_University_Education%20local_type:Hill_Or_Mountain%20local_type:Hospice%20local_type:Hospital%20local_type:Medical_Care_Accommodation%20local_type:Named_Road%20local_type:Non_State_Primary_Education%20local_type:Non_State_Secondary_Education%20local_type:Other_Settlement%20local_type:Passenger_Ferry_Terminal%20local_type:Port_Consisting_of_Docks_and_Nautical_Berthing%20local_type:Postcode%20local_type:Primary_Education%20local_type:Railway_Station%20local_type:Road_User_Services%20local_type:Secondary_Education%20local_type:Section_Of_Named_Road%20local_type:Section_Of_Numbered_Road%20local_type:Special_Needs_Education%20local_type:Suburban_Area%20local_type:Town%20local_type:Urban_Greenspace%20local_type:Vehicular_Ferry_Terminal%20local_type:Vehicular_Rail_Terminal%20local_type:Village%20local_type:Waterfall%20`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above, are the list of types likely to need changing? How did you determine what to include?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above

Copy link
Contributor

@jbarnsley10 jbarnsley10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks really good. Just a couple of very minor comments, and a question or to for my benefit. Approving in principal.

@davidjamesstone davidjamesstone changed the title feature/DF-680 location maps latlong feature/DF-680 location maps latlong, E&N and OSGR Jan 16, 2026
Comment on lines 73 to 79
VTS_OUTDOOR_URL:
'https://raw.githubusercontent.com/OrdnanceSurvey/OS-Vector-Tile-API-Stylesheets/main/OS_VTS_3857_Outdoor.json',
VTS_DARK_URL:
'https://raw.githubusercontent.com/OrdnanceSurvey/OS-Vector-Tile-API-Stylesheets/main/OS_VTS_3857_Dark.json',
VTS_BLACK_AND_WHITE_URL:
'https://raw.githubusercontent.com/OrdnanceSurvey/OS-Vector-Tile-API-Stylesheets/main/OS_VTS_3857_Black_and_White.json'
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should definitely pull these into our app, rather than hardcoding them to Ordnance Survey's github. Since this looks the main branch, if they restructure the repo/delete the files/etc it'll break our app.

I'd rather we downlod a copy and mirror them on our end, that way we can guarantee they'll always be there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've reverted this 9bae11a commit and will work on identifying any subsequent requests made to that domain.

Copy link
Contributor Author

@davidjamesstone davidjamesstone Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thumbnail: `${assetPath}/defra-map/assets/images/outdoor-map-thumb.jpg`,
logo: `${assetPath}/defra-map/assets/images/os-logo.svg`,
logoAltText,
attribution: `Contains OS data ${String.fromCodePoint(COMPANY_SYMBOL_CODE)} Crown copyright and database rights ${new Date().getFullYear()}`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is missing from dark/black-white

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved with 5324874

Comment on lines 493 to 500
zoom: '16',
center,
markers: [
{
id: 'location',
coords: center
}
]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

worth pulling these (except center) into a constant and reusing them between the different inputs? so we don't get any drift between the individual component's maps

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved with 88f2216 👍

Comment on lines 663 to 670
// Move the 'location' marker to the new point
map.addMarker('location', center)

// Pan & zoom the map to the new valid location
mapProvider.flyTo({
center,
zoom: 14,
essential: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could pull this out into a centerMap(center) and share it between the component handlers?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved with bd5918b

@alexluckett
Copy link
Contributor

This is great stuff, Dave 🚀

Only one major comment really (styles), everything else is fairly trivial.

@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants