Skip to content

Commit 59dd6bb

Browse files
committed
fix feed page point icons and deduplicate pointToLayer logic
1 parent 2ca488c commit 59dd6bb

5 files changed

Lines changed: 18 additions & 8 deletions

File tree

works/static/js/map-search.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,10 +400,8 @@ class MapSearchManager {
400400
const styleFn = (typeof publicationStyle === 'function') ? publicationStyle : () => ({});
401401

402402
// Create a new layer with the filtered publications, preserving the original symbology.
403-
// pointToLayer is required so that GeoJSON Point features become CircleMarkers
404-
// (matching the original layer) rather than falling back to default blue pin markers.
405403
this.filteredLayer = L.geoJSON(filteredGeoJSON, {
406-
pointToLayer: (feature, latlng) => L.circleMarker(latlng, Object.assign({ radius: 6 }, styleFn(feature))),
404+
pointToLayer: (feature, latlng) => publicationPointToLayer(feature, latlng, styleFn),
407405
style: styleFn,
408406
onEachFeature: popupFunc
409407
});

works/static/js/map-status-layers.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,10 @@
5151
// (interaction, keyboard, search). Not added to the map directly — its
5252
// children are routed to the two FeatureGroups, which ARE on the map.
5353
this.allLayer = L.geoJSON(features, {
54-
// Render GeoJSON Points as circleMarkers (same as the work landing page)
55-
// instead of the default pin-marker. The style function is not called for
56-
// layers created by pointToLayer, so we compute the style here directly.
5754
pointToLayer: (feature, latlng) => {
5855
const base = styleFn ? styleFn(feature) : {};
5956
const style = isUnpublished(feature) ? unpublishedStyle(base) : base;
60-
return L.circleMarker(latlng, Object.assign({ radius: 6 }, style));
57+
return publicationPointToLayer(feature, latlng, () => style);
6158
},
6259
style: (feature) => {
6360
const base = styleFn ? styleFn(feature) : {};

works/static/js/map-styles.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,17 @@ const OPTIMAP_MAP_STYLES = {
2727
function publicationStyle(/* feature */) {
2828
return OPTIMAP_MAP_STYLES.default;
2929
}
30+
31+
/**
32+
* Shared pointToLayer for L.geoJSON — renders GeoJSON Point features as
33+
* circleMarkers so they match the styled polygon/line symbology instead of
34+
* falling back to Leaflet's default blue-pin marker.
35+
* @param {Object} feature - GeoJSON feature
36+
* @param {L.LatLng} latlng
37+
* @param {Function} [styleFn] - Optional override; defaults to publicationStyle.
38+
* @returns {L.CircleMarker}
39+
*/
40+
function publicationPointToLayer(feature, latlng, styleFn) {
41+
const style = (styleFn || publicationStyle)(feature);
42+
return L.circleMarker(latlng, Object.assign({ radius: 6 }, style));
43+
}

works/templates/feed_page.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ <h3>About this feed</h3>
174174
// Add publications to map using shared popup function (displayed above region layer)
175175
const publicationsLayer = L.geoJSON(publicationsData, {
176176
style: publicationStyle,
177+
pointToLayer: publicationPointToLayer,
177178
onEachFeature: publicationPopup
178179
}).addTo(map);
179180

works/templates/work_landing_page.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ <h5 class="mb-0">
598598
if (publicationFeature) {
599599
layer = L.geoJSON(publicationFeature, {
600600
style: publicationStyle,
601-
pointToLayer: (feat, latlng) => L.circleMarker(latlng, Object.assign({ radius: 6 }, publicationStyle(feat)))
601+
pointToLayer: publicationPointToLayer
602602
});
603603
featureGroup.addLayer(layer);
604604

0 commit comments

Comments
 (0)