Add north arrow

This commit is contained in:
Tepponen Margit H
2025-06-03 14:15:38 +03:00
parent ceb6b57767
commit 4dab4957cf
2 changed files with 21 additions and 1 deletions
+21 -1
View File
@@ -2,7 +2,7 @@ import { useEffect, useRef, useState } from 'react'
import 'leaflet/dist/leaflet.css'
import { borders } from './country_borders_WGS84'
import { Button } from '@mui/material'
import { Button, SvgIcon } from '@mui/material'
import MapIcon from '@mui/icons-material/Map'
import L, { LatLngExpression, Icon } from 'leaflet'
import { Locality } from '@/shared/types/data.js'
@@ -13,6 +13,7 @@ import './MarkerCluster.css'
import './MarkerCluster.Default.css'
import '../../styles/LocalityMap.css'
import northarrow from './images/north-arrow.png'
interface Props {
localitiesQueryData?: Locality[]
@@ -84,6 +85,25 @@ export const LocalitiesMap = ({ localitiesQueryData, localitiesQueryIsFetching }
// Add a scale bar to the map
L.control.scale({ position: 'bottomright' }).addTo(map)
//Add north-arrow to the map
const imageurl = northarrow
L.Control.NorthArrow = L.Control.extend({
onAdd: function (map) {
var img = L.DomUtil.create('img');
img.src = imageurl;
img.style.width = '40px';
return img;
},
});
L.control.northArrow = function(opts){
return new L.Control.NorthArrow(opts);
}
L.control.northArrow({ position: 'bottomright' }).addTo(map);
// Add a layer control to the map
L.control.layers(baseMaps, {}, { position: 'topright' }).addTo(map)
Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB