Skip to content

Commit 145f5e4

Browse files
committed
Add ScaleControl to various map components
- Integrated ScaleControl into ActivityMap, BoundsSelectorModal, InsetMap, SupplementalMap, TaskMap, TaskNearbyMap, and LeaderboardMap components for improved user navigation. - Updated styles in MapPane.scss to ensure proper positioning of the ScaleControl. - Removed redundant ScaleControl styles from TaskClusterMap.scss. This enhancement provides users with a clearer understanding of the map scale across different views.
1 parent f6241e5 commit 145f5e4

11 files changed

Lines changed: 24 additions & 10 deletions

File tree

src/components/ActivityMap/ActivityMap.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import _map from "lodash/map";
77
import PropTypes from "prop-types";
88
import { useEffect, useState } from "react";
99
import { FormattedMessage, injectIntl } from "react-intl";
10-
import { AttributionControl, CircleMarker, MapContainer, Popup, useMap } from "react-leaflet";
10+
import { AttributionControl, CircleMarker, MapContainer, Popup, ScaleControl, useMap } from "react-leaflet";
1111
import { GLOBAL_MAPBOUNDS, toLatLngBounds } from "../../services/MapBounds/MapBounds";
1212
import { TaskStatusColors } from "../../services/Task/TaskStatus/TaskStatus";
1313
import { buildLayerSources } from "../../services/VisibleLayer/LayerSources";
@@ -120,6 +120,7 @@ export const ActivityMap = (props) => {
120120
/>
121121
<ResizeMap />
122122
<AttributionControl position="bottomleft" prefix={false} />
123+
<ScaleControl position="bottomleft" />
123124
<VisibleTileLayer {...props} zIndex={1} noWrap bounds={toLatLngBounds(GLOBAL_MAPBOUNDS)} />
124125
{overlayLayers}
125126
{coloredMarkers}

src/components/BoundsSelectorModal/BoundsSelectorModal.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import classNames from "classnames";
33
import _split from "lodash/split";
44
import { Component, Fragment } from "react";
55
import { FormattedMessage } from "react-intl";
6-
import { AttributionControl, MapContainer } from "react-leaflet";
6+
import { AttributionControl, MapContainer, ScaleControl } from "react-leaflet";
77
import { fromLatLngBounds, toLatLngBounds } from "../../services/MapBounds/MapBounds";
88
import { DEFAULT_MAP_BOUNDS } from "../../services/MapBounds/MapBounds";
99
import { defaultLayerSource } from "../../services/VisibleLayer/LayerSources";
@@ -103,6 +103,7 @@ export default class BoundsSelectorModal extends Component {
103103
fitBoundsControl
104104
/>
105105
<AttributionControl position="bottomleft" prefix={false} />
106+
<ScaleControl position="bottomleft" />
106107
<SourcedTileLayer source={defaultLayerSource()} skipAttribution={true} />
107108
<AreaSelect
108109
bounds={boundingBox}

src/components/EnhancedMap/MapPane/MapPane.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@
106106
color: $grey;
107107
}
108108
}
109+
110+
.leaflet-control-scale.leaflet-control {
111+
top: 0;
112+
box-shadow: none;
113+
}
109114
}
110115
}
111116

