@@ -247,12 +247,14 @@ It's useful when :ref:`using a Map inside a Live Component <map-live-component>`
247
247
$map->addPolygon($polygon = new Polygon(/* ... */));
248
248
$map->addPolyline($polyline = new Polyline(/* ... */));
249
249
$map->addCircle($circle = new Circle(/* ... */));
250
+ $map->addRectangle($rectangle = new Rectangle(/* ... */));
250
251
251
252
// And later, remove those elements
252
253
$map->removeMarker($marker);
253
254
$map->removePolygon($polygon);
254
255
$map->removePolyline($polyline);
255
256
$map->removeCircle($circle);
257
+ $map->removeRectangle($rectangle);
256
258
257
259
If you haven't stored the element instance, you can still remove them by passing the identifier string::
258
260
@@ -261,11 +263,15 @@ If you haven't stored the element instance, you can still remove them by passing
261
263
$map->addMarker(new Marker(id: 'my-marker', /* ... */));
262
264
$map->addPolygon(new Polygon(id: 'my-polygon', /* ... */));
263
265
$map->addPolyline(new Polyline(id: 'my-marker', /* ... */));
266
+ $map->addCircle(new Circle(id: 'my-circle', /* ... */));
267
+ $map->addRectangle(new Rectangle(id: 'my-rectangle', /* ... */));
264
268
265
269
// And later, remove those elements
266
270
$map->removeMarker('my-marker');
267
271
$map->removePolygon('my-polygon');
268
272
$map->removePolyline('my-marker');
273
+ $map->removeCircle('my-circle');
274
+ $map->removeRectangle('my-rectangle');
269
275
270
276
Render a map
271
277
------------
@@ -417,6 +423,8 @@ Symfony UX Map allows you to extend its default behavior using a custom Stimulus
417
423
console .log (event .detail .infoWindows );
418
424
console .log (event .detail .polygons );
419
425
console .log (event .detail .polylines );
426
+ console .log (event .detail .circles );
427
+ console .log (event .detail .rectangles );
420
428
}
421
429
422
430
/**
@@ -671,12 +679,23 @@ For greater customization and extensibility, you can pass additional data from P
671
679
to the Stimulus controller. This can be useful when associating extra information
672
680
with a specific marker; for example, indicating the type of location it represents.
673
681
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
675
683
only forwards them to the Stimulus controller.
676
684
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
+
679
693
694
+ $map = new Map(extra: ['foo' => 'bar']);
695
+ // or
696
+ $map->extra(['foo' => 'bar']);
697
+
698
+ // And for other elements, like Marker, InfoWindow, etc.
680
699
$map->addMarker(new Marker(
681
700
position: new Point(48.822248, 2.337338),
682
701
title: 'Paris - Parc Montsouris',
@@ -686,65 +705,30 @@ available in ``Marker``, ``InfoWindow``, ``Polygon``, ``Polyline``, ``Circle`` a
686
705
],
687
706
));
688
707
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::
692
710
693
711
.. code-block :: javascript
694
712
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 );
714
716
}
715
717
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
+ }
735
721
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
+ }
737
726
738
- _onPreConnect (event ) {
739
- console .log (event .detail .extra );
740
- // { foo: 'bar', ... }
741
- }
727
+ _onMarkerAfterCreate (event ) {
728
+ console .log (event .detail .definition .extra );
729
+ }
742
730
743
- _onConnect (event ) {
744
- console .log (event .detail .extra );
745
- // { foo: 'bar', ... }
746
- }
747
- }
731
+ // etc...
748
732
749
733
.. _map-live-component :
750
734
0 commit comments