Skip to content

Commit c735cde

Browse files
committed
[Map] Deprecate option title from Polygon, Polyline, Rectangle and Circle in favor of infoWindow
While writing E2E tests for Map, I found that our `title` option from `Polygon`, `Polyline`, `Rectangle` and `Circle` was wrongly used, and does not make sense. Using `title` won't add an HTML attribute `title` as I expected, it's not something supported by Google nor Leaflet. Instead, we used it to display a popup, like the `infoWindow` (which is more complete). I suggest deprecating `title` from 2.x and remove it in 3.0.
1 parent cb9dc5b commit c735cde

File tree

15 files changed

+84
-47
lines changed

15 files changed

+84
-47
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,5 @@
2626
"tinyglobby": "^0.2.14",
2727
"tsup": "^8.5.0",
2828
"vitest": "^3.2.4"
29-
},
30-
"version": "2.27.0"
29+
}
3130
}

src/Map/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# CHANGELOG
22

3+
## 2.30
4+
5+
- Deprecate option `title` from `Polygon`, `Polyline`, `Rectangle` and `Circle` in favor of `infoWindow`
6+
37
## 2.29.0
48

59
- Add Symfony 8 support

src/Map/assets/src/abstract_map_controller.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export type MarkerDefinition<BridgeMarkerOptions, BridgeInfoWindowOptions> = Wit
6565
infoWindow?: Omit<InfoWindowDefinition<BridgeInfoWindowOptions>, 'position'>;
6666
icon?: Icon;
6767
/**
68-
* @deprecated Use "bridgeOptions" instead.
68+
* @deprecated since Symfony UX Map 2.27, use "bridgeOptions" instead.
6969
* Raw options passed to the marker constructor, specific to the map provider (e.g.: `L.marker()` for Leaflet).
7070
*/
7171
rawOptions?: BridgeMarkerOptions;
@@ -86,9 +86,12 @@ export type MarkerDefinition<BridgeMarkerOptions, BridgeInfoWindowOptions> = Wit
8686
export type PolygonDefinition<BridgePolygonOptions, BridgeInfoWindowOptions> = WithIdentifier<{
8787
infoWindow?: Omit<InfoWindowDefinition<BridgeInfoWindowOptions>, 'position'>;
8888
points: Array<Point> | Array<Array<Point>>;
89+
/**
90+
* @deprecated since Symfony UX Map 2.29, use "infoWindow" instead
91+
*/
8992
title: string | null;
9093
/**
91-
* @deprecated Use "bridgeOptions" instead.
94+
* @deprecated since Symfony UX Map 2.27, use "bridgeOptions" instead.
9295
* Raw options passed to the polygon constructor, specific to the map provider (e.g.: `L.polygon()` for Leaflet).
9396
*/
9497
rawOptions?: BridgePolygonOptions;
@@ -109,9 +112,12 @@ export type PolygonDefinition<BridgePolygonOptions, BridgeInfoWindowOptions> = W
109112
export type PolylineDefinition<BridgePolylineOptions, BridgeInfoWindowOptions> = WithIdentifier<{
110113
infoWindow?: Omit<InfoWindowDefinition<BridgeInfoWindowOptions>, 'position'>;
111114
points: Array<Point>;
115+
/**
116+
* @deprecated since Symfony UX Map 2.29, use "infoWindow" instead
117+
*/
112118
title: string | null;
113119
/**
114-
* @deprecated Use "bridgeOptions" instead.
120+
* @deprecated since Symfony UX Map 2.27, use "bridgeOptions" instead.
115121
* Raw options passed to the polyline constructor, specific to the map provider (e.g.: `L.polyline()` for Leaflet).
116122
*/
117123
rawOptions?: BridgePolylineOptions;
@@ -133,9 +139,12 @@ export type CircleDefinition<BridgeCircleOptions, BridgeInfoWindowOptions> = Wit
133139
infoWindow?: Omit<InfoWindowDefinition<BridgeInfoWindowOptions>, 'position'>;
134140
center: Point;
135141
radius: number;
142+
/**
143+
* @deprecated since Symfony UX Map 2.29, use "infoWindow" instead
144+
*/
136145
title: string | null;
137146
/**
138-
* @deprecated Use "bridgeOptions" instead.
147+
* @deprecated since Symfony UX Map 2.27, use "bridgeOptions" instead.
139148
* Raw options passed to the circle constructor, specific to the map provider (e.g.: `L.circle()` for Leaflet).
140149
*/
141150
rawOptions?: BridgeCircleOptions;
@@ -157,9 +166,12 @@ export type RectangleDefinition<BridgeRectangleOptions, BridgeInfoWindowOptions>
157166
infoWindow?: Omit<InfoWindowDefinition<BridgeInfoWindowOptions>, 'position'>;
158167
southWest: Point;
159168
northEast: Point;
169+
/**
170+
* @deprecated since Symfony UX Map 2.29, use "infoWindow" instead
171+
*/
160172
title: string | null;
161173
/**
162-
* @deprecated Use "bridgeOptions" instead.
174+
* @deprecated since Symfony UX Map 2.27, use "bridgeOptions" instead.
163175
* Raw options passed to the rectangle constructor, specific to the map provider (e.g.: `L.rectangle()` for Leaflet).
164176
*/
165177
rawOptions?: BridgeRectangleOptions;
@@ -184,7 +196,7 @@ export type InfoWindowDefinition<BridgeInfoWindowOptions> = {
184196
opened: boolean;
185197
autoClose: boolean;
186198
/**
187-
* @deprecated Use "bridgeOptions" instead.
199+
* @deprecated since Symfony UX Map 2.27, use "bridgeOptions" instead.
188200
* Raw options passed to the info window constructor, specific to the map provider (e.g.: `google.maps.InfoWindow()` for Google Maps).
189201
*/
190202
rawOptions?: BridgeInfoWindowOptions;

src/Map/doc/index.rst

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ You can add Circles, which represents a circular area defined by a center point
237237
$map->addCircle(new Circle(
238238
center: new Point(48.8566, 2.3522),
239239
radius: 5_000, // 5km
240-
title: 'Paris',
241240
infoWindow: new InfoWindow(
242241
content: 'A 5km radius circle centered on Paris',
243242
),
@@ -251,7 +250,6 @@ You can add Rectangles, which represents a rectangular area defined by two corne
251250
$map->addRectangle(new Rectangle(
252251
southWest: new Point(48.8566, 2.3522), // Paris
253252
northEast: new Point(50.6292, 3.0573), // Lille
254-
title: 'Paris to Lille',
255253
infoWindow: new InfoWindow(
256254
content: 'A rectangle from Paris to Lille',
257255
),
@@ -504,7 +502,7 @@ Symfony UX Map allows you to extend its default behavior using a custom Stimulus
504502
*/
505503
_onPolygonBeforeCreate(event) {
506504
console.log(event.detail.definition);
507-
// { title: 'My polygon', points: [ { lat: 48.8566, lng: 2.3522 }, { lat: 45.7640, lng: 4.8357 }, { lat: 43.2965, lng: 5.3698 }, ... ], ... }
505+
// { points: [ { lat: 48.8566, lng: 2.3522 }, { lat: 45.7640, lng: 4.8357 }, { lat: 43.2965, lng: 5.3698 }, ... ], ... }
508506
}
509507
510508
/**
@@ -522,7 +520,7 @@ Symfony UX Map allows you to extend its default behavior using a custom Stimulus
522520
*/
523521
_onPolylineBeforeCreate(event) {
524522
console.log(event.detail.definition);
525-
// { title: 'My polyline', points: [ { lat: 48.8566, lng: 2.3522 }, { lat: 45.7640, lng: 4.8357 }, { lat: 43.2965, lng: 5.3698 }, ... ], ... }
523+
// { points: [ { lat: 48.8566, lng: 2.3522 }, { lat: 45.7640, lng: 4.8357 }, { lat: 43.2965, lng: 5.3698 }, ... ], ... }
526524
}
527525
528526
/**
@@ -536,7 +534,7 @@ Symfony UX Map allows you to extend its default behavior using a custom Stimulus
536534
537535
_onCircleBeforeCreate(event) {
538536
console.log(event.detail.definition);
539-
// { title: 'My circle', center: { lat: 48.8566, lng: 2.3522 }, radius: 1000, ... }
537+
// { center: { lat: 48.8566, lng: 2.3522 }, radius: 1000, ... }
540538
}
541539
542540
_onCircleAfterCreate(event) {
@@ -546,7 +544,7 @@ Symfony UX Map allows you to extend its default behavior using a custom Stimulus
546544
547545
_onRectangleBeforeCreate(event) {
548546
console.log(event.detail.definition);
549-
// { title: 'My rectangle', southWest: { lat: 48.8566, lng: 2.3522 }, northEast: { lat: 45.7640, lng: 4.8357 }, ... }
547+
// { southWest: { lat: 48.8566, lng: 2.3522 }, northEast: { lat: 45.7640, lng: 4.8357 }, ... }
550548
}
551549
552550
_onRectangleAfterCreate(event) {

src/Map/src/Bridge/Google/assets/src/map_controller.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,9 @@ export default class extends AbstractMapController<
212212
...bridgeOptions,
213213
});
214214

215+
/**
216+
* @deprecated since Symfony UX Map 2.29, will be removed in 3.0
217+
*/
215218
if (title) {
216219
polygon.set('title', title);
217220
}
@@ -241,6 +244,9 @@ export default class extends AbstractMapController<
241244
...bridgeOptions,
242245
});
243246

247+
/**
248+
* @deprecated since Symfony UX Map 2.29, will be removed in 3.0
249+
*/
244250
if (title) {
245251
polyline.set('title', title);
246252
}
@@ -267,6 +273,9 @@ export default class extends AbstractMapController<
267273
...bridgeOptions,
268274
});
269275

276+
/**
277+
* @deprecated since Symfony UX Map 2.29, will be removed in 3.0
278+
*/
270279
if (title) {
271280
circle.set('title', title);
272281
}
@@ -296,6 +305,9 @@ export default class extends AbstractMapController<
296305
...bridgeOptions,
297306
});
298307

308+
/**
309+
* @deprecated since Symfony UX Map 2.29, will be removed in 3.0
310+
*/
299311
if (title) {
300312
rectangle.set('title', title);
301313
}

src/Map/src/Bridge/Leaflet/assets/src/map_controller.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ export default class extends AbstractMapController<
169169

170170
const polygon = L.polygon(points, { ...rawOptions, ...bridgeOptions }).addTo(this.map);
171171

172+
/**
173+
* @deprecated since Symfony UX Map 2.29
174+
*/
172175
if (title) {
173176
polygon.bindPopup(title);
174177
}
@@ -189,6 +192,9 @@ export default class extends AbstractMapController<
189192

190193
const polyline = L.polyline(points, { ...rawOptions, ...bridgeOptions }).addTo(this.map);
191194

195+
/**
196+
* @deprecated since Symfony UX Map 2.29
197+
*/
192198
if (title) {
193199
polyline.bindPopup(title);
194200
}
@@ -209,6 +215,9 @@ export default class extends AbstractMapController<
209215

210216
const circle = L.circle(center, { radius, ...rawOptions, ...bridgeOptions }).addTo(this.map);
211217

218+
/**
219+
* @deprecated since Symfony UX Map 2.29
220+
*/
212221
if (title) {
213222
circle.bindPopup(title);
214223
}
@@ -235,6 +244,9 @@ export default class extends AbstractMapController<
235244
{ ...rawOptions, ...bridgeOptions }
236245
).addTo(this.map);
237246

