You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/Map/CHANGELOG.md
+21-1Lines changed: 21 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,27 @@
2
2
3
3
## 2.26
4
4
5
-
- Add MultiPolygon support. A MultiPolygon allows you to represent multiple polygons (possibly with holes or separate areas) as a single map element. See documentation for usage.
5
+
- Add support for creating `Polygon` with holes, by passing an array of `array<Point>` as `points` parameter to the `Polygon` constructor, e.g.:
6
+
```php
7
+
// Draw a polygon with a hole in it, on the French map
8
+
$map->addPolygon(new Polygon(points: [
9
+
// First path, the outer boundary of the polygon
10
+
[
11
+
new Point(48.117266, -1.677792), // Rennes
12
+
new Point(50.629250, 3.057256), // Lille
13
+
new Point(48.573405, 7.752111), // Strasbourg
14
+
new Point(43.296482, 5.369780), // Marseille
15
+
new Point(44.837789, -0.579180), // Bordeaux
16
+
],
17
+
// Second path, it will make a hole in the previous one
Copy file name to clipboardExpand all lines: src/Map/doc/index.rst
+24-22Lines changed: 24 additions & 22 deletions
Original file line number
Diff line number
Diff line change
@@ -71,7 +71,7 @@ Start by creating a new map instance::
71
71
use Symfony\UX\Map\Map;
72
72
73
73
// Create a new map instance
74
-
$myMap = (new Map());
74
+
$map = new Map();
75
75
76
76
Center and zoom
77
77
~~~~~~~~~~~~~~~
@@ -81,7 +81,7 @@ You can set the center and zoom of the map using the ``center()`` and ``zoom()``
81
81
use Symfony\UX\Map\Map;
82
82
use Symfony\UX\Map\Point;
83
83
84
-
$myMap
84
+
$map
85
85
// Explicitly set the center and zoom
86
86
->center(new Point(46.903354, 1.888334))
87
87
->zoom(6)
@@ -95,7 +95,7 @@ Add markers
95
95
96
96
You can add markers to a map using the ``addMarker()`` method::
97
97
98
-
$myMap
98
+
$map
99
99
->addMarker(new Marker(
100
100
position: new Point(48.8566, 2.3522),
101
101
title: 'Paris'
@@ -154,7 +154,7 @@ Add Polygons
154
154
155
155
You can also add Polygons, which represents an area enclosed by a series of ``Point`` instances::
156
156
157
-
$myMap->addPolygon(new Polygon(
157
+
$map->addPolygon(new Polygon(
158
158
points: [
159
159
new Point(48.8566, 2.3522),
160
160
new Point(45.7640, 4.8357),
@@ -168,33 +168,35 @@ You can also add Polygons, which represents an area enclosed by a series of ``Po
168
168
169
169
.. versionadded:: 2.26
170
170
171
-
``MultiPolygon`` is available since UX Map 2.26.
171
+
`Polygon` with holes is available since UX Map 2.26.
172
172
173
-
You can also add a MultiPolygon. A MultiPolygon allows you to represent multiple polygons (possibly with holes or separate areas) as a single map element::
173
+
Since UX Map 2.26, you can also create polygons with holes in them, by passing an array of `array<Point>` to `points` parameter::
174
174
175
-
$myMap->addPolygon(new Polygon(
176
-
points: [
177
-
[
178
-
new Point(-180, 90),
179
-
new Point(180, 90),
180
-
new Point(180, -90),
181
-
new Point(-180, -90),
182
-
],
183
-
[
184
-
new Point(48.8566, 2.3522),
185
-
new Point(45.7640, 4.8357),
186
-
new Point(43.2965, 5.3698),
187
-
new Point(44.8378, -0.5792),
188
-
]
175
+
// Draw a polygon with a hole in it, on the French map
176
+
$map->addPolygon(new Polygon(points: [
177
+
// First path, the outer boundary of the polygon
178
+
[
179
+
new Point(48.117266, -1.677792), // Rennes
180
+
new Point(50.629250, 3.057256), // Lille
181
+
new Point(48.573405, 7.752111), // Strasbourg
182
+
new Point(43.296482, 5.369780), // Marseille
183
+
new Point(44.837789, -0.579180), // Bordeaux
189
184
],
190
-
));
185
+
// Second path, it will make a hole in the previous one
186
+
[
187
+
new Point(45.833619, 1.261105), // Limoges
188
+
new Point(45.764043, 4.835659), // Lyon
189
+
new Point(49.258329, 4.031696), // Reims
190
+
new Point(48.856613, 2.352222), // Paris
191
+
],
192
+
]));
191
193
192
194
Add Polylines
193
195
~~~~~~~~~~~~~
194
196
195
197
You can add Polylines, which represents a path made by a series of ``Point`` instances::
Copy file name to clipboardExpand all lines: src/Map/src/Polygon.php
+9-6Lines changed: 9 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -21,8 +21,8 @@
21
21
finalclass Polygon implements Element
22
22
{
23
23
/**
24
-
* @param array<array<Point>|array<array<Point>>> $points Points of the polygon. Each point can be a single Point or an array of Points.
25
-
* @param array<string, mixed> $extra Extra data, can be used by the developer to store additional information and use them later JavaScript side
24
+
* @param array<Point>|array<array<Point>> $points A list of point representing the polygon, or a list of paths (each path is an array of points) representing a polygon with holes.
25
+
* @param array<string, mixed> $extra Extra data, can be used by the developer to store additional information and use them later JavaScript side
0 commit comments