Skip to content

Commit 92ee6d9

Browse files
authored
Merge pull request #1165 from jboolean/location-picker-dots
Location map layer improvements
2 parents 8917bda + e43022c commit 92ee6d9

File tree

2 files changed

+34
-5
lines changed

2 files changed

+34
-5
lines changed

frontend/src/screens/App/screens/Corrections/components/LocationPickerModal.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ import useCorrectionsStore, {
88

99
import FourtiesModal from 'shared/components/Modal';
1010

11+
import {
12+
installLayers,
13+
setOverlay,
14+
} from '../../MapPane/components/MainMap/overlays';
1115
import stylesheet from './LocationPickerModal.less';
1216

1317
const MAPBOX_STYLE = __DEV__
@@ -25,19 +29,22 @@ export default function LocationPickerModal(): JSX.Element {
2529
correctedLng,
2630
correctedLat,
2731
setCorrectedLngLat,
32+
photo,
2833
} = useCorrectionsStore(
2934
({
3035
isMapOpen,
3136
closeMap,
3237
correctedLng,
3338
correctedLat,
3439
setCorrectedLngLat,
40+
photo,
3541
}) => ({
3642
isMapOpen,
3743
closeMap,
3844
correctedLng,
3945
correctedLat,
4046
setCorrectedLngLat,
47+
photo,
4148
})
4249
);
4350
const { previousLng, previousLat } = useCorrectionsStoreComputeds();
@@ -60,11 +67,19 @@ export default function LocationPickerModal(): JSX.Element {
6067
});
6168

6269
map.current.on('style.load', () => {
63-
map.current.removeLayer('photos-1940s');
70+
// map.current.removeLayer('photos-1940s');
71+
map.current.setFilter('photos-1940s', [
72+
'!=',
73+
['get', 'photoIdentifier'],
74+
photo.identifier || null,
75+
]);
6476
map.current.removeLayer('photos-1940s-wide-zoom');
65-
map.current.setLayoutProperty('lot-label', 'visibility', 'visible');
6677

6778
map.current.addControl(new mapboxgl.NavigationControl(), 'top-right');
79+
installLayers(map.current, 'photos-1940s', {
80+
fadeOverlays: false,
81+
});
82+
setOverlay(map.current, ['default-map', 'bbl-label']);
6883
});
6984

7085
map.current.on('moveend', () => {

frontend/src/screens/App/screens/MapPane/components/MainMap/overlays.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import { bboxPolygon, booleanIntersects } from '@turf/turf';
44
import { Feature } from 'geojson';
5+
import compact from 'lodash/compact';
6+
import flatMap from 'lodash/flatMap';
57
import boroughBoundaries from './Borough Boundaries simplified.json';
68

79
const LAYER_IDS = [
@@ -12,6 +14,8 @@ const LAYER_IDS = [
1214
'atlas-1930',
1315
'atlas-1956',
1416
'nyc-label',
17+
'lot-label',
18+
'block-label',
1519
] as const;
1620

1721
type LayerId = typeof LAYER_IDS[number];
@@ -23,7 +27,8 @@ export type OverlayId =
2327
| 'district'
2428
| 'atlas-1916'
2529
| 'atlas-1930'
26-
| 'atlas-1956';
30+
| 'atlas-1956'
31+
| 'bbl-label';
2732

2833
const MANHATTAN_BOUNDS_GEOJSON = boroughBoundaries.features.find(
2934
(feature) => feature.properties['boro_name'] === 'Manhattan'
@@ -55,6 +60,7 @@ const overlaysToLayers: { [overlay in OverlayId]: LayerId[] } = {
5560
'atlas-1916': ['atlas-1916'],
5661
'atlas-1930': ['atlas-1930'],
5762
'atlas-1956': ['atlas-1956'],
63+
'bbl-label': ['block-label', 'lot-label'],
5864
};
5965

6066
const NYC_ATTRIBUTION =
@@ -155,9 +161,17 @@ export const installLayers = (
155161

156162
export const setOverlay = (
157163
map: mapboxgl.Map,
158-
overlayId: OverlayId | null
164+
overlayId: OverlayId | null | OverlayId[]
159165
): void => {
160-
const visibleLayers = overlayId ? overlaysToLayers[overlayId] : [];
166+
// If overlayId is not an arary, convert it to an array
167+
const overlayIds: OverlayId[] = compact(
168+
Array.isArray(overlayId) ? overlayId : [overlayId]
169+
);
170+
171+
const visibleLayers = flatMap(
172+
overlayIds,
173+
(overlayId) => overlaysToLayers[overlayId]
174+
);
161175
const mapBounds = map.getBounds();
162176

163177
// Convert the map bounds into a Turf polygon

0 commit comments

Comments
 (0)