Conversation
makes the minimum line width 3 and remove some unnecessary steps
GeoWill
left a comment
There was a problem hiding this comment.
I haven't run this locally, but I found the screencast extremely useful! I would mostly be checking that the popups open and close as I would expect, and it works nicely on constituencies and regions (i.e. there's no accidental sharing of feature data between the maps or some such).
There's a few comments on the code.
Regarding showing the postcode in the popup I think that's a nice to have rather than needed.
| "source-layer": `${newDivisionsetID}_${change.division_type}`, | ||
| "paint": { | ||
| "fill-color": "#E6007C", | ||
| "fill-opacity": ShowNewBoundaryFill ? 0.2 : 0 |
There was a problem hiding this comment.
I'm assuming this is done to make the popups work I.e. we need a transparent fill.
If this is the case, I don't think this needs to be a conditional. It looks like ShowNewBoundaryFill is set to true, then not used, then set to false and evaluated here. Shouldn't we just bin it, and set opacity to 0?
If I've missed something and we do need ShowNewBoundaryFill, can it be camel case: showNewBoundaryFill.
There was a problem hiding this comment.
This is so the fill appears when when we're only showing the new boundaries (e.g. no change, or all Welsh postcodes), but is transparent when the old boundaries are also on the map.
There was a problem hiding this comment.
Got it.
In that case I think it might actually be clearer to make this:
"fill-opacity": !showOldBoundary ? 0.2 : 0There was a problem hiding this comment.
That makes more sense. Have changed it in 0b33dac
| return { | ||
| name: feature.properties.division__name || "Name Missing", | ||
| layerColor: feature.layer.paint['fill-color'] || feature.layer.paint['line-color'], | ||
| isNew: feature.source.startsWith("new") ? true : false |
There was a problem hiding this comment.
startsWith returns a bool, so I don't think you need the ternary (? true : false)
| <div style="color: ${feat.layerColor};"> | ||
| ${feat.isNew ? "New" : "Old"}: <strong style="color: ${feat.layerColor};">${feat.name}</strong> | ||
| </div> | ||
| `).join(''); |
There was a problem hiding this comment.
I know we control the pmtiles, but I think it's probably better here not to just chuck the colour and name strings into the html without sanitizing it. This is more so that we don't go and copy and paste it somewhere else when we shouldn't, rather than it being a massive concern here. It's also confusing because there's a js built in setHTML which does sanitize input, while maplibre popup setHTML doesn't...
I think if you build the popup up out of dom elements, and then use setDOMContent, it will avoid the issue.
const popupContent = document.createElement('div');
featsData.forEach(feat => {
const featContainer = document.createElement('div');
featContainer.style.color = feat.layerColor;
const label = document.createTextNode(feat.isNew ? "New: " : "Old: ");
const strong = document.createElement('strong');
strong.style.color = feat.layerColor;
strong.textContent = feat.name;
featContainer.appendChild(label);
featContainer.appendChild(strong);
popupContent.appendChild(row);
});
const popup = new maplibregl.Popup({ closeButton: true, closeOnClick: true })
.setLngLat(coords)
.setDOMContent(popupContent);
showPopup(popup);There was a problem hiding this comment.
Ah I had not thought about that. I've implemented the above in c8f59a7.
| let seen = new Set(); | ||
|
|
||
| for (const feat of feats) { | ||
| const featId = feat.properties.id |
There was a problem hiding this comment.
You don't use featId any more now.
| offset: 25, | ||
| }) | ||
| .setLngLat(postcodeLocation.geometry.coordinates) | ||
| .setText("Postcode Centroid"); |
There was a problem hiding this comment.
I assume the actual postcode is available in the context, so I'd lean to including it here rather than just poscode.
I just double-checked a few scottish postcodes and didn't find any accidental interactions between maps. popups acting normal as well. |
|
I've pushed ba5f123 to |
Turning this Mablibre popup option to But I don't if that has any accessibility implications? Happy to change the padding but wanted to see what you think. |
|
I'm not sure I'm afraid. |
Done in ac35c9a |
GeoWill
left a comment
There was a problem hiding this comment.
I reckon we're good to apply the fixups and deploy 👍


This PR makes some tweaks to the boundary change maps. It: