Skip to content

Commit 980d119

Browse files
committed
fix lint and tests
1 parent 3b3b3a0 commit 980d119

File tree

8 files changed

+54
-132
lines changed

8 files changed

+54
-132
lines changed

src/Map/CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
- Add `ux_map.google_maps.default_map_id` configuration to set the Google ``Map ID``
77
- Add `Polyline` support
88

9+
## 2.22
10+
11+
- Add `Polyline` support
12+
913
## 2.20
1014

1115
- Deprecate `render_map` Twig function (will be removed in 2.21). Use
@@ -16,7 +20,6 @@
1620
- The importmap entry `@symfony/ux-map/abstract-map-controller` can be removed
1721
from your importmap, it is no longer needed.
1822
- Add `Polygon` support
19-
- Add `Polyline` support
2023

2124
## 2.19
2225

src/Map/assets/dist/abstract_map_controller.d.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,17 @@ export default abstract class<MapOptions, Map, MarkerOptions, Marker, InfoWindow
6565
protected abstract doCreateMarker(definition: MarkerDefinition<MarkerOptions, InfoWindowOptions>): Marker;
6666
protected abstract doCreatePolygon(definition: PolygonDefinition<PolygonOptions, InfoWindowOptions>): Polygon;
6767
protected abstract doCreatePolyline(definition: PolylineDefinition<PolylineOptions, InfoWindowOptions>): Polyline;
68-
protected createInfoWindow({ definition, element, }: {
69-
definition: MarkerDefinition<MarkerOptions, InfoWindowOptions>['infoWindow'] | PolygonDefinition<PolygonOptions, InfoWindowOptions>['infoWindow'] | PolylineDefinition<PolylineOptions, InfoWindowOptions>['infoWindow'];
70-
element: Marker | Polygon | Polyline;
68+
protected abstract createInfoWindow(args: {
69+
definition: MarkerDefinition<MarkerOptions, InfoWindowOptions>['infoWindow'];
70+
element: Marker;
71+
} | {
72+
definition: PolygonDefinition<PolygonOptions, InfoWindowOptions>['infoWindow'];
73+
element: Polygon;
74+
} | {
75+
definition: PolylineDefinition<PolylineOptions, InfoWindowOptions>['infoWindow'];
76+
element: Polyline;
7177
}): InfoWindow;
72-
protected abstract doCreateInfoWindow({ definition, element, }: {
78+
protected abstract doCreateInfoWindow(args: {
7379
definition: MarkerDefinition<MarkerOptions, InfoWindowOptions>['infoWindow'];
7480
element: Marker;
7581
} | {

src/Map/assets/dist/abstract_map_controller.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class default_1 extends Controller {
99
this.polylines = [];
1010
}
1111
connect() {
12-
const { center, zoom, options, markers, polygons, fitBoundsToMarkers } = this.viewValue;
12+
const { center, zoom, options, markers, polygons, polylines, fitBoundsToMarkers } = this.viewValue;
1313
this.dispatchEvent('pre-connect', { options });
1414
this.map = this.doCreateMap({ center, zoom, options });
1515
markers.forEach((marker) => this.createMarker(marker));
@@ -47,7 +47,8 @@ class default_1 extends Controller {
4747
this.polylines.push(polyline);
4848
return polyline;
4949
}
50-
createInfoWindow({ definition, element, }) {
50+
createInfoWindow(args) {
51+
const { definition, element } = args;
5152
this.dispatchEvent('info-window:before-create', { definition, element });
5253
const infoWindow = this.doCreateInfoWindow({ definition, element });
5354
this.dispatchEvent('info-window:after-create', { infoWindow, element });

src/Map/assets/src/abstract_map_controller.ts

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -156,16 +156,22 @@ export default abstract class<
156156
protected abstract doCreatePolygon(definition: PolygonDefinition<PolygonOptions, InfoWindowOptions>): Polygon;
157157
protected abstract doCreatePolyline(definition: PolylineDefinition<PolylineOptions, InfoWindowOptions>): Polyline;
158158

159-
protected createInfoWindow({
160-
definition,
161-
element,
162-
}: {
163-
definition:
164-
| MarkerDefinition<MarkerOptions, InfoWindowOptions>['infoWindow']
165-
| PolygonDefinition<PolygonOptions, InfoWindowOptions>['infoWindow']
166-
| PolylineDefinition<PolylineOptions, InfoWindowOptions>['infoWindow'];
167-
element: Marker | Polygon | Polyline;
168-
}): InfoWindow {
159+
protected abstract createInfoWindow(
160+
args:
161+
| {
162+
definition: MarkerDefinition<MarkerOptions, InfoWindowOptions>['infoWindow'];
163+
element: Marker;
164+
}
165+
| {
166+
definition: PolygonDefinition<PolygonOptions, InfoWindowOptions>['infoWindow'];
167+
element: Polygon;
168+
}
169+
| {
170+
definition: PolylineDefinition<PolylineOptions, InfoWindowOptions>['infoWindow'];
171+
element: Polyline;
172+
}
173+
): InfoWindow {
174+
const { definition, element } = args;
169175
this.dispatchEvent('info-window:before-create', { definition, element });
170176
const infoWindow = this.doCreateInfoWindow({ definition, element });
171177
this.dispatchEvent('info-window:after-create', { infoWindow, element });
@@ -175,22 +181,21 @@ export default abstract class<
175181
return infoWindow;
176182
}
177183

178-
protected abstract doCreateInfoWindow({
179-
definition,
180-
element,
181-
}:
182-
| {
183-
definition: MarkerDefinition<MarkerOptions, InfoWindowOptions>['infoWindow'];
184-
element: Marker;
185-
}
186-
| {
187-
definition: PolygonDefinition<PolygonOptions, InfoWindowOptions>['infoWindow'];
188-
element: Polygon;
189-
}
190-
| {
191-
definition: PolylineDefinition<PolylineOptions, InfoWindowOptions>['infoWindow'];
192-
element: Polyline;
193-
}): InfoWindow;
184+
protected abstract doCreateInfoWindow(
185+
args:
186+
| {
187+
definition: MarkerDefinition<MarkerOptions, InfoWindowOptions>['infoWindow'];
188+
element: Marker;
189+
}
190+
| {
191+
definition: PolygonDefinition<PolygonOptions, InfoWindowOptions>['infoWindow'];
192+
element: Polygon;
193+
}
194+
| {
195+
definition: PolylineDefinition<PolylineOptions, InfoWindowOptions>['infoWindow'];
196+
element: Polyline;
197+
}
198+
): InfoWindow;
194199

195200
protected abstract doFitBoundsToMarkers(): void;
196201

src/Map/src/Bridge/Google/assets/dist/map_controller.js

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ let default_1$1 = class default_1 extends Controller {
1010
this.polylines = [];
1111
}
1212
connect() {
13-
const { center, zoom, options, markers, polygons, fitBoundsToMarkers } = this.viewValue;
13+
const { center, zoom, options, markers, polygons, polylines, fitBoundsToMarkers } = this.viewValue;
1414
this.dispatchEvent('pre-connect', { options });
1515
this.map = this.doCreateMap({ center, zoom, options });
1616
markers.forEach((marker) => this.createMarker(marker));
@@ -48,7 +48,8 @@ let default_1$1 = class default_1 extends Controller {
4848
this.polylines.push(polyline);
4949
return polyline;
5050
}
51-
createInfoWindow({ definition, element, }) {
51+
createInfoWindow(args) {
52+
const { definition, element } = args;
5253
this.dispatchEvent('info-window:before-create', { definition, element });
5354
const infoWindow = this.doCreateInfoWindow({ definition, element });
5455
this.dispatchEvent('info-window:after-create', { infoWindow, element });
@@ -182,23 +183,6 @@ class default_1 extends default_1$1 {
182183
infoWindow.open({ map: this.map, anchor: element });
183184
}
184185
}
185-
else if (element instanceof google.maps.Polyline) {
186-
element.addListener('click', (event) => {
187-
if (definition.autoClose) {
188-
this.closeInfoWindowsExcept(infoWindow);
189-
}
190-
infoWindow.setPosition(event.latLng);
191-
infoWindow.open(this.map);
192-
});
193-
if (definition.opened) {
194-
const bounds = new google.maps.LatLngBounds();
195-
element.getPath().forEach((point) => {
196-
bounds.extend(point);
197-
});
198-
infoWindow.setPosition(bounds.getCenter());
199-
infoWindow.open({ map: this.map, anchor: element });
200-
}
201-
}
202186
return infoWindow;
203187
}
204188
createTextOrElement(content) {

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

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -219,23 +219,6 @@ export default class extends AbstractMapController<
219219
infoWindow.open(this.map);
220220
});
221221

222-
if (definition.opened) {
223-
const bounds = new google.maps.LatLngBounds();
224-
element.getPath().forEach((point: google.maps.LatLng) => {
225-
bounds.extend(point);
226-
});
227-
infoWindow.setPosition(bounds.getCenter());
228-
infoWindow.open({ map: this.map, anchor: element });
229-
}
230-
} else if (element instanceof google.maps.Polyline) {
231-
element.addListener('click', (event: any) => {
232-
if (definition.autoClose) {
233-
this.closeInfoWindowsExcept(infoWindow);
234-
}
235-
infoWindow.setPosition(event.latLng);
236-
infoWindow.open(this.map);
237-
});
238-
239222
if (definition.opened) {
240223
const bounds = new google.maps.LatLngBounds();
241224
element.getPath().forEach((point: google.maps.LatLng) => {

src/Map/src/Bridge/Leaflet/assets/dist/map_controller.js

Lines changed: 2 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,8 @@
1-
import { Controller } from '@hotwired/stimulus';
1+
import AbstractMapController from '@symfony/ux-map';
22
import 'leaflet/dist/leaflet.min.css';
33
import * as L from 'leaflet';
44

5-
class default_1 extends Controller {
6-
constructor() {
7-
super(...arguments);
8-
this.markers = [];
9-
this.infoWindows = [];
10-
this.polygons = [];
11-
this.polylines = [];
12-
}
13-
connect() {
14-
const { center, zoom, options, markers, polygons, fitBoundsToMarkers } = this.viewValue;
15-
this.dispatchEvent('pre-connect', { options });
16-
this.map = this.doCreateMap({ center, zoom, options });
17-
markers.forEach((marker) => this.createMarker(marker));
18-
polygons.forEach((polygon) => this.createPolygon(polygon));
19-
polylines.forEach((polyline) => this.createPolyline(polyline));
20-
if (fitBoundsToMarkers) {
21-
this.doFitBoundsToMarkers();
22-
}
23-
this.dispatchEvent('connect', {
24-
map: this.map,
25-
markers: this.markers,
26-
polygons: this.polygons,
27-
polylines: this.polylines,
28-
infoWindows: this.infoWindows,
29-
});
30-
}
31-
createMarker(definition) {
32-
this.dispatchEvent('marker:before-create', { definition });
33-
const marker = this.doCreateMarker(definition);
34-
this.dispatchEvent('marker:after-create', { marker });
35-
this.markers.push(marker);
36-
return marker;
37-
}
38-
createPolygon(definition) {
39-
this.dispatchEvent('polygon:before-create', { definition });
40-
const polygon = this.doCreatePolygon(definition);
41-
this.dispatchEvent('polygon:after-create', { polygon });
42-
this.polygons.push(polygon);
43-
return polygon;
44-
}
45-
createPolyline(definition) {
46-
this.dispatchEvent('polyline:before-create', { definition });
47-
const polyline = this.doCreatePolyline(definition);
48-
this.dispatchEvent('polyline:after-create', { polyline });
49-
this.polylines.push(polyline);
50-
return polyline;
51-
}
52-
createInfoWindow({ definition, element, }) {
53-
this.dispatchEvent('info-window:before-create', { definition, element });
54-
const infoWindow = this.doCreateInfoWindow({ definition, element });
55-
this.dispatchEvent('info-window:after-create', { infoWindow, element });
56-
this.infoWindows.push(infoWindow);
57-
return infoWindow;
58-
}
59-
}
60-
default_1.values = {
61-
providerOptions: Object,
62-
view: Object,
63-
};
64-
65-
class map_controller extends default_1 {
5+
class map_controller extends AbstractMapController {
666
connect() {
677
L.Marker.prototype.options.icon = L.divIcon({
688
html: '<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" fill-rule="evenodd" stroke-linecap="round" clip-rule="evenodd" viewBox="0 0 500 820"><defs><linearGradient id="__sf_ux_map_gradient_marker_fill" x1="0" x2="1" y1="0" y2="0" gradientTransform="matrix(0 -37.57 37.57 0 416.45 541)" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#126FC6"/><stop offset="1" stop-color="#4C9CD1"/></linearGradient><linearGradient id="__sf_ux_map_gradient_marker_border" x1="0" x2="1" y1="0" y2="0" gradientTransform="matrix(0 -19.05 19.05 0 414.48 522.49)" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#2E6C97"/><stop offset="1" stop-color="#3883B7"/></linearGradient></defs><circle cx="252.31" cy="266.24" r="83.99" fill="#fff"/><path fill="url(#__sf_ux_map_gradient_marker_fill)" stroke="url(#__sf_ux_map_gradient_marker_border)" stroke-width="1.1" d="M416.54 503.61c-6.57 0-12.04 5.7-12.04 11.87 0 2.78 1.56 6.3 2.7 8.74l9.3 17.88 9.26-17.88c1.13-2.43 2.74-5.79 2.74-8.74 0-6.18-5.38-11.87-11.96-11.87Zm0 7.16a4.69 4.69 0 1 1-.02 9.4 4.69 4.69 0 0 1 .02-9.4Z" transform="translate(-7889.1 -9807.44) scale(19.54)"/></svg>',

src/Map/src/Twig/UXMapComponent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
namespace Symfony\UX\Map\Twig;
1313

14-
use Symfony\UX\Map\Point;
1514
use Symfony\UX\Map\Marker;
15+
use Symfony\UX\Map\Point;
1616
use Symfony\UX\Map\Polygon;
1717
use Symfony\UX\Map\Polyline;
1818

0 commit comments

Comments
 (0)