@@ -11,11 +11,12 @@ import TileWMS from "ol/source/TileWMS";
11
11
import Projection from "ol/proj/Projection" ;
12
12
import Proj4 from "proj4" ;
13
13
import { register } from "ol/proj/proj4" ;
14
+ import { latlngToUTM } from "../../util/helper" ;
14
15
import ApiEndpointContext from "../../context/api-endpoint-context" ;
15
16
import "./map-wrapper.css" ;
16
17
17
18
// Todo style this......
18
- function MapWrapper ( { mapData, goToView } ) {
19
+ function MapWrapper ( { mapData, goToView, hideMapOverlay } ) {
19
20
const { mapUsername, mapPassword } = useContext ( ApiEndpointContext ) ;
20
21
const [ map , setMap ] = useState ( ) ;
21
22
const [ vectorLayer , setVectorLayer ] = useState ( null ) ;
@@ -29,10 +30,7 @@ function MapWrapper({ mapData, goToView }) {
29
30
mapData . length > 0 ? mapData [ 0 ] . northing : 574969.6851 ;
30
31
const eastingInitial = mapData . length > 0 ? mapData [ 0 ] . easting : 6223950.2116 ;
31
32
const view = new View ( {
32
- minZoom : 6 ,
33
- maxZoom : 20 ,
34
33
center : [ northingInitial , eastingInitial ] ,
35
- zoom : 6 ,
36
34
resolutions : [
37
35
1638.4 , 819.2 , 409.6 , 204.8 , 102.4 , 51.2 , 25.6 , 12.8 , 6.4 , 3.2 , 1.6 , 0.8 ,
38
36
0.4 , 0.2 , 0.1 ,
@@ -63,24 +61,40 @@ function MapWrapper({ mapData, goToView }) {
63
61
64
62
useEffect ( ( ) => {
65
63
if ( goToView && map ) {
66
- const { easting, northing } = goToView ;
64
+ const { centerlatitude, centerlongitude, zoomValue } = goToView ;
65
+ const [ destinationLat , destinationLong ] = latlngToUTM (
66
+ centerlatitude ,
67
+ centerlongitude
68
+ ) ;
67
69
map . getView ( ) . animate ( {
68
- center : [ northing , easting ] ,
70
+ center : [ destinationLat , destinationLong ] ,
71
+ zoom : zoomValue ,
69
72
duration : 800 ,
70
73
} ) ;
71
74
}
72
- } , [ goToView ] ) ;
75
+ } , [ goToView , map , hideMapOverlay ] ) ;
73
76
74
77
useEffect ( ( ) => {
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ABAUGBwgJCwwNFxkhIiQsLjk8PT4/QURFSElQUVRZZGZrbG58fX+Ai4yNjpGSk5SWl5iam5ydoKSmv8PExcfLztLT1NTW2Nna3Nzd3t/l5+jo7O3v8PLz8/T09ff4+Pn5+vv7+/z9/kqOLf8AAAABYktHRHNBCT3OAAABKklEQVQYGW3BhVYCQQAF0CeoWBjYid2Nio2Fiig22IGCz475/3Nk2RlY2LkXSnGbPxC5jwT8rcXI5RqIUYn2u2DRFKFVpBEZ3kfmindB6qSdF2k1t7R7rEVK4QF1wk4APdTrBgqOqHdYgAZmbO3c3J0xox4jVBaF4YPKEFYoLQvTO6UlhCmtCdMXpRCuKV0I0y+la8QoXQnTD6UoNiltCNMnpXXMUtr7E4a/V0o+tFDZ/RFCfL9RaYbjlMrl8cPzE5UTBzBBvXEAFXHqJCqRskCdeRiqk7RLVCFtjnYzMJVFmS9WDqmP+XqhOIPMtV2EjLoXWiU9sPDRahpWJSFm7ZcihydJJVmPPMNUBpHPsUpTwAkb9zkN525otNPQAa0pkpPQKxwLjjqR9Q+OaxIua1fKFgAAAABJRU5ErkJggg==" ,
86
100
} ) ,
@@ -89,13 +103,16 @@ function MapWrapper({ mapData, goToView }) {
89
103
// Define feature array and apply styling
90
104
const features = [ ] ;
91
105
92
- mapData . forEach ( ( { northing, easting, name } ) => {
106
+ mapData . forEach ( ( { northing, easting, name } , index ) => {
93
107
const feature = new Feature ( {
94
108
geometry : new Point ( [ northing , easting ] ) ,
95
109
name,
96
110
} ) ;
97
-
98
- feature . setStyle ( iconStyle ) ;
111
+ if ( index === 0 ) {
112
+ feature . setStyle ( firstIconStyle ) ;
113
+ } else {
114
+ feature . setStyle ( iconStyle ) ;
115
+ }
99
116
100
117
features . push ( feature ) ;
101
118
} ) ;
@@ -161,6 +178,7 @@ function MapWrapper({ mapData, goToView }) {
161
178
layers,
162
179
target : mapElement . current ,
163
180
view,
181
+ controls : [ ] ,
164
182
} ) ;
165
183
166
184
// save map and vector layer references to state
@@ -175,7 +193,9 @@ function MapWrapper({ mapData, goToView }) {
175
193
< div ref = { mapElement } className = "map rounded-xl overflow-hidden" id = "map" >
176
194
< div id = "tooltip" className = "tooltip" />
177
195
</ div >
178
- < div className = "map-color-overlay absolute left-0 top-0 bottom-0 right-0 w-screen h-screen bg-zinc-400 dark:bg-zinc-800 opacity-70 dark:opacity-80" />
196
+ { ! hideMapOverlay && (
197
+ < div className = "map-color-overlay absolute left-0 top-0 bottom-0 right-0 w-screen h-screen bg-zinc-400 dark:bg-zinc-800 opacity-70 dark:opacity-80" />
198
+ ) }
179
199
</ div >
180
200
) ;
181
201
}
0 commit comments