mirror of
https://github.com/DOI-DO/j40-cejst-2.git
synced 2025-08-27 16:41:40 -07:00
Add Geolocation from behind feature flag
This commit is contained in:
parent
70cc0e392e
commit
e1f4df8e51
5 changed files with 124 additions and 67 deletions
|
@ -267,7 +267,7 @@ const AreaDetail = ({properties, hash}: IAreaDetailProps) => {
|
||||||
// description: intl.formatMessage(EXPLORE_COPY.SIDE_PANEL_INDICATOR_DESCRIPTION.MED_HOME_VAL),
|
// description: intl.formatMessage(EXPLORE_COPY.SIDE_PANEL_INDICATOR_DESCRIPTION.MED_HOME_VAL),
|
||||||
// value: properties[constants.MEDIAN_HOME_VALUE_PERCENTILE] ?
|
// value: properties[constants.MEDIAN_HOME_VALUE_PERCENTILE] ?
|
||||||
// properties[constants.MEDIAN_HOME_VALUE_PERCENTILE] : null,
|
// properties[constants.MEDIAN_HOME_VALUE_PERCENTILE] : null,
|
||||||
// isDisadvagtaged: false, // TODO
|
// isDisadvagtaged: false,
|
||||||
// };
|
// };
|
||||||
|
|
||||||
const proxHaz: indicatorInfo = {
|
const proxHaz: indicatorInfo = {
|
||||||
|
|
|
@ -1,24 +1,71 @@
|
||||||
@use '../styles/design-system.scss' as *;
|
@use '../styles/design-system.scss' as *;
|
||||||
@import "./utils.scss";
|
@import "./utils.scss";
|
||||||
|
|
||||||
.j40Popup {
|
|
||||||
width: 375px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.navigationControl {
|
.j40Map {
|
||||||
left: .75em;
|
@include at-media-max("desktop") {
|
||||||
top: units(15);
|
// < 1024
|
||||||
// width: 2.5em;
|
height: 55vh;
|
||||||
}
|
}
|
||||||
|
|
||||||
.fullscreenControl {
|
.mapHeaderRow{
|
||||||
right: 1.25em;
|
@include u-display("flex");
|
||||||
top: 2.5em;
|
@include u-padding-left(1.5);
|
||||||
}
|
|
||||||
|
justify-content: space-between;
|
||||||
|
|
||||||
|
/*
|
||||||
|
This width is set to prevent this row from
|
||||||
|
overflowing. Using justify-content: space-between
|
||||||
|
will allow the geolocation button to be right
|
||||||
|
ajusted. Without the width property constraint
|
||||||
|
of 98%, the space-between property forces the
|
||||||
|
geolocation icon out of the parent container.
|
||||||
|
|
||||||
|
Since the geolocation control is absolutely
|
||||||
|
positioned, attempts were made to set the
|
||||||
|
parent to be relative to avoid this, however
|
||||||
|
it seems that we haven't found a cleaner
|
||||||
|
solution (yet).
|
||||||
|
*/
|
||||||
|
width: 98%;
|
||||||
|
|
||||||
|
|
||||||
|
.geolocateBox {
|
||||||
|
@include u-margin-top(3);
|
||||||
|
|
||||||
|
.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);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.navigationControl {
|
||||||
|
left: .75em;
|
||||||
|
top: units(15);
|
||||||
|
}
|
||||||
|
|
||||||
|
//These classes are behind feature flags:
|
||||||
|
.fullscreenControl {
|
||||||
|
right: 1.25em;
|
||||||
|
top: 2.5em;
|
||||||
|
}
|
||||||
|
.j40Popup {
|
||||||
|
width: 375px;
|
||||||
|
}
|
||||||
|
|
||||||
.geolocateControl {
|
|
||||||
right: 1.25em;
|
|
||||||
top: 5em;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.mapInfoPanel {
|
.mapInfoPanel {
|
||||||
|
@ -26,11 +73,3 @@
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
height: 90vh;
|
height: 90vh;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This will control the height of the map when the device
|
|
||||||
// width is less than desktop (1024px)
|
|
||||||
.j40Map {
|
|
||||||
@include at-media-max("desktop") {
|
|
||||||
height: 55vh;
|
|
||||||
}
|
|
||||||
}
|
|
25
client/src/components/J40Map.module.scss.d.ts
vendored
25
client/src/components/J40Map.module.scss.d.ts
vendored
|
@ -1,14 +1,23 @@
|
||||||
declare namespace J40MapModuleScssNamespace {
|
declare namespace J40MapModuleScssNamespace {
|
||||||
export interface IJ40MapModuleScss {
|
export interface IJ40MapModuleScss {
|
||||||
j40Popup: string;
|
// main J40 map style
|
||||||
territoryFocusButton: string;
|
|
||||||
territoryFocusContainer: string;
|
|
||||||
navigationControl: string;
|
|
||||||
fullscreenControl: string;
|
|
||||||
geolocateControl: string;
|
|
||||||
detailView: string;
|
|
||||||
mapInfoPanel: string;
|
|
||||||
j40Map: string;
|
j40Map: string;
|
||||||
|
|
||||||
|
// map header row
|
||||||
|
mapHeaderRow: string;
|
||||||
|
geolocateBox: string;
|
||||||
|
geolocateMessage: string;
|
||||||
|
geolocateMessageHide: string;
|
||||||
|
geolocateIcon: string;
|
||||||
|
|
||||||
|
// nav control
|
||||||
|
navigationControl: string;
|
||||||
|
|
||||||
|
// feature flags
|
||||||
|
fullscreenControl: string;
|
||||||
|
j40Popup: string;
|
||||||
|
|
||||||
|
mapInfoPanel: string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,12 @@ export const featureURLForTilesetName = (tilesetName: string): string => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This the main map component
|
||||||
|
*
|
||||||
|
* @param {IJ40Interface} location
|
||||||
|
* @returns {ReactElement}
|
||||||
|
*/
|
||||||
const J40Map = ({location}: IJ40Interface) => {
|
const J40Map = ({location}: IJ40Interface) => {
|
||||||
/**
|
/**
|
||||||
* Initializes the zoom, and the map's center point (lat, lng) via the URL hash #{z}/{lat}/{long}
|
* Initializes the zoom, and the map's center point (lat, lng) via the URL hash #{z}/{lat}/{long}
|
||||||
|
@ -329,12 +334,12 @@ const J40Map = ({location}: IJ40Interface) => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Grid desktop={{col: 9}} className={styles.j40Map}>
|
<Grid desktop={{col: 9}} className={styles.j40Map}>
|
||||||
|
|
||||||
{/**
|
{/**
|
||||||
* This will render the MapSearch component
|
|
||||||
*
|
|
||||||
* Note:
|
* Note:
|
||||||
* The MapSearch component is no longer wrapped in a div in order to allow this feature
|
* The MapSearch component is no longer used in this location. It has been moved inside the
|
||||||
|
* <ReactMapGL> component itself.
|
||||||
|
*
|
||||||
|
* It was originally wrapped in a div in order to allow this feature
|
||||||
* to be behind a feature flag. This was causing a bug for MapSearch to render
|
* to be behind a feature flag. This was causing a bug for MapSearch to render
|
||||||
* correctly in a production build. Leaving this comment here in case future flags are
|
* correctly in a production build. Leaving this comment here in case future flags are
|
||||||
* needed in this component.
|
* needed in this component.
|
||||||
|
@ -346,9 +351,10 @@ const J40Map = ({location}: IJ40Interface) => {
|
||||||
* - npm run clean && npm run build && npm run serve
|
* - npm run clean && npm run build && npm run serve
|
||||||
*
|
*
|
||||||
* to ensure the production build works and that MapSearch and the map (ReactMapGL) render correctly.
|
* to ensure the production build works and that MapSearch and the map (ReactMapGL) render correctly.
|
||||||
|
*
|
||||||
|
* Any component declrations outside the <ReactMapGL> component may be susceptible to this bug.
|
||||||
*/}
|
*/}
|
||||||
<MapSearch goToPlace={goToPlace}/>
|
{/* <MapSearch goToPlace={goToPlace}/> */}
|
||||||
|
|
||||||
|
|
||||||
{/**
|
{/**
|
||||||
* The ReactMapGL component's props are grouped by the API's documentation. The component also has
|
* The ReactMapGL component's props are grouped by the API's documentation. The component also has
|
||||||
|
@ -393,7 +399,9 @@ const J40Map = ({location}: IJ40Interface) => {
|
||||||
data-cy={'reactMapGL'}
|
data-cy={'reactMapGL'}
|
||||||
>
|
>
|
||||||
{/**
|
{/**
|
||||||
* The low zoom source
|
* Load all data sources and layers
|
||||||
|
*
|
||||||
|
* First the low zoom:
|
||||||
*/}
|
*/}
|
||||||
<Source
|
<Source
|
||||||
id={constants.LOW_ZOOM_SOURCE_NAME}
|
id={constants.LOW_ZOOM_SOURCE_NAME}
|
||||||
|
@ -483,25 +491,34 @@ const J40Map = ({location}: IJ40Interface) => {
|
||||||
/>
|
/>
|
||||||
</Source>
|
</Source>
|
||||||
|
|
||||||
{/* This will add the navigation controls of the zoom in and zoom out buttons */}
|
{/* This is the first overlayed row on the map: Search and Geolocation */}
|
||||||
|
<div className={styles.mapHeaderRow}>
|
||||||
|
<MapSearch goToPlace={goToPlace}/>
|
||||||
|
|
||||||
|
<div className={styles.geolocateBox}>
|
||||||
|
<div className={styles.geolocateIcon}>
|
||||||
|
<GeolocateControl
|
||||||
|
positionOptions={{enableHighAccuracy: true}}
|
||||||
|
onGeolocate={onGeolocate}
|
||||||
|
onClick={onClickGeolocate}
|
||||||
|
trackUserLocation={true}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* This is the second row overlayed on the map, it will add the navigation controls
|
||||||
|
of the zoom in and zoom out buttons */}
|
||||||
{ windowWidth > constants.USWDS_BREAKPOINTS.MOBILE_LG && <NavigationControl
|
{ windowWidth > constants.USWDS_BREAKPOINTS.MOBILE_LG && <NavigationControl
|
||||||
showCompass={false}
|
showCompass={false}
|
||||||
className={styles.navigationControl}
|
className={styles.navigationControl}
|
||||||
/> }
|
/> }
|
||||||
|
|
||||||
{/* This will show shortcut buttons to pan/zoom to US territories */}
|
{/* This is the third row overlayed on the map, it will show shortcut buttons to
|
||||||
|
pan/zoom to US territories */}
|
||||||
<TerritoryFocusControl onClick={onClick}/>
|
<TerritoryFocusControl onClick={onClick}/>
|
||||||
|
|
||||||
{/* This places Geolocation behind a feature flag */}
|
|
||||||
{'gl' in flags ? <GeolocateControl
|
|
||||||
className={styles.geolocateControl}
|
|
||||||
positionOptions={{enableHighAccuracy: true}}
|
|
||||||
onGeolocate={onGeolocate}
|
|
||||||
// @ts-ignore
|
|
||||||
onClick={onClickGeolocate}
|
|
||||||
/> : ''}
|
|
||||||
{geolocationInProgress ? <div>Geolocation in progress...</div> : ''}
|
|
||||||
|
|
||||||
{/* Enable fullscreen pop-up behind a feature flag */}
|
{/* Enable fullscreen pop-up behind a feature flag */}
|
||||||
{('fs' in flags && detailViewData && !transitionInProgress) && (
|
{('fs' in flags && detailViewData && !transitionInProgress) && (
|
||||||
<Popup
|
<Popup
|
||||||
|
|
|
@ -1,20 +1,12 @@
|
||||||
@use '../../styles/design-system.scss' as *;
|
@use '../../styles/design-system.scss' as *;
|
||||||
|
|
||||||
.mapSearchContainer {
|
.mapSearchContainer {
|
||||||
|
/*
|
||||||
// styles for mobile-lg (480px) and greater widths,
|
The width of the container is being limited so that
|
||||||
@include at-media('mobile-lg') {
|
as the device width decreases, the geolocation
|
||||||
position: absolute;
|
button has enough space between the Search
|
||||||
// top: units(4);
|
component
|
||||||
left: units(1.5);
|
*/
|
||||||
width: 50%;
|
width: 71%;
|
||||||
z-index: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// styles for less than mobile-lg (480px)
|
|
||||||
position: absolute;
|
|
||||||
left: units(1.5);
|
|
||||||
width: 90%;
|
|
||||||
z-index: 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue