Skip to content

Commit c997258

Browse files
committed
fix review & pipeline
1 parent b2eee4c commit c997258

File tree

12 files changed

+39
-15
lines changed

12 files changed

+39
-15
lines changed

src/Map/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# CHANGELOG
22

33
## 2.28
4+
45
- Add support for creating `Circle` by passing a `Point` and a radius in meters to the `Circle` constructor, e.g.:
56
```php
67
$map->addCircle(new Circle(

src/Map/assets/src/abstract_map_controller.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,11 @@ export default abstract class<
370370
factory: typeof this.doCreateCircle
371371
): typeof this.doCreateCircle;
372372
private createDrawingFactory<
373-
Factory extends typeof this.doCreateMarker | typeof this.doCreatePolygon | typeof this.doCreatePolyline | typeof this.doCreateCircle,
373+
Factory extends
374+
| typeof this.doCreateMarker
375+
| typeof this.doCreatePolygon
376+
| typeof this.doCreatePolyline
377+
| typeof this.doCreateCircle,
374378
Draw extends ReturnType<Factory>,
375379
>(
376380
type: 'marker' | 'polygon' | 'polyline' | 'circle',

src/Map/assets/test/abstract_map_controller.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ describe('AbstractMapController', () => {
128128
])
129129
);
130130
expect(controller.polylines).toEqual(new Map([['0fa955da866c7720', { polyline: 'polyline', title: null }]]));
131-
expect(controller.circles).toEqual(new Map([['7c3e1a9b5f2d4e81', { circle: 'circle', title: null }]])); expect(controller.infoWindows).toEqual([
131+
expect(controller.circles).toEqual(new Map([['7c3e1a9b5f2d4e81', { circle: 'circle', title: null }]]));
132+
expect(controller.infoWindows).toEqual([
132133
{
133134
headerContent: 'Paris',
134135
infoWindow: 'infoWindow',

src/Map/doc/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ You can add Polylines, which represents a path made by a series of ``Point`` ins
209209
));
210210

211211
Add Circles
212-
~~~~~~~~~~
212+
~~~~~~~~~~~
213213

214214
You can add Circles, which represents a circular area defined by a center point and a radius (in meters)::
215215

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ import type { LoaderOptions } from '@googlemaps/js-api-loader';
1111
import { Loader } from '@googlemaps/js-api-loader';
1212
import AbstractMapController, { IconTypes } from '@symfony/ux-map';
1313
import type {
14+
CircleDefinition,
1415
Icon,
1516
InfoWindowWithoutPositionDefinition,
1617
MarkerDefinition,
1718
Point,
1819
PolygonDefinition,
1920
PolylineDefinition,
20-
CircleDefinition,
2121
} from '@symfony/ux-map';
2222

2323
type MapOptions = Pick<

src/Map/src/Bridge/Google/tests/GoogleRendererTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\UX\Icons\IconRendererInterface;
1515
use Symfony\UX\Map\Bridge\Google\GoogleOptions;
1616
use Symfony\UX\Map\Bridge\Google\Renderer\GoogleRenderer;
17+
use Symfony\UX\Map\Circle;
1718
use Symfony\UX\Map\Icon\Icon;
1819
use Symfony\UX\Map\Icon\UxIconRenderer;
1920
use Symfony\UX\Map\InfoWindow;
@@ -101,6 +102,15 @@ public static function provideTestRenderMap(): iterable
101102
->addPolyline(new Polyline(points: [new Point(1.1, 2.2), new Point(3.3, 4.4), new Point(5.5, 6.6)], infoWindow: new InfoWindow(content: 'Polygon'))),
102103
];
103104

105+
yield 'with circles and infoWindows' => [
106+
'renderer' => new GoogleRenderer(new StimulusHelper(null), new UxIconRenderer(null), apiKey: 'api_key'),
107+
'map' => (new Map())
108+
->center(new Point(48.8566, 2.3522))
109+
->zoom(12)
110+
->addCircle(new Circle(center: new Point(48.8566, 2.3522), radius: 500, infoWindow: new InfoWindow(content: 'Circle')))
111+
->addCircle(new Circle(center: new Point(1.1, 2.2), radius: 1000, infoWindow: new InfoWindow(content: 'Circle'))),
112+
];
113+
104114
yield 'with controls enabled' => [
105115
'renderer' => new GoogleRenderer(new StimulusHelper(null), new UxIconRenderer(null), apiKey: 'api_key'),
106116
'map' => (new Map())

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
import AbstractMapController, { IconTypes } from '@symfony/ux-map';
22
import type {
3+
CircleDefinition,
34
Icon,
45
InfoWindowWithoutPositionDefinition,
56
MarkerDefinition,
67
Point,
78
PolygonDefinition,
89
PolylineDefinition,
9-
CircleDefinition,
1010
} from '@symfony/ux-map';
1111
import 'leaflet/dist/leaflet.min.css';
1212
import * as L from 'leaflet';
13-
import {
13+
import type {
14+
CircleOptions,
1415
ControlPosition,
1516
LatLngBoundsExpression,
1617
MapOptions as LeafletMapOptions,
1718
MarkerOptions,
1819
PolylineOptions as PolygonOptions,
1920
PolylineOptions,
2021
PopupOptions,
21-
CircleOptions,
2222
} from 'leaflet';
2323

2424
type MapOptions = Pick<LeafletMapOptions, 'center' | 'zoom' | 'attributionControl' | 'zoomControl'> & {
@@ -180,12 +180,10 @@ export default class extends AbstractMapController<
180180
polyline.remove();
181181
}
182182

183-
protected doCreateCircle({
184-
definition,
185-
}: { definition: CircleDefinition<CircleOptions, PopupOptions> }): L.Circle {
183+
protected doCreateCircle({ definition }: { definition: CircleDefinition<CircleOptions, PopupOptions> }): L.Circle {
186184
const { '@id': _id, center, radius, title, infoWindow, rawOptions = {} } = definition;
187185

188-
const circle = L.circle(center, {radius, ...rawOptions }).addTo(this.map);
186+
const circle = L.circle(center, { radius, ...rawOptions }).addTo(this.map);
189187

190188
if (title) {
191189
circle.bindPopup(title);

src/Map/src/Bridge/Leaflet/tests/LeafletRendererTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\UX\Icons\IconRendererInterface;
1515
use Symfony\UX\Map\Bridge\Leaflet\Renderer\LeafletRenderer;
16+
use Symfony\UX\Map\Circle;
1617
use Symfony\UX\Map\Icon\Icon;
1718
use Symfony\UX\Map\Icon\UxIconRenderer;
1819
use Symfony\UX\Map\InfoWindow;
@@ -96,6 +97,15 @@ public static function provideTestRenderMap(): iterable
9697
->addPolyline(new Polyline(points: [new Point(1.1, 2.2), new Point(3.3, 4.4), new Point(5.5, 6.6)], infoWindow: new InfoWindow(content: 'Polyline'), id: 'polyline2')),
9798
];
9899

100+
yield 'with circles and infoWindows' => [
101+
'renderer' => new LeafletRenderer(new StimulusHelper(null), new UxIconRenderer(null)),
102+
'map' => (new Map())
103+
->center(new Point(48.8566, 2.3522))
104+
->zoom(12)
105+
->addCircle(new Circle(center: new Point(48.8566, 2.3522), radius: 1000000, title: 'Paris', id: 'circle1'))
106+
->addCircle(new Circle(center: new Point(1.1, 2.2), radius: 500, infoWindow: new InfoWindow(content: 'Circle'), id: 'circle2')),
107+
];
108+
99109
yield 'markers with icons' => [
100110
'renderer' => new LeafletRenderer(
101111
new StimulusHelper(null),

src/Map/src/Circle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
/**
1717
* Represents a circle on a map.
1818
*
19-
* @author Symfony Community
19+
* @author Valmont Pehaut-Pietri <[email protected]>
2020
*/
2121
final class Circle implements Element
2222
{

src/Map/src/Circles.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
/**
1515
* Represents a Circle collection.
1616
*
17-
* @author Symfony Community
17+
* @author Valmont Pehaut-Pietri <[email protected]>
1818
*
1919
* @internal
2020
*/

0 commit comments

Comments
 (0)