import {
AttributionControl,
CircleMarker,
LayerGroup,
LayersControl,
MapContainer,
Marker,
Polygon,
Polyline,
Popup,
Rectangle,
TileLayer,
VideoOverlay,
useMap,
useMapEvent,
useMapEvents
} from 'react-leaflet'
// import 'leaflet/dist/leaflet.css'
import React, { useEffect, useState, useRef, useMemo, useCallback } from 'react'
// import 'leaflet/dist/leaflet.css'
// import '../../../../node_modules/leaflet/dist/leaflet.css'
import { StyledMapContainer } from './MapBox.theme'
import GeoJSON from 'geojson'
import L from 'leaflet'
// function LocationMarker() {
// const [position, setPosition] = useState(null)
// const map = useMapEvents({
// click() {
// map.locate()
// },
// locationfound(e) {
// if (e?.latlng) {
// setPosition(e.latlng)
// map.flyTo(e.latlng, map.getZoom())
// }
// }
// })
// return position === null ? null : (
//
// You are here
//
// )
// }
const MapBox = () => {
// const setColor = ({ }) => {
// return { weight: 1 }
// }
// const setIcon = ({ properties }, latlng) => {
// return L.marker(latlng, { icon: customMarkerIcon(properties.Name) })
// }
const center = [51.505, -0.09]
const multiPolygonGroup = [
[
[51.51, -0.12],
[51.51, -0.13],
[51.53, -0.13]
],
[
[51.51, -0.05],
[51.51, -0.07],
[51.53, -0.07]
]
]
const polyline = [
[51.505, -0.09],
[51.51, -0.1],
[51.51, -0.12]
]
const multiPolyline = [
[
[51.5, -0.1],
[51.5, -0.12],
[51.52, -0.12]
],
[
[51.5, -0.05],
[51.5, -0.06],
[51.52, -0.06]
]
]
const polygon = [
[51.515, -0.09],
[51.52, -0.1],
[51.52, -0.12]
]
const multiPolygon = [
[
[51.51, -0.12],
[51.51, -0.13],
[51.53, -0.13],
[51.55, -0.2]
],
[
[51.51, -0.05],
[51.51, -0.07],
[51.53, -0.07]
]
]
const fillBlueOptions = { fillColor: 'blue' }
const blackOptions = { color: 'black' }
const limeOptions = { color: 'lime' }
const purpleOptions = { color: 'purple' }
const redOptions = { color: 'red' }
const POSITION_CLASSES = {
bottomleft: 'leaflet-bottom leaflet-left',
bottomright: 'leaflet-bottom leaflet-right',
topleft: 'leaflet-top leaflet-left',
topright: 'leaflet-top leaflet-right'
}
const BOUNDS_STYLE = { weight: 1 }
function MinimapBounds({ parentMap, zoom }) {
const minimap = useMap()
// Clicking a point on the minimap sets the parent's map center
const onClick = useCallback(
event => {
parentMap.setView(event.latlng, parentMap.getZoom())
},
[parentMap]
)
useMapEvent('click', onClick)
// Keep track of bounds in state to trigger renders
const [bounds, setBounds] = useState(parentMap.getBounds())
const onChange = useCallback(() => {
setBounds(parentMap.getBounds())
// Update the minimap's view to match the parent map's center and zoom
minimap.setView(parentMap.getCenter(), zoom)
}, [minimap, parentMap, zoom])
// Listen to events on the parent map
const handlers = useMemo(() => ({ move: onChange, zoom: onChange }), [])
useEventHandlers({ instance: parentMap }, handlers)
return
}
function MinimapControl({ position, zoom }) {
const parentMap = useMap()
const mapZoom = zoom || 0
// Memoize the minimap so it's not affected by position changes
const minimap = useMemo(
() => (
),
[]
)
const positionClass =
(position && POSITION_CLASSES[position]) || POSITION_CLASSES.topright
return (
)
}
const videoOverlayBounds = L.latLngBounds([
[51.51, -0.12],
[51.52, -0.11] // Define the bounds for the video overlay
])
return (
{/*
Popup in CircleMarker
{multiPolygon.map(item => (
))}
*/}
)
}
export default MapBox
// function useEventHandlers({ instance }, handlers) {
// useEffect(() => {
// const { move, zoom } = handlers
// if (instance) {
// instance.on('move', move)
// instance.on('zoom', zoom)
// }
// return () => {
// if (instance) {
// instance.off('move', move)
// instance.off('zoom', zoom)
// }
// }
// }, [instance, handlers])
// }