@@ -247,12 +247,14 @@ It's useful when :ref:`using a Map inside a Live Component <map-live-component>`
247247 $map->addPolygon($polygon = new Polygon(/* ... */));
248248 $map->addPolyline($polyline = new Polyline(/* ... */));
249249 $map->addCircle($circle = new Circle(/* ... */));
250+ $map->addRectangle($rectangle = new Rectangle(/* ... */));
250251
251252 // And later, remove those elements
252253 $map->removeMarker($marker);
253254 $map->removePolygon($polygon);
254255 $map->removePolyline($polyline);
255256 $map->removeCircle($circle);
257+ $map->removeRectangle($rectangle);
256258
257259If you haven't stored the element instance, you can still remove them by passing the identifier string::
258260
@@ -261,11 +263,15 @@ If you haven't stored the element instance, you can still remove them by passing
261263 $map->addMarker(new Marker(id: 'my-marker', /* ... */));
262264 $map->addPolygon(new Polygon(id: 'my-polygon', /* ... */));
263265 $map->addPolyline(new Polyline(id: 'my-marker', /* ... */));
266+ $map->addCircle(new Circle(id: 'my-circle', /* ... */));
267+ $map->addRectangle(new Rectangle(id: 'my-rectangle', /* ... */));
264268
265269 // And later, remove those elements
266270 $map->removeMarker('my-marker');
267271 $map->removePolygon('my-polygon');
268272 $map->removePolyline('my-marker');
273+ $map->removeCircle('my-circle');
274+ $map->removeRectangle('my-rectangle');
269275
270276Render a map
271277------------
@@ -417,6 +423,8 @@ Symfony UX Map allows you to extend its default behavior using a custom Stimulus
417423 console .log (event .detail .infoWindows );
418424 console .log (event .detail .polygons );
419425 console .log (event .detail .polylines );
426+ console .log (event .detail .circles );
427+ console .log (event .detail .rectangles );
420428 }
421429
422430 /**
@@ -671,12 +679,23 @@ For greater customization and extensibility, you can pass additional data from P
671679to the Stimulus controller. This can be useful when associating extra information
672680with a specific marker; for example, indicating the type of location it represents.
673681
674- These additional data points are defined and used exclusively by you; UX Map
682+ These additional data are defined and used exclusively by you; UX Map
675683only forwards them to the Stimulus controller.
676684
677- To pass extra data from PHP to the Stimulus controller, you must use the ``extra `` property
678- available in ``Marker ``, ``InfoWindow ``, ``Polygon ``, ``Polyline ``, ``Circle `` and ``Rectangle `` instances::
685+ .. versionadded :: 2.27
686+
687+ The ability to pass extra data to ``Map `` class was added in UX Map 2.27.
688+
689+ To pass extra data from PHP to the Stimulus controller, you must use the ``extra ``
690+ property available in ``Map ``, ``Marker ``, ``InfoWindow ``, ``Polygon ``, ``Polyline ``,
691+ ``Circle `` and ``Rectangle ``::
692+
679693
694+ $map = new Map(extra: ['foo' => 'bar']);
695+ // or
696+ $map->extra(['foo' => 'bar']);
697+
698+ // And for other elements, like Marker, InfoWindow, etc.
680699 $map->addMarker(new Marker(
681700 position: new Point(48.822248, 2.337338),
682701 title: 'Paris - Parc Montsouris',
@@ -686,65 +705,30 @@ available in ``Marker``, ``InfoWindow``, ``Polygon``, ``Polyline``, ``Circle`` a
686705 ],
687706 ));
688707
689- On the JavaScript side, you can access your extra data via the
690- ``event.detail.definition.extra `` object, available in the
691- ``ux:map:*:before-create `` and ``ux:map:*:after-create `` events:
708+ On the JavaScript side, you can access these extra data by listening to ``ux:map:pre-connect ``,
709+ ``ux:map:connect ``, ``ux:map:*:before-create ``, ``ux:map:*:after-create `` events::
692710
693711.. code-block :: javascript
694712
695- // assets/controllers/mymap_controller.js
696-
697- import { Controller } from ' @hotwired/stimulus' ;
698-
699- export default class extends Controller {
700-
701- // ...
702-
703- _onMarkerBeforeCreate (event ) {
704- console .log (event .detail .definition .extra );
705- // { type: 'Park', ...}
706- }
707-
708- _onMarkerAfterCreate (event ) {
709- console .log (event .detail .definition .extra );
710- // { type: 'Park', ...}
711- }
712-
713- // ...
713+ // Access extra data from the `Map` instance, through `event.detail.extra`
714+ _onPreConnect (event ) {
715+ console .log (event .detail .extra );
714716 }
715717
716- .. versionadded :: 2.27
717-
718- The ``Map `` class now has an ``extra `` property, which can be accessed in the ``ux:map:pre-connect `` and ``ux:map:connect `` events::
719-
720- $map = new Map(/* ... */, extra: [
721- 'foo' => 'bar',
722- ]);
723- // or
724- $map->extra([
725- 'foo' => 'bar',
726- ]);
727-
728- .. code-block :: javascript
729-
730- // assets/controllers/mymap_controller.js
731-
732- import { Controller } from ' @hotwired/stimulus' ;
733-
734- export default class extends Controller {
718+ _onConnect (event ) {
719+ console .log (event .detail .extra );
720+ }
735721
736- // ...
722+ // Access extra data from the `Marker` (and other elements) instance, through `event.detail.definition.extra`
723+ _onMarkerBeforeCreate (event ) {
724+ console .log (event .detail .definition .extra );
725+ }
737726
738- _onPreConnect (event ) {
739- console .log (event .detail .extra );
740- // { foo: 'bar', ... }
741- }
727+ _onMarkerAfterCreate (event ) {
728+ console .log (event .detail .definition .extra );
729+ }
742730
743- _onConnect (event ) {
744- console .log (event .detail .extra );
745- // { foo: 'bar', ... }
746- }
747- }
731+ // etc...
748732
749733 .. _map-live-component :
750734
0 commit comments