Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,5 @@
"tinyglobby": "^0.2.14",
"tsup": "^8.5.0",
"vitest": "^3.2.4"
},
"version": "2.27.0"
}
}
4 changes: 4 additions & 0 deletions src/Map/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## 2.30

- Deprecate option `title` from `Polygon`, `Polyline`, `Rectangle` and `Circle` in favor of `infoWindow`

## 2.29.0

- Add Symfony 8 support
Expand Down
24 changes: 18 additions & 6 deletions src/Map/assets/src/abstract_map_controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export type MarkerDefinition<BridgeMarkerOptions, BridgeInfoWindowOptions> = Wit
infoWindow?: Omit<InfoWindowDefinition<BridgeInfoWindowOptions>, 'position'>;
icon?: Icon;
/**
* @deprecated Use "bridgeOptions" instead.
* @deprecated since Symfony UX Map 2.27, use "bridgeOptions" instead.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will open a PR on fabbot to valide the @deprecated since ... format on JS/TS files too.

* Raw options passed to the marker constructor, specific to the map provider (e.g.: `L.marker()` for Leaflet).
*/
rawOptions?: BridgeMarkerOptions;
Expand All @@ -86,9 +86,12 @@ export type MarkerDefinition<BridgeMarkerOptions, BridgeInfoWindowOptions> = Wit
export type PolygonDefinition<BridgePolygonOptions, BridgeInfoWindowOptions> = WithIdentifier<{
infoWindow?: Omit<InfoWindowDefinition<BridgeInfoWindowOptions>, 'position'>;
points: Array<Point> | Array<Array<Point>>;
/**
* @deprecated since Symfony UX Map 2.29, use "infoWindow" instead
*/
title: string | null;
/**
* @deprecated Use "bridgeOptions" instead.
* @deprecated since Symfony UX Map 2.27, use "bridgeOptions" instead.
* Raw options passed to the polygon constructor, specific to the map provider (e.g.: `L.polygon()` for Leaflet).
*/
rawOptions?: BridgePolygonOptions;
Expand All @@ -109,9 +112,12 @@ export type PolygonDefinition<BridgePolygonOptions, BridgeInfoWindowOptions> = W
export type PolylineDefinition<BridgePolylineOptions, BridgeInfoWindowOptions> = WithIdentifier<{
infoWindow?: Omit<InfoWindowDefinition<BridgeInfoWindowOptions>, 'position'>;
points: Array<Point>;
/**
* @deprecated since Symfony UX Map 2.29, use "infoWindow" instead
*/
title: string | null;
/**
* @deprecated Use "bridgeOptions" instead.
* @deprecated since Symfony UX Map 2.27, use "bridgeOptions" instead.
* Raw options passed to the polyline constructor, specific to the map provider (e.g.: `L.polyline()` for Leaflet).
*/
rawOptions?: BridgePolylineOptions;
Expand All @@ -133,9 +139,12 @@ export type CircleDefinition<BridgeCircleOptions, BridgeInfoWindowOptions> = Wit
infoWindow?: Omit<InfoWindowDefinition<BridgeInfoWindowOptions>, 'position'>;
center: Point;
radius: number;
/**
* @deprecated since Symfony UX Map 2.29, use "infoWindow" instead
*/
title: string | null;
/**
* @deprecated Use "bridgeOptions" instead.
* @deprecated since Symfony UX Map 2.27, use "bridgeOptions" instead.
* Raw options passed to the circle constructor, specific to the map provider (e.g.: `L.circle()` for Leaflet).
*/
rawOptions?: BridgeCircleOptions;
Expand All @@ -157,9 +166,12 @@ export type RectangleDefinition<BridgeRectangleOptions, BridgeInfoWindowOptions>
infoWindow?: Omit<InfoWindowDefinition<BridgeInfoWindowOptions>, 'position'>;
southWest: Point;
northEast: Point;
/**
* @deprecated since Symfony UX Map 2.29, use "infoWindow" instead
*/
title: string | null;
/**
* @deprecated Use "bridgeOptions" instead.
* @deprecated since Symfony UX Map 2.27, use "bridgeOptions" instead.
* Raw options passed to the rectangle constructor, specific to the map provider (e.g.: `L.rectangle()` for Leaflet).
*/
rawOptions?: BridgeRectangleOptions;
Expand All @@ -184,7 +196,7 @@ export type InfoWindowDefinition<BridgeInfoWindowOptions> = {
opened: boolean;
autoClose: boolean;
/**
* @deprecated Use "bridgeOptions" instead.
* @deprecated since Symfony UX Map 2.27, use "bridgeOptions" instead.
* Raw options passed to the info window constructor, specific to the map provider (e.g.: `google.maps.InfoWindow()` for Google Maps).
*/
rawOptions?: BridgeInfoWindowOptions;
Expand Down
10 changes: 4 additions & 6 deletions src/Map/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ You can add Circles, which represents a circular area defined by a center point
$map->addCircle(new Circle(
center: new Point(48.8566, 2.3522),
radius: 5_000, // 5km
title: 'Paris',
infoWindow: new InfoWindow(
content: 'A 5km radius circle centered on Paris',
),
Expand All @@ -251,7 +250,6 @@ You can add Rectangles, which represents a rectangular area defined by two corne
$map->addRectangle(new Rectangle(
southWest: new Point(48.8566, 2.3522), // Paris
northEast: new Point(50.6292, 3.0573), // Lille
title: 'Paris to Lille',
infoWindow: new InfoWindow(
content: 'A rectangle from Paris to Lille',
),
Expand Down Expand Up @@ -504,7 +502,7 @@ Symfony UX Map allows you to extend its default behavior using a custom Stimulus
*/
_onPolygonBeforeCreate(event) {
console.log(event.detail.definition);
// { title: 'My polygon', points: [ { lat: 48.8566, lng: 2.3522 }, { lat: 45.7640, lng: 4.8357 }, { lat: 43.2965, lng: 5.3698 }, ... ], ... }
// { points: [ { lat: 48.8566, lng: 2.3522 }, { lat: 45.7640, lng: 4.8357 }, { lat: 43.2965, lng: 5.3698 }, ... ], ... }
}

/**
Expand All @@ -522,7 +520,7 @@ Symfony UX Map allows you to extend its default behavior using a custom Stimulus
*/
_onPolylineBeforeCreate(event) {
console.log(event.detail.definition);
// { title: 'My polyline', points: [ { lat: 48.8566, lng: 2.3522 }, { lat: 45.7640, lng: 4.8357 }, { lat: 43.2965, lng: 5.3698 }, ... ], ... }
// { points: [ { lat: 48.8566, lng: 2.3522 }, { lat: 45.7640, lng: 4.8357 }, { lat: 43.2965, lng: 5.3698 }, ... ], ... }
}

/**
Expand All @@ -536,7 +534,7 @@ Symfony UX Map allows you to extend its default behavior using a custom Stimulus

_onCircleBeforeCreate(event) {
console.log(event.detail.definition);
// { title: 'My circle', center: { lat: 48.8566, lng: 2.3522 }, radius: 1000, ... }
// { center: { lat: 48.8566, lng: 2.3522 }, radius: 1000, ... }
}

_onCircleAfterCreate(event) {
Expand All @@ -546,7 +544,7 @@ Symfony UX Map allows you to extend its default behavior using a custom Stimulus

_onRectangleBeforeCreate(event) {
console.log(event.detail.definition);
// { title: 'My rectangle', southWest: { lat: 48.8566, lng: 2.3522 }, northEast: { lat: 45.7640, lng: 4.8357 }, ... }
// { southWest: { lat: 48.8566, lng: 2.3522 }, northEast: { lat: 45.7640, lng: 4.8357 }, ... }
}

_onRectangleAfterCreate(event) {
Expand Down
12 changes: 12 additions & 0 deletions src/Map/src/Bridge/Google/assets/src/map_controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ export default class extends AbstractMapController<
...bridgeOptions,
});

/**
* @deprecated since Symfony UX Map 2.29, will be removed in 3.0
*/
if (title) {
polygon.set('title', title);
}
Expand Down Expand Up @@ -241,6 +244,9 @@ export default class extends AbstractMapController<
...bridgeOptions,
});

/**
* @deprecated since Symfony UX Map 2.29, will be removed in 3.0
*/
if (title) {
polyline.set('title', title);
}
Expand All @@ -267,6 +273,9 @@ export default class extends AbstractMapController<
...bridgeOptions,
});

/**
* @deprecated since Symfony UX Map 2.29, will be removed in 3.0
*/
if (title) {
circle.set('title', title);
}
Expand Down Expand Up @@ -296,6 +305,9 @@ export default class extends AbstractMapController<
...bridgeOptions,
});

/**
* @deprecated since Symfony UX Map 2.29, will be removed in 3.0
*/
if (title) {
rectangle.set('title', title);
}
Expand Down
12 changes: 12 additions & 0 deletions src/Map/src/Bridge/Leaflet/assets/src/map_controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ export default class extends AbstractMapController<

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

/**
* @deprecated since Symfony UX Map 2.29
*/
if (title) {
polygon.bindPopup(title);
}
Expand All @@ -189,6 +192,9 @@ export default class extends AbstractMapController<

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

/**
* @deprecated since Symfony UX Map 2.29
*/
if (title) {
polyline.bindPopup(title);
}
Expand All @@ -209,6 +215,9 @@ export default class extends AbstractMapController<

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

/**
* @deprecated since Symfony UX Map 2.29
*/
if (title) {
circle.bindPopup(title);
}
Expand All @@ -235,6 +244,9 @@ export default class extends AbstractMapController<
{ ...rawOptions, ...bridgeOptions }
).addTo(this.map);

