|
|
@ -9,6 +9,13 @@ import { useSelector } from 'react-redux'; |
|
|
|
import MapLeftContent from '../../components/MapLeftContent'; |
|
|
|
import MapLeftContent from '../../components/MapLeftContent'; |
|
|
|
import MapRightContent from '../../components/MapRightContent'; |
|
|
|
import MapRightContent from '../../components/MapRightContent'; |
|
|
|
import { removeLayerByName } from '../../utils/MapUtils'; |
|
|
|
import { removeLayerByName } from '../../utils/MapUtils'; |
|
|
|
|
|
|
|
import RoutingBar from '../../components/RoutingBarV2'; |
|
|
|
|
|
|
|
import Loader from "react-loader-spinner"; |
|
|
|
|
|
|
|
import "react-loader-spinner/dist/loader/css/react-spinner-loader.css"; |
|
|
|
|
|
|
|
import { ToastContainer, toast } from "react-toastify"; |
|
|
|
|
|
|
|
import "react-toastify/dist/ReactToastify.css"; |
|
|
|
|
|
|
|
import './MapMonitoring.css'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const MapMonitoring = () => { |
|
|
|
const MapMonitoring = () => { |
|
|
|
|
|
|
|
|
|
|
@ -24,7 +31,7 @@ const MapMonitoring = () => { |
|
|
|
lng: 120.13025155062624 |
|
|
|
lng: 120.13025155062624 |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
const {userPoints, mymap, openLeft, openRight} = useSelector(state => state.mapReducer); |
|
|
|
const {userPoints, mymap, openLeft, openRight, routingBarVisible, userHistory, isSearchingRoute} = useSelector(state => state.mapReducer); |
|
|
|
const [gridMiddle, setGridMiddle] = useState(GRID_MIDDLE); |
|
|
|
const [gridMiddle, setGridMiddle] = useState(GRID_MIDDLE); |
|
|
|
const [gridLeft, setGridLeft] = useState(0); |
|
|
|
const [gridLeft, setGridLeft] = useState(0); |
|
|
|
const [gridRight, setGridRight] = useState(0); |
|
|
|
const [gridRight, setGridRight] = useState(0); |
|
|
@ -46,14 +53,28 @@ const MapMonitoring = () => { |
|
|
|
if (userPoints) { |
|
|
|
if (userPoints) { |
|
|
|
let userPointLayer = L.geoJson(userPoints, { |
|
|
|
let userPointLayer = L.geoJson(userPoints, { |
|
|
|
name: 'userPointLayer', |
|
|
|
name: 'userPointLayer', |
|
|
|
onEachFeature: onEachFeatureUserPoints, |
|
|
|
onEachFeature: onEachFeatureUserPoints |
|
|
|
}); |
|
|
|
}); |
|
|
|
userPointLayer.addTo(mymap); |
|
|
|
userPointLayer.addTo(mymap); |
|
|
|
|
|
|
|
mymap.fitBounds(userPointLayer.getBounds()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}, [userPoints]) |
|
|
|
}, [userPoints]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
|
|
|
if (mymap) { |
|
|
|
|
|
|
|
removeLayerByName('userHistoryLayer'); |
|
|
|
|
|
|
|
if (userHistory) { |
|
|
|
|
|
|
|
let userHistoryLayer = L.geoJson(userHistory, { |
|
|
|
|
|
|
|
name: 'userHistoryLayer' |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
userHistoryLayer.addTo(mymap); |
|
|
|
|
|
|
|
mymap.fitBounds(userHistoryLayer.getBounds()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, [userHistory]) |
|
|
|
|
|
|
|
|
|
|
|
const initMap = () => { |
|
|
|
const initMap = () => { |
|
|
|
let mymap = L.map('map-area', { |
|
|
|
let mymap = L.map('map-area', { |
|
|
|
center: center, |
|
|
|
center: center, |
|
|
@ -64,9 +85,12 @@ const MapMonitoring = () => { |
|
|
|
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors' }).addTo(mymap); |
|
|
|
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors' }).addTo(mymap); |
|
|
|
|
|
|
|
|
|
|
|
mymap.on('click', (e) => { |
|
|
|
mymap.on('click', (e) => { |
|
|
|
removeLayerByName('popupTemp'); |
|
|
|
if (!store.getState().mapReducer.routingBarVisible) { |
|
|
|
store.dispatch(setOpenRight(false)); |
|
|
|
// only can close popup when routing mode is not visible
|
|
|
|
store.dispatch(setSelectedFeature(null)); |
|
|
|
removeLayerByName('popupTemp'); |
|
|
|
|
|
|
|
store.dispatch(setOpenRight(false)); |
|
|
|
|
|
|
|
store.dispatch(setSelectedFeature(null)); |
|
|
|
|
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -99,7 +123,10 @@ const MapMonitoring = () => { |
|
|
|
const onEachFeatureUserPoints = (feature, layer) => { |
|
|
|
const onEachFeatureUserPoints = (feature, layer) => { |
|
|
|
layer.on('click', function(e) { |
|
|
|
layer.on('click', function(e) { |
|
|
|
L.DomEvent.stopPropagation(e); |
|
|
|
L.DomEvent.stopPropagation(e); |
|
|
|
showHighLight(feature); |
|
|
|
if (!store.getState().mapReducer.routingBarVisible) { |
|
|
|
|
|
|
|
// proceed only when routing mode is not visible
|
|
|
|
|
|
|
|
showHighLight(feature); |
|
|
|
|
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -130,18 +157,30 @@ const MapMonitoring = () => { |
|
|
|
<Col span={gridMiddle}> |
|
|
|
<Col span={gridMiddle}> |
|
|
|
<div id="map-area" style={{ height: '90vh', width: '100%' }} ref={mapRef}></div> |
|
|
|
<div id="map-area" style={{ height: '90vh', width: '100%' }} ref={mapRef}></div> |
|
|
|
<button
|
|
|
|
<button
|
|
|
|
title='List Projects' |
|
|
|
title='Project List' |
|
|
|
style={{position: 'absolute', top: 80, left: 10, zIndex: 999, backgroundColor:'white', backgroundSize:'34px 34px', width: '34px', height: '34px', borderRadius: '2px', borderWidth: '1px', borderColor: 'grey'}}
|
|
|
|
style={{position: 'absolute', top: 80, left: 10, zIndex: 999, backgroundColor:'white', backgroundSize:'34px 34px', width: '34px', height: '34px', borderRadius: '2px', borderWidth: '1px', borderColor: 'grey'}}
|
|
|
|
onClick={() => store.dispatch(setOpenLeft(!openLeft))}> |
|
|
|
onClick={() => store.dispatch(setOpenLeft(!openLeft))}> |
|
|
|
<i className='fa fa-list'></i> |
|
|
|
<i className='fa fa-list'></i> |
|
|
|
</button> |
|
|
|
</button> |
|
|
|
|
|
|
|
{ routingBarVisible && <RoutingBar /> } |
|
|
|
|
|
|
|
{ isSearchingRoute && ( |
|
|
|
|
|
|
|
<div className="loader-container"> |
|
|
|
|
|
|
|
<Loader |
|
|
|
|
|
|
|
type="TailSpin" |
|
|
|
|
|
|
|
color="#36D7B7" |
|
|
|
|
|
|
|
height={100} |
|
|
|
|
|
|
|
width={100} |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
)} |
|
|
|
</Col> |
|
|
|
</Col> |
|
|
|
<Col span={gridRight}> |
|
|
|
<Col span={gridRight}> |
|
|
|
<MapRightContent /> |
|
|
|
<MapRightContent /> |
|
|
|
</Col> |
|
|
|
</Col> |
|
|
|
|
|
|
|
<ToastContainer autoClose={5000} /> |
|
|
|
</Row> |
|
|
|
</Row> |
|
|
|
) |
|
|
|
) |
|
|
|
}, [openLeft, openRight, gridLeft, gridMiddle, gridRight]) |
|
|
|
}, [openLeft, openRight, gridLeft, gridMiddle, gridRight, routingBarVisible ]) |
|
|
|
|
|
|
|
|
|
|
|
const renderGridMap = () => { |
|
|
|
const renderGridMap = () => { |
|
|
|
let middle = GRID_MIDDLE; |
|
|
|
let middle = GRID_MIDDLE; |
|
|
|