diff --git a/src/components/Map/Map.js b/src/components/Map/Map.js index 5892f022..c3378eb8 100644 --- a/src/components/Map/Map.js +++ b/src/components/Map/Map.js @@ -1,7 +1,8 @@ -import React from 'react'; +import React, { useContext } from 'react'; import { Map, Circle, TileLayer, Marker, Popup } from 'react-leaflet'; import styled from 'styled-components'; import L from 'leaflet'; +import { DispatchContext } from '../../context'; const protestPoint = ({ iconUrl, iconRetinaUrl, iconSize, iconAnchor }) => new L.Icon({ @@ -45,6 +46,8 @@ const MarkersList = ({ markers }) => { const balfur = [31.7749837, 35.219797]; function AppMap({ markers, coordinates, setMapPosition, setMapPositionHistory }) { + const dispatch = useContext(DispatchContext); + return ( 0 ? coordinates : balfur} @@ -59,7 +62,9 @@ function AppMap({ markers, coordinates, setMapPosition, setMapPositionHistory }) /> {coordinates.length === 2 && ( <> - + dispatch({ type: 'setUserCoordinates', payload: marker.getLatLng()})}> +