Skip to content

Commit a28ad51

Browse files
committed
feature #3036 [Map] Deprecate option title from Polygon, Polyline, Rectangle and Circle in favor of infoWindow (Kocal)
This PR was merged into the 2.x branch. Discussion ---------- [Map] Deprecate option `title` from `Polygon`, `Polyline`, `Rectangle` and `Circle` in favor of `infoWindow` | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes <!-- please update src/**/CHANGELOG.md files --> | Docs? | no <!-- required for new features --> | Issues | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT <!-- Replace this notice by a description of your feature/bugfix. This will help reviewers and should be a good start for the documentation. Additionally (see https://symfony.com/releases): - Always add tests and ensure they pass. - For new features, provide some code snippets to help understand usage. - Features and deprecations must be submitted against branch main. - Update/add documentation as required (we can help!) - Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry - Never break backward compatibility (see https://symfony.com/bc). --> 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. Commits ------- ae8b7f9 [Map] Deprecate option `title` from `Polygon`, `Polyline`, `Rectangle` and `Circle` in favor of `infoWindow`
2 parents cb9dc5b + ae8b7f9 commit a28ad51

18 files changed

+87
-51
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/Bridge/Leaflet/tests/LeafletRendererTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public static function provideTestRenderMap(): iterable
103103
'map' => (new Map())
104104
->center(new Point(48.8566, 2.3522))
105105
->zoom(12)
106-
->addCircle(new Circle(center: new Point(48.8566, 2.3522), radius: 1000000, title: 'Paris', id: 'circle1'))
106+
->addCircle(new Circle(center: new Point(48.8566, 2.3522), radius: 1000000, id: 'circle1'))
107107
->addCircle(new Circle(center: new Point(1.1, 2.2), radius: 500, infoWindow: new InfoWindow(content: 'Circle'), id: 'circle2')),
108108
];
109109