247+
/**
248+
* @deprecated since Symfony UX Map 2.29
249+
*/
238250
if (title) {
239251
rectangle.bindPopup(title);
240252
}

src/Map/src/Circle.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ public function __construct(
3434
public readonly array $extra = [],
3535
public readonly ?string $id = null,
3636
) {
37+
if (null !== $title) {
38+
trigger_deprecation('symfony/ux-map', '2.30', 'The "title" parameter is deprecated and will be removed in 3.0. Use "infoWindow" instead.');
39+
}
40+
3741
if ($radius <= 0) {
3842
throw new InvalidArgumentException(\sprintf('Radius must be greater than 0, "%s" given.', $radius));
3943
}

src/Map/src/Polygon.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ public function __construct(
3333
private readonly array $extra = [],
3434
public readonly ?string $id = null,
3535
) {
36+
if (null !== $title) {
37+
trigger_deprecation('symfony/ux-map', '2.30', 'The "title" parameter is deprecated and will be removed in 3.0. Use "infoWindow" instead.');
38+
}
3639
}
3740

3841
/**

src/Map/src/Polyline.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ public function __construct(
3232
private readonly array $extra = [],
3333
public readonly ?string $id = null,
3434
) {
35+
if (null !== $title) {
36+
trigger_deprecation('symfony/ux-map', '2.30', 'The "title" parameter is deprecated and will be removed in 3.0. Use "infoWindow" instead.');
37+
}
3538
}
3639

3740
/**

src/Map/src/Rectangle.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ public function __construct(
3333
public readonly array $extra = [],
3434
public readonly ?string $id = null,
3535
) {
36+
if (null !== $title) {
37+
trigger_deprecation('symfony/ux-map', '2.30', 'The "title" parameter is deprecated and will be removed in 3.0. Use "infoWindow" instead.');
38+
}
3639
}
3740

3841
/**

0 commit comments

Comments
 (0)