diff --git a/src/frontend/src/Components/Map.js b/src/frontend/src/Components/Map.js
index d346471ca..3812fd4ad 100644
--- a/src/frontend/src/Components/Map.js
+++ b/src/frontend/src/Components/Map.js
@@ -107,7 +107,9 @@ import {
import './Map.scss';
-export default function MapWrapper({ camera, isPreview, mapViewRoute }) {
+export default function MapWrapper(props) {
+ let { camera, isCamDetail, mapViewRoute, loadCamDetails } = props;
+
// Redux
const dispatch = useDispatch();
const {
@@ -316,7 +318,7 @@ export default function MapWrapper({ camera, isPreview, mapViewRoute }) {
});
mapRef.current.once('loadstart', async () => {
- if (camera && !isPreview) {
+ if (camera && !isCamDetail) {
if (camera.event_type) {
updateClickedEvent(camera);
} else {
@@ -431,17 +433,23 @@ export default function MapWrapper({ camera, isPreview, mapViewRoute }) {
};
const camClickHandler = feature => {
- resetClickedStates(feature);
+ if (!isCamDetail) {
+ resetClickedStates(feature);
- // set new clicked camera feature
- feature.setStyle(cameraStyles['active']);
- feature.setProperties({ clicked: true }, true);
+ // set new clicked camera feature
+ feature.setStyle(cameraStyles['active']);
+ feature.setProperties({ clicked: true }, true);
+
+ updateClickedCamera(feature);
- updateClickedCamera(feature);
+ cameraPopupRef.current = popup;
- cameraPopupRef.current = popup;
+ setTimeout(resetCameraPopupRef, 500);
- setTimeout(resetCameraPopupRef, 500);
+ } else {
+ setZoomPan(mapView, null, feature.getGeometry().getCoordinates());
+ loadCamDetails(feature.getProperties());
+ }
};
const eventClickHandler = feature => {
@@ -531,7 +539,6 @@ export default function MapWrapper({ camera, isPreview, mapViewRoute }) {
camClickHandler(clickedFeature);
return;
case 'event':
- console.log(clickedFeature.getProperties());
eventClickHandler(clickedFeature);
return;
case 'ferry':
@@ -562,7 +569,6 @@ export default function MapWrapper({ camera, isPreview, mapViewRoute }) {
regionalClickHandler(clickedFeature);
return;
case 'rest':
- console.log(clickedFeature.getProperties())
trackEvent(
'click',
'map',
@@ -809,9 +815,7 @@ export default function MapWrapper({ camera, isPreview, mapViewRoute }) {
mapLayers.current['highwayCams'] = getCamerasLayer(
finalCameras,
mapRef.current.getView().getProjection().getCode(),
- mapContext,
- camera,
- updateClickedCamera,
+ mapContext
);
mapRef.current.addLayer(mapLayers.current['highwayCams']);
@@ -1262,7 +1266,7 @@ export default function MapWrapper({ camera, isPreview, mapViewRoute }) {
if (typeof camera === 'string') {
camera = JSON.parse(camera);
}
- if (isPreview || camera) {
+ if (isCamDetail || camera) {
return 12;
} else {
return zoom;
@@ -1279,7 +1283,7 @@ export default function MapWrapper({ camera, isPreview, mapViewRoute }) {
}
// Force camera and inland ferries filters to be checked on preview mode
- if (isPreview) {
+ if (isCamDetail) {
mapContext.visible_layers['highwayCams'] = true;
mapContext.visible_layers['inlandFerries'] = true;
}
@@ -1296,7 +1300,7 @@ export default function MapWrapper({ camera, isPreview, mapViewRoute }) {
const smallScreen = useMediaQuery('only screen and (max-width: 767px)');
return (
-
+
{clickedCamera && (
-
+
)}
{clickedEvent && getEventPopup(clickedEvent)}
@@ -1352,7 +1356,7 @@ export default function MapWrapper({ camera, isPreview, mapViewRoute }) {
- {!isPreview && (
+ {!isCamDetail && (
- {isPreview && (
+ {isCamDetail && (