@@ -131,11 +131,8 @@ function FeatureDetails() {
131131
132132 if ( mapRef == null ) {
133133 result = getCheckins ( 0 , 100 , 0 , 100 ) ;
134-
135- console . log ( "MAP REF IS NULL" ) ;
136134 } else {
137135 let bounds = mapRef . current ?. getBounds ( ) ;
138- console . log ( "MAP REF IS NOT NULL" ) ;
139136
140137 // change use map coords
141138 result = getCheckins ( bounds . getSouth ( ) , bounds . getNorth ( ) , bounds . getEast ( ) , bounds . getWest ( ) ) ;
@@ -267,6 +264,7 @@ function WeaverMap({
267264 }
268265 }
269266
267+ // TODO: have run depend on changing mapRef
270268 let featuredCheckin = h ( FeatureDetails ) ;
271269
272270 let overlay = h ( "div.overlay-div" , [
@@ -283,6 +281,8 @@ function WeaverMap({
283281 ] ) ;
284282 }
285283
284+ if ( style == null ) return null ;
285+
286286 return h (
287287 "div.map-container" ,
288288 [
@@ -300,12 +300,11 @@ function WeaverMap({
300300 setPosition : onSelectPosition ,
301301 } ) ,
302302 ] ) ,
303+
303304 // The Overlay Div
304305 overlay ,
305306 ]
306307 ) ,
307-
308-
309308 ]
310309 ) ;
311310
@@ -320,16 +319,18 @@ function useMapStyle(type, mapboxToken) {
320319 ? "mapbox://styles/mapbox/dark-v10"
321320 : "mapbox://styles/mapbox/light-v10" ;
322321
323- const [ actualStyle , setActualStyle ] = useState ( baseStyle ) ;
322+ const [ actualStyle , setActualStyle ] = useState ( null ) ;
324323
325324 // Auto select sample type
326- const overlayStyle = mergeStyles ( _macrostratStyle , weaverStyle ( types [ 0 ] ) ) ;
327- buildInspectorStyle ( baseStyle , overlayStyle , {
328- mapboxToken,
329- inDarkMode : isEnabled ,
330- } ) . then ( ( s ) => {
331- setActualStyle ( s ) ;
332- } ) ;
325+ useEffect ( ( ) => {
326+ const overlayStyle = mergeStyles ( _macrostratStyle , weaverStyle ( types [ 0 ] ) ) ;
327+ buildInspectorStyle ( baseStyle , overlayStyle , {
328+ mapboxToken,
329+ inDarkMode : isEnabled ,
330+ } ) . then ( ( s ) => {
331+ setActualStyle ( s ) ;
332+ } ) ;
333+ } , [ ] ) ;
333334
334335 return actualStyle ;
335336}
0 commit comments