Skip to content

Commit

Permalink
Added import for PinWaterActive icon
Browse files Browse the repository at this point in the history
Conditionally render PinWaterActive for WATER resources at selected location
Updated icon source based on resource type and coordinates match
Used fallback to default marker icon if no match
  • Loading branch information
icycoldveins committed Jan 25, 2025
1 parent 6aaa1c8 commit 8ef3fe1
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/components/ReactGoogleMaps/ReactGoogleMaps.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import phlaskMarkerIconV2 from '../icons/PhlaskMarkerIconV2';
import selectFilteredResource from '../../selectors/waterSelectors';
import useIsMobile from 'hooks/useIsMobile';
import { CITY_HALL_COORDINATES } from 'constants/defaults';
import PinWaterActive from '../icons/PinWaterActive.svg';

function getCoordinates() {
return new Promise(function (resolve, reject) {
Expand Down Expand Up @@ -154,6 +155,7 @@ export const ReactGoogleMaps = ({ google }) => {
const isMobile = useIsMobile();
const allResources = useSelector(state => state.filterMarkers.allResources);
const filteredResources = useSelector(state => selectFilteredResource(state));
const selectedPlace = useSelector(state => state.filterMarkers.selectedPlace);

const mapCenter = useSelector(state => state.filterMarkers.mapCenter);
const resourceType = useSelector(state => state.filterMarkers.resourceType);
Expand Down Expand Up @@ -311,9 +313,13 @@ export const ReactGoogleMaps = ({ google }) => {
lat: resource.latitude,
lng: resource.longitude
}}
icon={{
url: phlaskMarkerIconV2(resource.resource_type, 56, 56)
}}
icon={
resource.resource_type === 'WATER' &&
selectedPlace?.latitude === resource.latitude &&
selectedPlace?.longitude === resource.longitude
? { url: PinWaterActive }
: phlaskMarkerIconV2(resource.resource_type, 56, 56)
}
// This is used for marker targeting as we are unable to add custom properties with this library.
// We should eventually replace this so that we can still enable the use of screen readers in the future.
title={`data-cy-${index}`}
Expand Down

0 comments on commit 8ef3fe1

Please sign in to comment.