src/components/EnhancedMap/SourcedTileLayer/SourcedTileLayer.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import TileLayerErrorBoundary from "../../TaskClusterMap/TileLayerErrorBoundary"
2222
*
2323
* @author [Neil Rotstan](https://github.com/nrotstan)
2424
*/
25-
const SourcedTileLayerInternal = (props) => {
25+
const SourcedTileLayerInternal = ({ className, ...props }) => {
2626
const [layerRenderFailed, setLayerRenderFailed] = useState(false);
2727

2828
const attribution = (layer) => {

src/components/InsetMap/InsetMap.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import classNames from "classnames";
22
import PropTypes from "prop-types";
33
import { Component, useEffect } from "react";
4-
import { AttributionControl, MapContainer, Marker, useMap } from "react-leaflet";
4+
import { AttributionControl, MapContainer, Marker, ScaleControl, useMap } from "react-leaflet";
55
import { defaultLayerSource, layerSourceWithId } from "../../services/VisibleLayer/LayerSources";
66
import SourcedTileLayer from "../EnhancedMap/SourcedTileLayer/SourcedTileLayer";
77
import "./InsetMap.scss";
@@ -36,6 +36,7 @@ export default class InsetMap extends Component {
3636
>
3737
<ResizeMap />
3838
<AttributionControl position="bottomleft" prefix={false} />
39+
<ScaleControl position="bottomleft" />
3940
<SourcedTileLayer source={layerSource} skipAttribution={true} />
4041
<Marker
4142
position={this.props.centerPoint}

src/components/SupplementalMap/SupplementalMap.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import _map from "lodash/map";
44
import _sortBy from "lodash/sortBy";
55
import _uniqueId from "lodash/uniqueId";
66
import { useEffect, useState } from "react";
7-
import { AttributionControl, MapContainer, Pane, useMap } from "react-leaflet";
7+
import { AttributionControl, MapContainer, Pane, ScaleControl, useMap } from "react-leaflet";
88
import {
99
DEFAULT_ZOOM,
1010
MAX_ZOOM,
@@ -131,6 +131,7 @@ const SupplementalMap = (props) => {
131131
>
132132
<ResizeMap />
133133
<AttributionControl position="bottomleft" prefix={false} />
134+
<ScaleControl position="bottomleft" />
134135
<SupplementalMapContent {...props} />
135136
</MapContainer>
136137
</div>

src/components/TaskClusterMap/MapControlsDrawer.jsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,10 @@ const MapControlsDrawer = (props) => {
362362
transition: transform 0.3s ease-in-out;
363363
}
364364
365+
.map-controls-drawer:not(.open) .map-drawer-content {
366+
display: none;
367+
}
368+
365369
/* Add styles for lasso icons */
366370
.lasso-icon-container {
367371
position: relative;

src/components/TaskClusterMap/TaskClusterMap.scss

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,6 @@
5555
height: 100%;
5656
}
5757

58-
.leaflet-control-scale {
59-
top: 0px !important;
60-
}
6158
}
6259

6360
.greyscale-cluster {

src/components/TaskPane/TaskMap/TaskMap.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
LayerGroup,
2222
MapContainer,
2323
Pane,
24+
ScaleControl,
2425
useMap,
2526
useMapEvents,
2627
} from "react-leaflet";
@@ -769,6 +770,7 @@ const TaskMap = (props) => {
769770
>
770771
<ResizeMap />
771772
<AttributionControl position="bottomleft" prefix={false} />
773+
<ScaleControl position="bottomleft" />
772774
<TaskMapContent {...props} />
773775
</MapContainer>
774776
</div>

src/components/TaskPane/TaskNearbyList/TaskNearbyMap.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import "leaflet-vectoricon";
66
import "leaflet.markercluster/dist/MarkerCluster.css";
77
import _cloneDeep from "lodash/cloneDeep";
88
import _map from "lodash/map";
9-
import { AttributionControl, MapContainer, Marker, Tooltip, useMap } from "react-leaflet";
9+
import { AttributionControl, MapContainer, Marker, ScaleControl, Tooltip, useMap } from "react-leaflet";
1010
import resolveConfig from "tailwindcss/resolveConfig";
1111
import AsMappableTask from "../../../interactions/Task/AsMappableTask";
1212
import {
@@ -271,6 +271,7 @@ export class TaskNearbyMap extends Component {
271271
/>
272272
<ResizeMap />
273273
<AttributionControl position="bottomleft" prefix={false} />
274+
<ScaleControl position="bottomleft" />
274275

275276
<VisibleTileLayer {...this.props} zIndex={1} />
276277
{overlayLayers}

0 commit comments

Comments
 (0)