@@ -362,6 +362,10 @@ Symfony UX Map allows you to extend its default behavior using a custom Stimulus
362
362
this .element .addEventListener (' ux:map:polygon:after-create' , this ._onPolygonAfterCreate );
363
363
this .element .addEventListener (' ux:map:polyline:before-create' , this ._onPolylineBeforeCreate );
364
364
this .element .addEventListener (' ux:map:polyline:after-create' , this ._onPolylineAfterCreate );
365
+ this .element .addEventListener (' ux:map:circle:before-create' , this ._onCircleBeforeCreate );
366
+ this .element .addEventListener (' ux:map:circle:after-create' , this ._onCircleAfterCreate );
367
+ this .element .addEventListener (' ux:map:rectangle:before-create' , this ._onRectangleBeforeCreate );
368
+ this .element .addEventListener (' ux:map:rectangle:after-create' , this ._onRectangleAfterCreate );
365
369
}
366
370
367
371
disconnect () {
@@ -376,6 +380,10 @@ Symfony UX Map allows you to extend its default behavior using a custom Stimulus
376
380
this .element .removeEventListener (' ux:map:polygon:after-create' , this ._onPolygonAfterCreate );
377
381
this .element .removeEventListener (' ux:map:polyline:before-create' , this ._onPolylineBeforeCreate );
378
382
this .element .removeEventListener (' ux:map:polyline:after-create' , this ._onPolylineAfterCreate );
383
+ this .element .removeEventListener (' ux:map:circle:before-create' , this ._onCircleBeforeCreate );
384
+ this .element .removeEventListener (' ux:map:circle:after-create' , this ._onCircleAfterCreate );
385
+ this .element .removeEventListener (' ux:map:rectangle:before-create' , this ._onRectangleBeforeCreate );
386
+ this .element .removeEventListener (' ux:map:rectangle:after-create' , this ._onRectangleAfterCreate );
379
387
}
380
388
381
389
/**
@@ -386,6 +394,7 @@ Symfony UX Map allows you to extend its default behavior using a custom Stimulus
386
394
// You can read or write the zoom level
387
395
console .log (event .detail .zoom );
388
396
397
+ // You can read or write the center of the map
389
398
console .log (event .detail .center );
390
399
391
400
// You can read or write map options, specific to the Bridge, it represents the normalized `*Options` PHP class (e.g. `GoogleOptions`, `LeafletOptions`)
@@ -454,6 +463,10 @@ Symfony UX Map allows you to extend its default behavior using a custom Stimulus
454
463
console .log (event .detail .polygon );
455
464
// ... or a polyline
456
465
console .log (event .detail .polyline );
466
+ // ... or a circle
467
+ console .log (event .detail .circle );
468
+ // ... or a rectangle
469
+ console .log (event .detail .rectangle );
457
470
}
458
471
459
472
/**
@@ -491,6 +504,26 @@ Symfony UX Map allows you to extend its default behavior using a custom Stimulus
491
504
// The polyline instance
492
505
console .log (event .detail .polyline );
493
506
}
507
+
508
+ _onCircleBeforeCreate (event ) {
509
+ console .log (event .detail .definition );
510
+ // { title: 'My circle', center: { lat: 48.8566, lng: 2.3522 }, radius: 1000, ... }
511
+ }
512
+
513
+ _onCircleAfterCreate (event ) {
514
+ // The circle instance
515
+ console .log (event .detail .circle );
516
+ }
517
+
518
+ _onRectangleBeforeCreate (event ) {
519
+ console .log (event .detail .definition );
520
+ // { title: 'My rectangle', southWest: { lat: 48.8566, lng: 2.3522 }, northEast: { lat: 45.7640, lng: 4.8357 }, ... }
521
+ }
522
+
523
+ _onRectangleAfterCreate (event ) {
524
+ // The rectangle instance
525
+ console .log (event .detail .rectangle );
526
+ }
494
527
}
495
528
496
529
Then, you can use this controller in your template:
@@ -533,6 +566,17 @@ events ``ux:map:*:before-create`` using the special ``bridgeOptions`` property:
533
566
this .element .addEventListener (' ux:map:info-window:before-create' , this ._onInfoWindowBeforeCreate );
534
567
this .element .addEventListener (' ux:map:polygon:before-create' , this ._onPolygonBeforeCreate );
535
568
this .element .addEventListener (' ux:map:polyline:before-create' , this ._onPolylineBeforeCreate );
569
+ this .element .addEventListener (' ux:map:circle:before-create' , this ._onCircleBeforeCreate );
570
+ this .element .addEventListener (' ux:map:rectangle:before-create' , this ._onRectangleBeforeCreate );
571
+ }
572
+
573
+ disconnect () {
574
+ this .element .removeEventListener (' ux:map:marker:before-create' , this ._onMarkerBeforeCreate );
575
+ this .element .removeEventListener (' ux:map:info-window:before-create' , this ._onInfoWindowBeforeCreate );
576
+ this .element .removeEventListener (' ux:map:polygon:before-create' , this ._onPolygonBeforeCreate );
577
+ this .element .removeEventListener (' ux:map:polyline:before-create' , this ._onPolylineBeforeCreate );
578
+ this .element .removeEventListener (' ux:map:circle:before-create' , this ._onCircleBeforeCreate );
579
+ this .element .removeEventListener (' ux:map:rectangle:before-create' , this ._onRectangleBeforeCreate );
536
580
}
537
581
538
582
_onMarkerBeforeCreate (event ) {
@@ -590,6 +634,34 @@ events ``ux:map:*:before-create`` using the special ``bridgeOptions`` property:
590
634
// ...
591
635
};
592
636
}
637
+
638
+ _onCircleBeforeCreate (event ) {
639
+ // When using Google Maps, to configure a `google.maps.Circle`
640
+ event .detail .definition .bridgeOptions = {
641
+ strokeColor: ' red' ,
642
+ // ...
643
+ };
644
+
645
+ // When using Leaflet, to configure a `L.Circle`
646
+ event .detail .definition .bridgeOptions = {
647
+ color: ' red' ,
648
+ // ...
649
+ };
650
+ }
651
+
652
+ _onRectangleBeforeCreate (event ) {
653
+ // When using Google Maps, to configure a `google.maps.Rectangle`
654
+ event .detail .definition .bridgeOptions = {
655
+ strokeColor: ' red' ,
656
+ // ...
657
+ };
658
+
659
+ // When using Leaflet, to configure a `L.Rectangle`
660
+ event .detail .definition .bridgeOptions = {
661
+ color: ' red' ,
662
+ // ...
663
+ };
664
+ }
593
665
}
594
666
595
667
Advanced: Passing extra data from PHP to the Stimulus controller
@@ -603,7 +675,7 @@ These additional data points are defined and used exclusively by you; UX Map
603
675
only forwards them to the Stimulus controller.
604
676
605
677
To pass extra data from PHP to the Stimulus controller, you must use the ``extra `` property
606
- available in ``Marker ``, ``InfoWindow ``, ``Polygon `` and ``Polyline `` instances::
678
+ available in ``Marker ``, ``InfoWindow ``, ``Polygon ``, `` Polyline ``, `` Circle `` and ``Rectangle `` instances::
607
679
608
680
$map->addMarker(new Marker(
609
681
position: new Point(48.822248, 2.337338),
0 commit comments