diff --git a/src/frontend/src/Components/Map.js b/src/frontend/src/Components/Map.js
index 7902a06d2..25fcdd4cc 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 {
@@ -315,7 +317,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 {
@@ -427,17 +429,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 => {
@@ -527,7 +535,6 @@ export default function MapWrapper({ camera, isPreview, mapViewRoute }) {
camClickHandler(clickedFeature);
return;
case 'event':
- console.log(clickedFeature.getProperties());
eventClickHandler(clickedFeature);
return;
case 'ferry':
@@ -558,7 +565,6 @@ export default function MapWrapper({ camera, isPreview, mapViewRoute }) {
regionalClickHandler(clickedFeature);
return;
case 'rest':
- console.log(clickedFeature.getProperties())
trackEvent(
'click',
'map',
@@ -805,9 +811,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']);
@@ -1258,7 +1262,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;
@@ -1275,7 +1279,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;
}
@@ -1292,7 +1296,7 @@ export default function MapWrapper({ camera, isPreview, mapViewRoute }) {
const smallScreen = useMediaQuery('only screen and (max-width: 767px)');
return (
-
+
{clickedCamera && (
-
+
)}
{clickedEvent && getEventPopup(clickedEvent)}
@@ -1348,7 +1352,7 @@ export default function MapWrapper({ camera, isPreview, mapViewRoute }) {
- {!isPreview && (
+ {!isCamDetail && (
- {isPreview && (
+ {isCamDetail && (