Skip to content

Commit

Permalink
Update pin rendering logic
Browse files Browse the repository at this point in the history
  • Loading branch information
asanchezr committed Feb 11, 2024
1 parent 72e5f96 commit ebc986a
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const FilterContentContainer: React.FC<
> = ({ View }) => {
const mapMachine = useMapStateMachine();

const setVisiblePimsProperties = mapMachine.setVisiblePimsProperties;
const { setVisiblePimsProperties, setShowDisposed } = mapMachine;

const { getMatchingProperties } = usePimsPropertyRepository();

Expand All @@ -36,8 +36,9 @@ export const FilterContentContainer: React.FC<
const onChange = useCallback(
(model: PropertyFilterFormModel) => {
filterProperties(model.toApi());
setShowDisposed(model.isDisposed);
},
[filterProperties],
[filterProperties, setShowDisposed],
);

return <View onChange={onChange} isLoading={getMatchingProperties.loading} />;
Expand Down
31 changes: 31 additions & 0 deletions source/frontend/src/components/maps/leaflet/Layers/util.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,28 @@ export const otherInterestIconSelect = L.icon({
shadowSize: [41, 41],
});

// disposed icon (grey)
export const disposedIcon = L.icon({
iconUrl: require('@/assets/images/pins/disposed.png') ?? 'assets/images/pins/disposed.png',
shadowUrl: require('@/assets/images/pins/marker-shadow.png') ?? 'marker-shadow.png',
iconSize: [25, 41],
iconAnchor: [12, 41],
popupAnchor: [1, -34],
shadowSize: [41, 41],
});

// disposed icon (grey) highlighted
export const disposedIconSelect = L.icon({
iconUrl:
require('@/assets/images/pins/disposed-highlight.png') ??
'assets/images/pins/disposed-highlight.png',

Check warning on line 96 in source/frontend/src/components/maps/leaflet/Layers/util.tsx

View check run for this annotation

Codecov / codecov/patch

source/frontend/src/components/maps/leaflet/Layers/util.tsx#L96

Added line #L96 was not covered by tests
shadowUrl: require('@/assets/images/pins/marker-shadow.png') ?? 'marker-shadow.png',
iconSize: [25, 41],
iconAnchor: [12, 41],
popupAnchor: [1, -34],
shadowSize: [41, 41],
});

// not owned property icon (orange)
export const notOwnedPropertyIcon = L.icon({
iconUrl:
Expand Down Expand Up @@ -155,7 +177,16 @@ export function pointToLayer<P extends MarkerFeature, C extends Supercluster.Clu
export function getMarkerIcon(
feature: Supercluster.PointFeature<PIMS_Property_Location_View | PIMS_Property_Boundary_View>,
selected: boolean,
showDisposed: boolean = false,
): L.Icon<L.IconOptions> {
if (showDisposed && feature.properties.IS_DISPOSED) {
if (selected) {
return disposedIconSelect;
} else {
return disposedIcon;

Check warning on line 186 in source/frontend/src/components/maps/leaflet/Layers/util.tsx

View check run for this annotation

Codecov / codecov/patch

source/frontend/src/components/maps/leaflet/Layers/util.tsx#L183-L186

Added lines #L183 - L186 were not covered by tests
}
}

if (feature.properties.IS_PROPERTY_OF_INTEREST) {
if (selected) {
return propertyOfInterestIconSelect;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const SinglePropertyMarker: React.FC<React.PropsWithChildren<SinglePropertyMarke

const getIcon = () => {
if (isOwned) {
return getMarkerIcon(pointFeature, isSelected);
return getMarkerIcon(pointFeature, isSelected, mapMachine.showDisposed);
} else {
return getNotOwnerMarkerIcon(isSelected);
}
Expand Down
2 changes: 2 additions & 0 deletions source/frontend/src/mocks/mapFSM.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const mapMachineBaseMock: IMapStateMachineContext = {
isSelecting: false,
isFiltering: false,
isShowingMapLayers: false,
showDisposed: false,

requestFlyToLocation: jest.fn(),

Expand All @@ -56,4 +57,5 @@ export const mapMachineBaseMock: IMapStateMachineContext = {
toggleMapFilter: jest.fn(),

toggleMapLayer: jest.fn(),
setShowDisposed: jest.fn(),
};
3 changes: 3 additions & 0 deletions source/frontend/src/models/layers/pimsPropertyLocationView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export interface PIMS_Property_Location_View {
readonly IS_SENSITIVE: string | null;
readonly IS_OWNED: string | null;
readonly IS_PROPERTY_OF_INTEREST: string | null;
readonly IS_DISPOSED: string | null;
readonly IS_VISIBLE_TO_OTHER_AGENCIES: string | null;
readonly ZONING: string | null;
readonly ZONING_POTENTIAL: string | null;
Expand Down Expand Up @@ -74,6 +75,7 @@ export const EmptyPropertyLocation: PIMS_Property_Location_View = {
IS_SENSITIVE: null,
IS_OWNED: null,
IS_PROPERTY_OF_INTEREST: null,
IS_DISPOSED: null,
IS_VISIBLE_TO_OTHER_AGENCIES: null,
ZONING: null,
ZONING_POTENTIAL: null,
Expand Down Expand Up @@ -116,6 +118,7 @@ export interface PIMS_Property_Boundary_View {
readonly IS_SENSITIVE: string | null;
readonly IS_OWNED: string | null;
readonly IS_PROPERTY_OF_INTEREST: string | null;
readonly IS_DISPOSED: string | null;
readonly IS_VISIBLE_TO_OTHER_AGENCIES: string | null;
readonly ZONING: string | null;
readonly ZONING_POTENTIAL: string | null;
Expand Down

0 comments on commit ebc986a

Please sign in to comment.