From beac44ef20b8f6b3367f08cc9baa2947d758164a Mon Sep 17 00:00:00 2001 From: Nat Hillard <72811320+NatHillardUSDS@users.noreply.github.com> Date: Thu, 1 Jul 2021 12:57:59 -0400 Subject: [PATCH] Various map styling fixes (#278) Addresses #182, #291, #273 and #191 In particular: * Removes zoom fading for now * adds legend * Styles mapbox popup correctly * Styles zoom control * Adds feature borders at higher zoom levels --- client/src/components/MapLegend.tsx | 19 ---- client/src/components/mapLegend.module.scss | 41 ++++++++ .../src/components/mapLegend.module.scss.d.ts | 19 ++++ client/src/components/mapLegend.tsx | 26 +++++ client/src/components/mapWrapper.tsx | 2 - client/src/components/mapboxMap.module.scss | 25 +---- .../src/components/mapboxMap.module.scss.d.ts | 1 - client/src/components/mapboxMap.tsx | 18 ++-- client/src/components/openlayersMap.tsx | 4 +- ...odule.scss => openlayersPopup.module.scss} | 0 ....d.ts => openlayersPopup.module.scss.d.ts} | 0 .../{mapPopup.tsx => openlayersPopup.tsx} | 8 +- .../src/components/popupContent.module.scss | 16 +++ .../components/popupContent.module.scss.d.ts | 15 +++ client/src/components/popupContent.tsx | 52 +++++----- client/src/components/zoomWarning.module.scss | 4 +- client/src/data/constants.tsx | 23 ++++- client/src/data/mapStyle.tsx | 99 +++++++------------ client/src/pages/cejst.tsx | 7 +- client/src/styles/global.scss | 44 +++------ 20 files changed, 236 insertions(+), 187 deletions(-) delete mode 100644 client/src/components/MapLegend.tsx create mode 100644 client/src/components/mapLegend.module.scss create mode 100644 client/src/components/mapLegend.module.scss.d.ts create mode 100644 client/src/components/mapLegend.tsx rename client/src/components/{mapPopup.module.scss => openlayersPopup.module.scss} (100%) rename client/src/components/{mapPopup.module.scss.d.ts => openlayersPopup.module.scss.d.ts} (100%) rename client/src/components/{mapPopup.tsx => openlayersPopup.tsx} (88%) create mode 100644 client/src/components/popupContent.module.scss create mode 100644 client/src/components/popupContent.module.scss.d.ts diff --git a/client/src/components/MapLegend.tsx b/client/src/components/MapLegend.tsx deleted file mode 100644 index af22b225..00000000 --- a/client/src/components/MapLegend.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import React from 'react'; - -const MapLegend = () => { - return ( - <> -
Current Score Property: {constants.SCORE_PROPERTY}
); }; diff --git a/client/src/components/mapboxMap.module.scss b/client/src/components/mapboxMap.module.scss index f1681ae9..e423ba90 100644 --- a/client/src/components/mapboxMap.module.scss +++ b/client/src/components/mapboxMap.module.scss @@ -3,31 +3,12 @@ $sidebar-color: #ffffff; .mapContainer { height: 676px; - margin-bottom: 29px; - max-width: revert; - margin-top: 50px; -} - -.sidebar { - background-color: $sidebar-background; - color: $sidebar-color; - padding: 6px 12px; - font-family: monospace; - z-index: 1; - position: absolute; - top: 300px; - left: 0; - margin: 12px; - border-radius: 4px; } .j40Popup { max-height: 300px; - max-width: 300px; - overflow: scroll; + min-width: 36%; + max-width: 36%; + overflow-y: scroll; pointer-events: all !important; } - -.j40Popup .mapboxgl-popup-content { - pointer-events: all; -} diff --git a/client/src/components/mapboxMap.module.scss.d.ts b/client/src/components/mapboxMap.module.scss.d.ts index ad779b56..15389f65 100644 --- a/client/src/components/mapboxMap.module.scss.d.ts +++ b/client/src/components/mapboxMap.module.scss.d.ts @@ -1,6 +1,5 @@ declare namespace MapboxMapModuleScssNamespace { export interface IMapboxMapModuleScss { - sidebar: string; mapContainer: string; j40Popup: string; } diff --git a/client/src/components/mapboxMap.tsx b/client/src/components/mapboxMap.tsx index 9a6f77da..eb17cb65 100644 --- a/client/src/components/mapboxMap.tsx +++ b/client/src/components/mapboxMap.tsx @@ -9,10 +9,10 @@ import {LngLatBoundsLike, import mapStyle from '../data/mapStyle'; import ZoomWarning from './zoomWarning'; import PopupContent from './popupContent'; -import * as styles from './mapboxMap.module.scss'; import * as constants from '../data/constants'; import ReactDOM from 'react-dom'; import 'mapbox-gl/dist/mapbox-gl.css'; +import * as styles from './mapboxMap.module.scss'; type ClickEvent = mapboxgl.MapMouseEvent & mapboxgl.EventData; @@ -34,8 +34,14 @@ const MapboxMap = () => { maxZoom: constants.GLOBAL_MAX_ZOOM, maxBounds: constants.GLOBAL_MAX_BOUNDS as LngLatBoundsLike, }); + // disable map rotation using right click + drag + initialMap.dragRotate.disable(); + + // disable map rotation using touch rotation gesture + initialMap.touchZoomRotate.disableRotation(); + initialMap.on('click', handleClick); - initialMap.addControl(new NavigationControl()); + initialMap.addControl(new NavigationControl({showCompass: false}), 'top-left'); map.current = initialMap; }); @@ -43,7 +49,7 @@ const MapboxMap = () => { const map = e.target; const clickedCoord = e.point; const features = map.queryRenderedFeatures(clickedCoord, { - layers: ['score-low'], + layers: ['score'], }); if (features.length && features[0].properties) { @@ -52,11 +58,11 @@ const MapboxMap = () => { const options : PopupOptions = { offset: [0, 0], className: styles.j40Popup, + focusAfterOpen: false, }; new Popup(options) .setLngLat(e.lngLat) .setDOMContent(placeholder) - .setMaxWidth('300px') .addTo(map); } }; @@ -66,10 +72,10 @@ const MapboxMap = () => { map.current.on('move', () => { setZoom(map.current.getZoom()); }); - map.current.on('mouseenter', 'score-low', () => { + map.current.on('mouseenter', 'score', () => { map.current.getCanvas().style.cursor = 'pointer'; }); - map.current.on('mouseleave', 'score-low', () => { + map.current.on('mouseleave', 'score', () => { map.current.getCanvas().style.cursor = ''; }); }); diff --git a/client/src/components/openlayersMap.tsx b/client/src/components/openlayersMap.tsx index cfb44cba..19dd21de 100644 --- a/client/src/components/openlayersMap.tsx +++ b/client/src/components/openlayersMap.tsx @@ -10,7 +10,7 @@ import {Coordinate} from 'ol/coordinate'; import olms from 'ol-mapbox-style'; import mapStyle from '../data/mapStyle'; import ZoomWarning from './zoomWarning'; -import MapPopup from './mapPopup'; +import OpenlayersPopup from './openlayersPopup'; import {transformExtent} from 'ol/src/proj'; import * as styles from './openlayersMap.module.scss'; import * as constants from '../data/constants'; @@ -121,7 +121,7 @@ const MapWrapper = ({features}: IMapWrapperProps) => { <>Census Block Group: | -{blockGroup} | -
Just Progress Categorization: | -{getCategorization(score)} | -
Cumulative Index Score: | -{readablePercent(score)} | -
Indicator | -Percentile(0-100) | +INDICATOR | +VALUE |
---|