@@ -115,7 +115,6 @@ public static function provideTestRenderMap(): iterable
115115
->addRectangle(new Rectangle(
116116
southWest: new Point(48.8566, 2.3522),
117117
northEast: new Point(48.8566, 2.3522),
118-
title: 'Rectangle',
119118
id: 'rectangle1'
120119
))
121120
->addRectangle(new Rectangle(

src/Map/src/Bridge/Leaflet/tests/__snapshots__/LeafletRendererTest__testRenderMap with data set with circles and infoWindows__1.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
data-symfony--ux-leaflet-map--map-markers-value="[]"
1111
data-symfony--ux-leaflet-map--map-polygons-value="[]"
1212
data-symfony--ux-leaflet-map--map-polylines-value="[]"
13-
data-symfony--ux-leaflet-map--map-circles-value="[{&quot;center&quot;:{&quot;lat&quot;:48.8566,&quot;lng&quot;:2.3522},&quot;radius&quot;:1000000,&quot;title&quot;:&quot;Paris&quot;,&quot;infoWindow&quot;:null,&quot;extra&quot;:[],&quot;id&quot;:&quot;circle1&quot;,&quot;@id&quot;:&quot;b12929e5dc57d558&quot;},{&quot;center&quot;:{&quot;lat&quot;:1.1,&quot;lng&quot;:2.2},&quot;radius&quot;:500,&quot;title&quot;:null,&quot;infoWindow&quot;:{&quot;headerContent&quot;:null,&quot;content&quot;:&quot;Circle&quot;,&quot;position&quot;:null,&quot;opened&quot;:false,&quot;autoClose&quot;:true,&quot;extra&quot;:[]},&quot;extra&quot;:[],&quot;id&quot;:&quot;circle2&quot;,&quot;@id&quot;:&quot;4953b5cc1d5759f4&quot;}]"
13+
data-symfony--ux-leaflet-map--map-circles-value="[{&quot;center&quot;:{&quot;lat&quot;:48.8566,&quot;lng&quot;:2.3522},&quot;radius&quot;:1000000,&quot;title&quot;:null,&quot;infoWindow&quot;:null,&quot;extra&quot;:[],&quot;id&quot;:&quot;circle1&quot;,&quot;@id&quot;:&quot;ead7389af3a04828&quot;},{&quot;center&quot;:{&quot;lat&quot;:1.1,&quot;lng&quot;:2.2},&quot;radius&quot;:500,&quot;title&quot;:null,&quot;infoWindow&quot;:{&quot;headerContent&quot;:null,&quot;content&quot;:&quot;Circle&quot;,&quot;position&quot;:null,&quot;opened&quot;:false,&quot;autoClose&quot;:true,&quot;extra&quot;:[]},&quot;extra&quot;:[],&quot;id&quot;:&quot;circle2&quot;,&quot;@id&quot;:&quot;4953b5cc1d5759f4&quot;}]"
1414
data-symfony--ux-leaflet-map--map-rectangles-value="[]"
1515
></div>

src/Map/src/Bridge/Leaflet/tests/__snapshots__/LeafletRendererTest__testRenderMap with data set with rectangles and infoWindows__1.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
data-symfony--ux-leaflet-map--map-polygons-value="[]"
1212
data-symfony--ux-leaflet-map--map-polylines-value="[]"
1313
data-symfony--ux-leaflet-map--map-circles-value="[]"
14-
data-symfony--ux-leaflet-map--map-rectangles-value="[{&quot;southWest&quot;:{&quot;lat&quot;:48.8566,&quot;lng&quot;:2.3522},&quot;northEast&quot;:{&quot;lat&quot;:48.8566,&quot;lng&quot;:2.3522},&quot;title&quot;:&quot;Rectangle&quot;,&quot;infoWindow&quot;:null,&quot;extra&quot;:[],&quot;id&quot;:&quot;rectangle1&quot;,&quot;@id&quot;:&quot;4cde1a021a127686&quot;},{&quot;southWest&quot;:{&quot;lat&quot;:1.1,&quot;lng&quot;:2.2},&quot;northEast&quot;:{&quot;lat&quot;:3.3,&quot;lng&quot;:4.4},&quot;title&quot;:null,&quot;infoWindow&quot;:{&quot;headerContent&quot;:null,&quot;content&quot;:&quot;Rectangle&quot;,&quot;position&quot;:null,&quot;opened&quot;:false,&quot;autoClose&quot;:true,&quot;extra&quot;:[]},&quot;extra&quot;:[],&quot;id&quot;:&quot;rectangle2&quot;,&quot;@id&quot;:&quot;2549f5a73ef6bee7&quot;}]"
14+
data-symfony--ux-leaflet-map--map-rectangles-value="[{&quot;southWest&quot;:{&quot;lat&quot;:48.8566,&quot;lng&quot;:2.3522},&quot;northEast&quot;:{&quot;lat&quot;:48.8566,&quot;lng&quot;:2.3522},&quot;title&quot;:null,&quot;infoWindow&quot;:null,&quot;extra&quot;:[],&quot;id&quot;:&quot;rectangle1&quot;,&quot;@id&quot;:&quot;2ee3f2ebdef84b13&quot;},{&quot;southWest&quot;:{&quot;lat&quot;:1.1,&quot;lng&quot;:2.2},&quot;northEast&quot;:{&quot;lat&quot;:3.3,&quot;lng&quot;:4.4},&quot;title&quot;:null,&quot;infoWindow&quot;:{&quot;headerContent&quot;:null,&quot;content&quot;:&quot;Rectangle&quot;,&quot;position&quot;:null,&quot;opened&quot;:false,&quot;autoClose&quot;:true,&quot;extra&quot;:[]},&quot;extra&quot;:[],&quot;id&quot;:&quot;rectangle2&quot;,&quot;@id&quot;:&quot;2549f5a73ef6bee7&quot;}]"
1515
></div>

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
}

0 commit comments

Comments
 (0)