@@ -112,6 +112,34 @@ export class MainView extends React.Component<IProps, IStates> {
112
112
constructor ( props : IProps ) {
113
113
super ( props ) ;
114
114
115
+ const el = document . getElementById ( 'main-panel' ) ;
116
+
117
+ if ( el ) {
118
+ const setWidthOneHundred = ( selector : string ) => {
119
+ ( document . querySelector ( selector ) as HTMLElement ) . style . setProperty (
120
+ 'width' ,
121
+ '100%' ,
122
+ ) ;
123
+ } ;
124
+ //We need to observe the size to counteract
125
+ //What the default jupyter plugin will try
126
+ //To do dynamically with the width
127
+ const resizeObserver = new ResizeObserver ( _ => {
128
+ el . style . setProperty ( 'width' , '100%' ) ;
129
+ el . style . setProperty ( 'max-width' , '100%' ) ;
130
+ el ?. style . setProperty ( 'left' , '0px' ) ;
131
+
132
+ setWidthOneHundred ( '#main-panel jp-toolbar' ) ;
133
+ setWidthOneHundred ( '#main-panel .lm-SplitPanel ' ) ;
134
+
135
+ setWidthOneHundred (
136
+ '#main-panel .lm-SplitPanel .lm-SplitPanel-child ' ,
137
+ ) ;
138
+ } ) ;
139
+
140
+ resizeObserver . observe ( el ) ;
141
+ }
142
+
115
143
this . _mainViewModel = this . props . viewModel ;
116
144
this . _mainViewModel . viewSettingChanged . connect ( this . _onViewChanged , this ) ;
117
145
@@ -173,7 +201,9 @@ export class MainView extends React.Component<IProps, IStates> {
173
201
this . _sources = [ ] ;
174
202
this . _loadingLayers = new Set ( ) ;
175
203
this . _commands = new CommandRegistry ( ) ;
176
- this . _contextMenu = new ContextMenu ( { commands : this . _commands } ) ;
204
+ this . _contextMenu = new ContextMenu ( {
205
+ commands : this . _commands ,
206
+ } ) ;
177
207
}
178
208
179
209
async componentDidMount ( ) : Promise < void > {
@@ -184,6 +214,7 @@ export class MainView extends React.Component<IProps, IStates> {
184
214
? fromLonLat ( [ options . longitude ! , options . latitude ! ] )
185
215
: [ 0 , 0 ] ;
186
216
const zoom = options . zoom !== undefined ? options . zoom ! : 1 ;
217
+
187
218
await this . generateMap ( center , zoom ) ;
188
219
this . addContextMenu ( ) ;
189
220
this . _mainViewModel . initSignal ( ) ;
@@ -285,7 +316,13 @@ export class MainView extends React.Component<IProps, IStates> {
285
316
return ;
286
317
}
287
318
this . _model . syncViewport (
288
- { coordinates : { x : center [ 0 ] , y : center [ 1 ] } , zoom } ,
319
+ {
320
+ coordinates : {
321
+ x : center [ 0 ] ,
322
+ y : center [ 1 ] ,
323
+ } ,
324
+ zoom,
325
+ } ,
289
326
this . _mainViewModel . id ,
290
327
) ;
291
328
} ) ,
@@ -458,7 +495,10 @@ export class MainView extends React.Component<IProps, IStates> {
458
495
}
459
496
460
497
this . _mainViewModel . addAnnotation ( {
461
- position : { x : this . _clickCoords [ 0 ] , y : this . _clickCoords [ 1 ] } ,
498
+ position : {
499
+ x : this . _clickCoords [ 0 ] ,
500
+ y : this . _clickCoords [ 1 ] ,
501
+ } ,
462
502
zoom : this . _Map . getView ( ) . getZoom ( ) ?? 0 ,
463
503
label : 'New annotation' ,
464
504
contents : [ ] ,
@@ -538,7 +578,9 @@ export class MainView extends React.Component<IProps, IStates> {
538
578
minZoom : sourceParameters . minZoom ,
539
579
maxZoom : sourceParameters . maxZoom ,
540
580
url : url ,
541
- format : new MVT ( { featureClass : RenderFeature } ) ,
581
+ format : new MVT ( {
582
+ featureClass : RenderFeature ,
583
+ } ) ,
542
584
} ) ;
543
585
} else {
544
586
newSource = new PMTilesVectorSource ( {
@@ -916,7 +958,9 @@ export class MainView extends React.Component<IProps, IStates> {
916
958
} ;
917
959
918
960
if ( layerParameters . color ) {
919
- layerOptions [ 'style' ] = { color : layerParameters . color } ;
961
+ layerOptions [ 'style' ] = {
962
+ color : layerParameters . color ,
963
+ } ;
920
964
}
921
965
922
966
newMapLayer = new WebGlTileLayer ( layerOptions ) ;
@@ -1339,8 +1383,13 @@ export class MainView extends React.Component<IProps, IStates> {
1339
1383
return new Style ( {
1340
1384
image : new Circle ( {
1341
1385
radius : 6 ,
1342
- fill : new Fill ( { color : 'rgba(255, 255, 0, 0.8)' } ) ,
1343
- stroke : new Stroke ( { color : '#ff0' , width : 2 } ) ,
1386
+ fill : new Fill ( {
1387
+ color : 'rgba(255, 255, 0, 0.8)' ,
1388
+ } ) ,
1389
+ stroke : new Stroke ( {
1390
+ color : '#ff0' ,
1391
+ width : 2 ,
1392
+ } ) ,
1344
1393
} ) ,
1345
1394
} ) ;
1346
1395
case 'LineString' :
@@ -1388,7 +1437,10 @@ export class MainView extends React.Component<IProps, IStates> {
1388
1437
return new Promise ( resolve => {
1389
1438
const checkReady = ( ) => {
1390
1439
if ( this . _loadingLayers . size === 0 ) {
1391
- this . setState ( old => ( { ...old , loadingLayer : false } ) ) ;
1440
+ this . setState ( old => ( {
1441
+ ...old ,
1442
+ loadingLayer : false ,
1443
+ } ) ) ;
1392
1444
resolve ( ) ;
1393
1445
} else {
1394
1446
setTimeout ( checkReady , 50 ) ;
@@ -1454,7 +1506,10 @@ export class MainView extends React.Component<IProps, IStates> {
1454
1506
}
1455
1507
1456
1508
if ( remoteState . user ?. username !== this . state . remoteUser ?. username ) {
1457
- this . setState ( old => ( { ...old , remoteUser : remoteState . user } ) ) ;
1509
+ this . setState ( old => ( {
1510
+ ...old ,
1511
+ remoteUser : remoteState . user ,
1512
+ } ) ) ;
1458
1513
}
1459
1514
1460
1515
const remoteViewport = remoteState . viewportState ;
@@ -1468,7 +1523,10 @@ export class MainView extends React.Component<IProps, IStates> {
1468
1523
} else {
1469
1524
// If we are unfollowing a remote user, we reset our center and zoom to their previous values
1470
1525
if ( this . state . remoteUser !== null ) {
1471
- this . setState ( old => ( { ...old , remoteUser : null } ) ) ;
1526
+ this . setState ( old => ( {
1527
+ ...old ,
1528
+ remoteUser : null ,
1529
+ } ) ) ;
1472
1530
const viewportState = localState . viewportState ?. value ;
1473
1531
1474
1532
if ( viewportState ) {
@@ -1506,14 +1564,26 @@ export class MainView extends React.Component<IProps, IStates> {
1506
1564
username : client . user . username ,
1507
1565
displayName : client . user . display_name ,
1508
1566
color : client . user . color ,
1509
- coordinates : { x : pixel [ 0 ] , y : pixel [ 1 ] } ,
1510
- lonLat : { longitude : lonLat [ 0 ] , latitude : lonLat [ 1 ] } ,
1567
+ coordinates : {
1568
+ x : pixel [ 0 ] ,
1569
+ y : pixel [ 1 ] ,
1570
+ } ,
1571
+ lonLat : {
1572
+ longitude : lonLat [ 0 ] ,
1573
+ latitude : lonLat [ 1 ] ,
1574
+ } ,
1511
1575
} ;
1512
1576
} else {
1513
1577
currentClientPointer = {
1514
1578
...currentClientPointer ,
1515
- coordinates : { x : pixel [ 0 ] , y : pixel [ 1 ] } ,
1516
- lonLat : { longitude : lonLat [ 0 ] , latitude : lonLat [ 1 ] } ,
1579
+ coordinates : {
1580
+ x : pixel [ 0 ] ,
1581
+ y : pixel [ 1 ] ,
1582
+ } ,
1583
+ lonLat : {
1584
+ longitude : lonLat [ 0 ] ,
1585
+ latitude : lonLat [ 1 ] ,
1586
+ } ,
1517
1587
} ;
1518
1588
}
1519
1589
@@ -1875,7 +1945,10 @@ export class MainView extends React.Component<IProps, IStates> {
1875
1945
// Zoom needs to be set before changing center
1876
1946
if ( ! view . animate === undefined ) {
1877
1947
view . animate ( { zoom, duration } ) ;
1878
- view . animate ( { center : [ center . x , center . y ] , duration } ) ;
1948
+ view . animate ( {
1949
+ center : [ center . x , center . y ] ,
1950
+ duration,
1951
+ } ) ;
1879
1952
}
1880
1953
}
1881
1954
0 commit comments