@@ -362,6 +362,10 @@ Symfony UX Map allows you to extend its default behavior using a custom Stimulus
362362 this .element .addEventListener (' ux:map:polygon:after-create' , this ._onPolygonAfterCreate );
363363 this .element .addEventListener (' ux:map:polyline:before-create' , this ._onPolylineBeforeCreate );
364364 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 );
365369 }
366370
367371 disconnect () {
@@ -376,6 +380,10 @@ Symfony UX Map allows you to extend its default behavior using a custom Stimulus
376380 this .element .removeEventListener (' ux:map:polygon:after-create' , this ._onPolygonAfterCreate );
377381 this .element .removeEventListener (' ux:map:polyline:before-create' , this ._onPolylineBeforeCreate );
378382 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 );
379387 }
380388
381389 /**
@@ -386,6 +394,7 @@ Symfony UX Map allows you to extend its default behavior using a custom Stimulus
386394 // You can read or write the zoom level
387395 console .log (event .detail .zoom );
388396
397+ // You can read or write the center of the map
389398 console .log (event .detail .center );
390399
391400 // 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
454463 console .log (event .detail .polygon );
455464 // ... or a polyline
456465 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 );
457470 }
458471
459472 /**
@@ -491,6 +504,26 @@ Symfony UX Map allows you to extend its default behavior using a custom Stimulus
491504 // The polyline instance
492505 console .log (event .detail .polyline );
493506 }
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+ }
494527 }
495528
496529 Then, you can use this controller in your template:
@@ -533,6 +566,17 @@ events ``ux:map:*:before-create`` using the special ``bridgeOptions`` property:
533566 this .element .addEventListener (' ux:map:info-window:before-create' , this ._onInfoWindowBeforeCreate );
534567 this .element .addEventListener (' ux:map:polygon:before-create' , this ._onPolygonBeforeCreate );
535568 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 );
536580 }
537581
538582 _onMarkerBeforeCreate (event ) {
@@ -590,6 +634,34 @@ events ``ux:map:*:before-create`` using the special ``bridgeOptions`` property:
590634 // ...
591635 };
592636 }
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+ }
593665 }
594666
595667 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
603675only forwards them to the Stimulus controller.
604676
605677To 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::
607679
608680 $map->addMarker(new Marker(
609681 position: new Point(48.822248, 2.337338),
0 commit comments