@@ -107,7 +107,9 @@ import {
107
107
import './Map.scss' ;
108
108
109
109
110
- export default function MapWrapper ( { camera, isPreview, mapViewRoute } ) {
110
+ export default function MapWrapper ( props ) {
111
+ let { camera, isCamDetail, mapViewRoute, loadCamDetails } = props ;
112
+
111
113
// Redux
112
114
const dispatch = useDispatch ( ) ;
113
115
const {
@@ -316,7 +318,7 @@ export default function MapWrapper({ camera, isPreview, mapViewRoute }) {
316
318
} ) ;
317
319
318
320
mapRef . current . once ( 'loadstart' , async ( ) => {
319
- if ( camera && ! isPreview ) {
321
+ if ( camera && ! isCamDetail ) {
320
322
if ( camera . event_type ) {
321
323
updateClickedEvent ( camera ) ;
322
324
} else {
@@ -431,17 +433,23 @@ export default function MapWrapper({ camera, isPreview, mapViewRoute }) {
431
433
} ;
432
434
433
435
const camClickHandler = feature => {
434
- resetClickedStates ( feature ) ;
436
+ if ( ! isCamDetail ) {
437
+ resetClickedStates ( feature ) ;
435
438
436
- // set new clicked camera feature
437
- feature . setStyle ( cameraStyles [ 'active' ] ) ;
438
- feature . setProperties ( { clicked : true } , true ) ;
439
+ // set new clicked camera feature
440
+ feature . setStyle ( cameraStyles [ 'active' ] ) ;
441
+ feature . setProperties ( { clicked : true } , true ) ;
442
+
443
+ updateClickedCamera ( feature ) ;
439
444
440
- updateClickedCamera ( feature ) ;
445
+ cameraPopupRef . current = popup ;
441
446
442
- cameraPopupRef . current = popup ;
447
+ setTimeout ( resetCameraPopupRef , 500 ) ;
443
448
444
- setTimeout ( resetCameraPopupRef , 500 ) ;
449
+ } else {
450
+ setZoomPan ( mapView , null , feature . getGeometry ( ) . getCoordinates ( ) ) ;
451
+ loadCamDetails ( feature . getProperties ( ) ) ;
452
+ }
445
453
} ;
446
454
447
455
const eventClickHandler = feature => {
@@ -531,7 +539,6 @@ export default function MapWrapper({ camera, isPreview, mapViewRoute }) {
531
539
camClickHandler ( clickedFeature ) ;
532
540
return ;
533
541
case 'event' :
534
- console . log ( clickedFeature . getProperties ( ) ) ;
535
542
eventClickHandler ( clickedFeature ) ;
536
543
return ;
537
544
case 'ferry' :
@@ -562,7 +569,6 @@ export default function MapWrapper({ camera, isPreview, mapViewRoute }) {
562
569
regionalClickHandler ( clickedFeature ) ;
563
570
return ;
564
571
case 'rest' :
565
- console . log ( clickedFeature . getProperties ( ) )
566
572
trackEvent (
567
573
'click' ,
568
574
'map' ,
@@ -809,9 +815,7 @@ export default function MapWrapper({ camera, isPreview, mapViewRoute }) {
809
815
mapLayers . current [ 'highwayCams' ] = getCamerasLayer (
810
816
finalCameras ,
811
817
mapRef . current . getView ( ) . getProjection ( ) . getCode ( ) ,
812
- mapContext ,
813
- camera ,
814
- updateClickedCamera ,
818
+ mapContext
815
819
) ;
816
820
817
821
mapRef . current . addLayer ( mapLayers . current [ 'highwayCams' ] ) ;
@@ -1262,7 +1266,7 @@ export default function MapWrapper({ camera, isPreview, mapViewRoute }) {
1262
1266
if ( typeof camera === 'string' ) {
1263
1267
camera = JSON . parse ( camera ) ;
1264
1268
}
1265
- if ( isPreview || camera ) {
1269
+ if ( isCamDetail || camera ) {
1266
1270
return 12 ;
1267
1271
} else {
1268
1272
return zoom ;
@@ -1279,7 +1283,7 @@ export default function MapWrapper({ camera, isPreview, mapViewRoute }) {
1279
1283
}
1280
1284
1281
1285
// Force camera and inland ferries filters to be checked on preview mode
1282
- if ( isPreview ) {
1286
+ if ( isCamDetail ) {
1283
1287
mapContext . visible_layers [ 'highwayCams' ] = true ;
1284
1288
mapContext . visible_layers [ 'inlandFerries' ] = true ;
1285
1289
}
@@ -1296,7 +1300,7 @@ export default function MapWrapper({ camera, isPreview, mapViewRoute }) {
1296
1300
const smallScreen = useMediaQuery ( 'only screen and (max-width: 767px)' ) ;
1297
1301
1298
1302
return (
1299
- < div className = { `map-container ${ isPreview ? 'preview' : '' } ` } >
1303
+ < div className = { `map-container ${ isCamDetail ? 'preview' : '' } ` } >
1300
1304
< div
1301
1305
ref = { panel }
1302
1306
className = { `side-panel ${ openPanel ? 'open' : '' } ` }
@@ -1318,7 +1322,7 @@ export default function MapWrapper({ camera, isPreview, mapViewRoute }) {
1318
1322
1319
1323
< div className = "panel-content" >
1320
1324
{ clickedCamera && (
1321
- < CamPopup camFeature = { clickedCamera } isPreview = { isPreview } />
1325
+ < CamPopup camFeature = { clickedCamera } isCamDetail = { isCamDetail } />
1322
1326
) }
1323
1327
1324
1328
{ clickedEvent && getEventPopup ( clickedEvent ) }
@@ -1352,7 +1356,7 @@ export default function MapWrapper({ camera, isPreview, mapViewRoute }) {
1352
1356
</ Button >
1353
1357
</ div >
1354
1358
1355
- { ! isPreview && (
1359
+ { ! isCamDetail && (
1356
1360
< Button
1357
1361
className = "map-btn my-location"
1358
1362
variant = "primary"
@@ -1363,7 +1367,7 @@ export default function MapWrapper({ camera, isPreview, mapViewRoute }) {
1363
1367
</ Button >
1364
1368
) }
1365
1369
1366
- { ! isPreview && (
1370
+ { ! isCamDetail && (
1367
1371
< div className = { `map-left-container ${ ( showServerError || showNetworkError ) ? 'error-showing' : '' } ` } >
1368
1372
{ smallScreen && (
1369
1373
< ExitSurvey mobile = { true } />
@@ -1374,14 +1378,14 @@ export default function MapWrapper({ camera, isPreview, mapViewRoute }) {
1374
1378
</ div >
1375
1379
) }
1376
1380
1377
- { ( ! isPreview && ! smallScreen ) && (
1381
+ { ( ! isCamDetail && ! smallScreen ) && (
1378
1382
< ExitSurvey />
1379
1383
) }
1380
1384
1381
- { ! isPreview && (
1385
+ { ! isCamDetail && (
1382
1386
< Filters
1383
1387
toggleHandler = { toggleLayer }
1384
- disableFeatures = { isPreview }
1388
+ disableFeatures = { isCamDetail }
1385
1389
enableRoadConditions = { true }
1386
1390
/>
1387
1391
) }
@@ -1392,7 +1396,7 @@ export default function MapWrapper({ camera, isPreview, mapViewRoute }) {
1392
1396
< div id = "popup-content" className = "ol-popup-content" > </ div >
1393
1397
</ div >
1394
1398
1395
- { isPreview && (
1399
+ { isCamDetail && (
1396
1400
< Button
1397
1401
className = "map-btn cam-location"
1398
1402
variant = "primary"
@@ -1406,7 +1410,7 @@ export default function MapWrapper({ camera, isPreview, mapViewRoute }) {
1406
1410
</ Button >
1407
1411
) }
1408
1412
1409
- { isPreview && (
1413
+ { isCamDetail && (
1410
1414
< Button
1411
1415
className = "map-btn map-view"
1412
1416
variant = "primary"
@@ -1416,10 +1420,10 @@ export default function MapWrapper({ camera, isPreview, mapViewRoute }) {
1416
1420
</ Button >
1417
1421
) }
1418
1422
1419
- { isPreview && (
1423
+ { isCamDetail && (
1420
1424
< Filters
1421
1425
toggleHandler = { toggleLayer }
1422
- disableFeatures = { isPreview }
1426
+ disableFeatures = { isCamDetail }
1423
1427
enableRoadConditions = { true }
1424
1428
textOverride = { 'Layer filters' }
1425
1429
/>
0 commit comments