Spaces:
Runtime error
Runtime error
Commit
·
02e5929
1
Parent(s):
02a5e71
Add scale control to map component
Browse filesAdded ScaleControl from react-leaflet to the Map component, rendering a scale bar at the bottom right of the map. Both km/mi scale are there.
frontend/src/components/Map.js
CHANGED
|
@@ -9,7 +9,8 @@ import { MapContainer, TileLayer,
|
|
| 9 |
Polyline,
|
| 10 |
Tooltip,
|
| 11 |
Polygon,
|
| 12 |
-
GeoJSON
|
|
|
|
| 13 |
} from 'react-leaflet';
|
| 14 |
import L from 'leaflet';
|
| 15 |
import 'leaflet/dist/leaflet.css';
|
|
@@ -22,6 +23,8 @@ L.Icon.Default.mergeOptions({
|
|
| 22 |
iconUrl: 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.7.1/images/marker-icon.png',
|
| 23 |
shadowUrl: 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.7.1/images/marker-shadow.png',
|
| 24 |
});
|
|
|
|
|
|
|
| 25 |
|
| 26 |
const ClickHandler = ({ onClick }) => {
|
| 27 |
useMapEvents({
|
|
@@ -506,8 +509,11 @@ const Map = ( { onMapClick, searchQuery, contentType } ) => {
|
|
| 506 |
[-90, -180],
|
| 507 |
[90, 180]
|
| 508 |
]}
|
| 509 |
-
maxBoundsViscosity={1.0} // This prevents panning outside the horizonta/vertical bounds of the map. Avoids showing ugly section of the maps.
|
| 510 |
>
|
|
|
|
|
|
|
|
|
|
| 511 |
<ResizeHandler trigger={wikiWidth} />
|
| 512 |
{baseLayer === "satellite" && (
|
| 513 |
<>
|
|
|
|
| 9 |
Polyline,
|
| 10 |
Tooltip,
|
| 11 |
Polygon,
|
| 12 |
+
GeoJSON,
|
| 13 |
+
ScaleControl
|
| 14 |
} from 'react-leaflet';
|
| 15 |
import L from 'leaflet';
|
| 16 |
import 'leaflet/dist/leaflet.css';
|
|
|
|
| 23 |
iconUrl: 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.7.1/images/marker-icon.png',
|
| 24 |
shadowUrl: 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.7.1/images/marker-shadow.png',
|
| 25 |
});
|
| 26 |
+
// Add scale
|
| 27 |
+
// L.control.scale().addTo(window.Map);
|
| 28 |
|
| 29 |
const ClickHandler = ({ onClick }) => {
|
| 30 |
useMapEvents({
|
|
|
|
| 509 |
[-90, -180],
|
| 510 |
[90, 180]
|
| 511 |
]}
|
| 512 |
+
maxBoundsViscosity={1.0} // This completely prevents panning outside the horizonta/vertical bounds of the map. Avoids showing ugly section of the maps.
|
| 513 |
>
|
| 514 |
+
|
| 515 |
+
<ScaleControl position="bottomright" imperial={true} />
|
| 516 |
+
|
| 517 |
<ResizeHandler trigger={wikiWidth} />
|
| 518 |
{baseLayer === "satellite" && (
|
| 519 |
<>
|