@@ -359,12 +359,12 @@ class LayerController {
359
359
StreamController (onCancel: () => handle? .remove ());
360
360
361
361
handle = watch (
362
- ( ) => view.zoom,
363
- (zoom, _) {
362
+ allowInterop (( ) => view.zoom) ,
363
+ allowInterop ( (zoom, _) {
364
364
if (! controller.isClosed && zoom as double > 0 ) {
365
365
controller.add (zoom);
366
366
}
367
- },
367
+ }) ,
368
368
);
369
369
370
370
// Merge all the zoom streams into one
@@ -397,18 +397,16 @@ class LayerController {
397
397
StreamController (onCancel: () => handle? .remove ());
398
398
399
399
handle = watch (
400
- () => view.center,
401
- (center, _) {
402
- if (center != null && ! controller.isClosed) {
403
- final centerViewPoint = LatLng (
404
- (center as JsPoint ).latitude,
405
- center.longitude,
406
- );
407
- controller.add (centerViewPoint);
400
+ allowInterop (() => view.center),
401
+ allowInterop ((center, _) {
402
+ if (! controller.isClosed && center != null ) {
403
+ final point = center as JsPoint ;
404
+ controller.add (LatLng (point.latitude, point.longitude));
408
405
}
409
- },
406
+ }) ,
410
407
);
411
408
409
+ // Merge all the center position streams into one
412
410
return controller.stream;
413
411
}
414
412
@@ -455,48 +453,50 @@ class LayerController {
455
453
);
456
454
457
455
handle = watch (
458
- () => view.extent,
459
- (extent, _) {
460
- if (! controller.isClosed) {
461
- final List <String > graphicIdsInView = < String > [];
462
-
463
- // Return all the visible graphic ids in the MapView
464
- view.graphics.forEach (
465
- allowInterop ((JsGraphic graphic, _, __) {
466
- final bool isInView =
467
- (extent as JsExtent ? )? .intersects (graphic.geometry.extent) ??
468
- false ;
469
- if (isInView) {
470
- graphicIdsInView.add (graphic.attributes.id);
471
- }
472
- }),
473
- );
456
+ allowInterop (() => view.extent),
457
+ allowInterop (
458
+ (extent, _) {
459
+ if (! controller.isClosed) {
460
+ final List <String > graphicIdsInView = < String > [];
461
+
462
+ // Return all the visible graphic ids in the MapView
463
+ view.graphics.forEach (
464
+ allowInterop ((JsGraphic graphic, _, __) {
465
+ final bool isInView = (extent as JsExtent ? )
466
+ ? .intersects (graphic.geometry.extent) ??
467
+ false ;
468
+ if (isInView) {
469
+ graphicIdsInView.add (graphic.attributes.id);
470
+ }
471
+ }),
472
+ );
474
473
475
- // Return all the visible graphic ids in the graphic layers
476
- final layers = map.layers;
477
- layers? .forEach (
478
- allowInterop ((layer, _, __) {
479
- if (layer is JsGraphicsLayer ) {
480
- layer.graphics? .forEach (
481
- allowInterop ((JsGraphic graphic, _, __) {
482
- final bool isInView = (extent as JsExtent ? )
483
- ? .intersects (graphic.geometry.extent) ??
484
- false ;
485
- if (isInView) {
486
- graphicIdsInView.add (graphic.attributes.id);
487
- }
488
- }),
489
- );
490
- }
491
- }),
492
- );
474
+ // Return all the visible graphic ids in the graphic layers
475
+ final layers = map.layers;
476
+ layers? .forEach (
477
+ allowInterop ((layer, _, __) {
478
+ if (layer is JsGraphicsLayer ) {
479
+ layer.graphics? .forEach (
480
+ allowInterop ((JsGraphic graphic, _, __) {
481
+ final bool isInView = (extent as JsExtent ? )
482
+ ? .intersects (graphic.geometry.extent) ??
483
+ false ;
484
+ if (isInView) {
485
+ graphicIdsInView.add (graphic.attributes.id);
486
+ }
487
+ }),
488
+ );
489
+ }
490
+ }),
491
+ );
493
492
494
- if (! listEquals (graphicIdsInViewBuffer, graphicIdsInView)) {
495
- controller.add (graphicIdsInView);
496
- graphicIdsInViewBuffer = graphicIdsInView;
493
+ if (! listEquals (graphicIdsInViewBuffer, graphicIdsInView)) {
494
+ controller.add (graphicIdsInView);
495
+ graphicIdsInViewBuffer = graphicIdsInView;
496
+ }
497
497
}
498
- }
499
- } ,
498
+ },
499
+ ) ,
500
500
);
501
501
// Merge all the streams into one
502
502
return controller.stream;
@@ -509,14 +509,14 @@ class LayerController {
509
509
JsView view,
510
510
JsEsriMap map,
511
511
) {
512
- final extent = view.get ( ' extent' ) as JsExtent ? ;
512
+ final extent = view.extent;
513
513
514
514
// Return all the visible graphic ids in the MapView
515
515
final List <String > graphicIdsInView = < String > [];
516
516
view.graphics.forEach (
517
517
allowInterop ((JsGraphic graphic, _, __) {
518
518
final bool isInView =
519
- extent? .intersects (graphic.geometry.extent) ?? false ;
519
+ extent.intersects (graphic.geometry.extent) ?? false ;
520
520
if (isInView) {
521
521
graphicIdsInView.add (graphic.attributes.id);
522
522
}
@@ -531,7 +531,7 @@ class LayerController {
531
531
layer.graphics? .forEach (
532
532
allowInterop ((JsGraphic graphic, _, __) {
533
533
final bool isInView =
534
- extent? .intersects (graphic.geometry.extent) ?? false ;
534
+ extent.intersects (graphic.geometry.extent) ?? false ;
535
535
if (isInView) {
536
536
graphicIdsInView.add (graphic.attributes.id);
537
537
}
@@ -566,46 +566,47 @@ class LayerController {
566
566
/// Gets the current bounds streams of the active views.
567
567
Stream <BoundingBox > _getCurrentBoundsStreams (JsView view) {
568
568
streamsRefreshed.add (boundsStreamRefreshedForCurrentView);
569
-
570
- // In order to stop watching on the extent when the stream is canceled in Dart,
569
+ // In order to stop watching on the bounds when the stream is canceled in Dart,
571
570
// a handle is assigned to the watch method, and it is removed when the Stream is canceled.
572
571
WatchHandle ? handle;
573
572
final StreamController <BoundingBox > controller =
574
573
StreamController (onCancel: () => handle? .remove ());
575
574
576
575
handle = watch (
577
- () => view.extent,
578
- (newValue, _) {
579
- if (newValue is JsExtent && ! controller.isClosed) {
580
- final centerViewPoint =
581
- LatLng (newValue.center.latitude, newValue.center.longitude);
582
- final xDistanceFromViewCenter = newValue.width / 2 ;
583
- final yDistanceFromViewCenter = newValue.height / 2 ;
584
-
585
- // Lower left point
586
- final latLngMin = BoundingBox .getLatLngFromMapUnits (
587
- referencePoint: centerViewPoint,
588
- x: - xDistanceFromViewCenter,
589
- y: - yDistanceFromViewCenter,
590
- );
576
+ allowInterop (() => view.extent),
577
+ allowInterop (
578
+ (newValue, _) {
579
+ if (newValue is JsExtent && ! controller.isClosed) {
580
+ final centerViewPoint =
581
+ LatLng (newValue.center.latitude, newValue.center.longitude);
582
+ final xDistanceFromViewCenter = newValue.width / 2 ;
583
+ final yDistanceFromViewCenter = newValue.height / 2 ;
584
+
585
+ // Lower left point
586
+ final latLngMin = BoundingBox .getLatLngFromMapUnits (
587
+ referencePoint: centerViewPoint,
588
+ x: - xDistanceFromViewCenter,
589
+ y: - yDistanceFromViewCenter,
590
+ );
591
591
592
- // Top right point
593
- final latLngMax = BoundingBox .getLatLngFromMapUnits (
594
- referencePoint: centerViewPoint,
595
- x: xDistanceFromViewCenter,
596
- y: yDistanceFromViewCenter,
597
- );
592
+ // Top right point
593
+ final latLngMax = BoundingBox .getLatLngFromMapUnits (
594
+ referencePoint: centerViewPoint,
595
+ x: xDistanceFromViewCenter,
596
+ y: yDistanceFromViewCenter,
597
+ );
598
598
599
- controller.add (
600
- BoundingBox (
601
- height: newValue.height,
602
- width: newValue.width,
603
- lowerLeft: latLngMin,
604
- topRight: latLngMax,
605
- ),
606
- );
607
- }
608
- },
599
+ controller.add (
600
+ BoundingBox (
601
+ height: newValue.height,
602
+ width: newValue.width,
603
+ lowerLeft: latLngMin,
604
+ topRight: latLngMax,
605
+ ),
606
+ );
607
+ }
608
+ },
609
+ ),
609
610
);
610
611
611
612
return controller.stream;
0 commit comments