/**
* @deprecated since Symfony UX Map 2.29
*/
if (title) {
rectangle.bindPopup(title);
}
Expand Down
3 changes: 1 addition & 2 deletions src/Map/src/Bridge/Leaflet/tests/LeafletRendererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public static function provideTestRenderMap(): iterable
'map' => (new Map())
->center(new Point(48.8566, 2.3522))
->zoom(12)
->addCircle(new Circle(center: new Point(48.8566, 2.3522), radius: 1000000, title: 'Paris', id: 'circle1'))
->addCircle(new Circle(center: new Point(48.8566, 2.3522), radius: 1000000, id: 'circle1'))
->addCircle(new Circle(center: new Point(1.1, 2.2), radius: 500, infoWindow: new InfoWindow(content: 'Circle'), id: 'circle2')),
];

Expand All @@ -115,7 +115,6 @@ public static function provideTestRenderMap(): iterable
->addRectangle(new Rectangle(
southWest: new Point(48.8566, 2.3522),
northEast: new Point(48.8566, 2.3522),
title: 'Rectangle',
id: 'rectangle1'
))
->addRectangle(new Rectangle(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
data-symfony--ux-leaflet-map--map-markers-value="[]"
data-symfony--ux-leaflet-map--map-polygons-value="[]"
data-symfony--ux-leaflet-map--map-polylines-value="[]"
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;}]"
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;}]"
data-symfony--ux-leaflet-map--map-rectangles-value="[]"
></div>
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
data-symfony--ux-leaflet-map--map-polygons-value="[]"
data-symfony--ux-leaflet-map--map-polylines-value="[]"
data-symfony--ux-leaflet-map--map-circles-value="[]"
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;}]"
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;}]"
></div>
4 changes: 4 additions & 0 deletions src/Map/src/Circle.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ public function __construct(
public readonly array $extra = [],
public readonly ?string $id = null,
) {
if (null !== $title) {
trigger_deprecation('symfony/ux-map', '2.30', 'The "title" parameter is deprecated and will be removed in 3.0. Use "infoWindow" instead.');
}

if ($radius <= 0) {
throw new InvalidArgumentException(\sprintf('Radius must be greater than 0, "%s" given.', $radius));
}
Expand Down
3 changes: 3 additions & 0 deletions src/Map/src/Polygon.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public function __construct(
private readonly array $extra = [],
public readonly ?string $id = null,
) {
if (null !== $title) {
trigger_deprecation('symfony/ux-map', '2.30', 'The "title" parameter is deprecated and will be removed in 3.0. Use "infoWindow" instead.');
}
}

/**
Expand Down
3 changes: 3 additions & 0 deletions src/Map/src/Polyline.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ public function __construct(
private readonly array $extra = [],
public readonly ?string $id = null,
) {
if (null !== $title) {
trigger_deprecation('symfony/ux-map', '2.30', 'The "title" parameter is deprecated and will be removed in 3.0. Use "infoWindow" instead.');
}
}

/**
Expand Down
3 changes: 3 additions & 0 deletions src/Map/src/Rectangle.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public function __construct(
public readonly array $extra = [],
public readonly ?string $id = null,
) {
if (null !== $title) {
trigger_deprecation('symfony/ux-map', '2.30', 'The "title" parameter is deprecated and will be removed in 3.0. Use "infoWindow" instead.');
}
}

/**
Expand Down
7 changes: 3 additions & 4 deletions src/Map/tests/CircleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public function testToArray()
$circle = new Circle(
center: $center,
radius: 500,
title: 'Test Circle',
infoWindow: $infoWindow,
extra: ['foo' => 'bar'],
id: 'circle1'
Expand All @@ -37,7 +36,7 @@ public function testToArray()
self::assertSame([
'center' => ['lat' => 1.1, 'lng' => 2.2],
'radius' => 500.0,
'title' => 'Test Circle',
'title' => null,
'infoWindow' => [
'headerContent' => 'info content',
'content' => null,
Expand All @@ -56,7 +55,7 @@ public function testFromArray()
$data = [
'center' => ['lat' => 1.1, 'lng' => 2.2],
'radius' => 500,
'title' => 'Test Circle',
'title' => null,
'infoWindow' => ['content' => 'info content'],
'extra' => ['foo' => 'bar'],
'id' => 'circle1',
Expand All @@ -70,7 +69,7 @@ public function testFromArray()
self::assertSame([
'center' => ['lat' => 1.1, 'lng' => 2.2],
'radius' => 500.0,
'title' => 'Test Circle',
'title' => null,
'infoWindow' => [
'headerContent' => null,
'content' => 'info content',
Expand Down
5 changes: 2 additions & 3 deletions src/Map/tests/MapFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ public function testToArrayFromArray()
new Point(48.853, 2.3499),
new Point(48.8566, 2.3522),
],
title: 'Polygon 1',
infoWindow: new InfoWindow('Polygon 1', 'Polygon 1', extra: ['color' => 'red']),
extra: ['color' => 'blue'],
));
Expand Down Expand Up @@ -222,7 +221,7 @@ private static function createMapArray(): array
'lng' => 2.3522,
],
],
'title' => 'Polygon 1',
'title' => null,
'infoWindow' => [
'headerContent' => 'Polygon 1',
'content' => 'Polygon 1',
Expand All @@ -245,7 +244,7 @@ private static function createMapArray(): array
'lng' => 2.3522,
],
],
'title' => 'Polyline 1',
'title' => null,
'infoWindow' => [
'headerContent' => 'Polyline 1',
'content' => 'Polyline 1',
Expand Down
Loading
Loading