diff --git a/client/src/components/J40Map.module.scss b/client/src/components/J40Map.module.scss index 0cc4e3cb..01827a3c 100644 --- a/client/src/components/J40Map.module.scss +++ b/client/src/components/J40Map.module.scss @@ -32,22 +32,32 @@ .geolocateBox { - @include u-margin-top(3); + margin-top: 6px; + + .geolocateMessage { + visibility: visible; + background-color: white; + margin-bottom: 3px; + } + .geolocateMessageHide { + visibility: hidden; + margin-bottom: 3px; + } + + @include at-media-max("tablet") { + // < 640 + margin-top: 28px; + } + + @media (max-width: 365px){ + margin-top: 46px; + + } .geolocateIcon{ align-self: flex-end; @include u-margin-right(4); - @include u-margin-top(.5); - @include at-media-max("tablet") { - // < 640 - @include u-margin-top(3); - } - - @media (max-width: 362px){ - @include u-margin-top(5); - - } } } } diff --git a/client/src/components/J40Map.tsx b/client/src/components/J40Map.tsx index 17480924..3009d139 100644 --- a/client/src/components/J40Map.tsx +++ b/client/src/components/J40Map.tsx @@ -13,6 +13,7 @@ import ReactMapGL, { FlyToInterpolator, FullscreenControl, MapRef, Source, Layer} from 'react-map-gl'; +import {useIntl} from 'gatsby-plugin-intl'; import bbox from '@turf/bbox'; import * as d3 from 'd3-ease'; import {isMobile} from 'react-device-detect'; @@ -34,6 +35,7 @@ import 'maplibre-gl/dist/maplibre-gl.css'; import * as constants from '../data/constants'; import * as styles from './J40Map.module.scss'; import * as COMMON_COPY from '../data/copy/common'; +import * as EXPLORE_COPY from '../data/copy/explore'; declare global { @@ -55,6 +57,11 @@ export interface IDetailViewInterface { properties: constants.J40Properties, }; +export const GEOLOCATION_STATES = { + OFF: 'OFF', + LOCATING: 'LOCATING', + LOCKED: 'LOCKED', +}; /** * This function will determine the URL for the map tiles. It will read in a string that will designate either * high or low tiles. It will allow to overide the URL to the pipeline staging tile URL via feature flag. @@ -130,12 +137,13 @@ const J40Map = ({location}: IJ40Interface) => { const [selectedFeature, setSelectedFeature] = useState(); const [detailViewData, setDetailViewData] = useState(); const [transitionInProgress, setTransitionInProgress] = useState(false); - const [geolocationInProgress, setGeolocationInProgress] = useState(false); + const [geolocationState, setGeolocationState] = useState(GEOLOCATION_STATES.OFF); const [isMobileMapState, setIsMobileMapState] = useState(false); const {width: windowWidth} = useWindowSize(); const mapRef = useRef(null); const flags = useFlags(); + const intl = useIntl(); const selectedFeatureId = (selectedFeature && selectedFeature.id) || ''; const filter = useMemo(() => ['in', constants.GEOID_PROPERTY, selectedFeatureId], [selectedFeature]); @@ -322,11 +330,17 @@ const J40Map = ({location}: IJ40Interface) => { }; const onGeolocate = () => { - setGeolocationInProgress(false); + setGeolocationState(GEOLOCATION_STATES.LOCKED); }; const onClickGeolocate = () => { - setGeolocationInProgress(true); + if (geolocationState === GEOLOCATION_STATES.LOCKED) { + setGeolocationState(GEOLOCATION_STATES.OFF); + } + + if (geolocationState === GEOLOCATION_STATES.OFF) { + setGeolocationState(GEOLOCATION_STATES.LOCATING); + } }; const mapBoxBaseLayer = 'tl' in flags ? `mapbox://styles/justice40/cl2qimpi2000014qeb1egpox8` : `mapbox://styles/mapbox/streets-v11`; @@ -495,6 +509,12 @@ const J40Map = ({location}: IJ40Interface) => {
+
+ {intl.formatMessage(EXPLORE_COPY.MAP.GEOLOC_MSG_LOCATING)} +