|
1 | | -import { Controller } from '@hotwired/stimulus'; |
| 1 | +import AbstractMapController from '@symfony/ux-map'; |
2 | 2 | import { Loader } from '@googlemaps/js-api-loader'; |
3 | 3 |
|
4 | | -let default_1$1 = class default_1 extends Controller { |
5 | | - constructor() { |
6 | | - super(...arguments); |
7 | | - this.markers = []; |
8 | | - this.infoWindows = []; |
9 | | - this.polygons = []; |
10 | | - this.polylines = []; |
11 | | - } |
12 | | - connect() { |
13 | | - const { center, zoom, options, markers, polygons, polylines, fitBoundsToMarkers } = this.viewValue; |
14 | | - this.dispatchEvent('pre-connect', { options }); |
15 | | - this.map = this.doCreateMap({ center, zoom, options }); |
16 | | - markers.forEach((marker) => this.createMarker(marker)); |
17 | | - polygons.forEach((polygon) => this.createPolygon(polygon)); |
18 | | - polylines.forEach((polyline) => this.createPolyline(polyline)); |
19 | | - if (fitBoundsToMarkers) { |
20 | | - this.doFitBoundsToMarkers(); |
21 | | - } |
22 | | - this.dispatchEvent('connect', { |
23 | | - map: this.map, |
24 | | - markers: this.markers, |
25 | | - polygons: this.polygons, |
26 | | - polylines: this.polylines, |
27 | | - infoWindows: this.infoWindows, |
28 | | - }); |
29 | | - } |
30 | | - createMarker(definition) { |
31 | | - this.dispatchEvent('marker:before-create', { definition }); |
32 | | - const marker = this.doCreateMarker(definition); |
33 | | - this.dispatchEvent('marker:after-create', { marker }); |
34 | | - this.markers.push(marker); |
35 | | - return marker; |
36 | | - } |
37 | | - createPolygon(definition) { |
38 | | - this.dispatchEvent('polygon:before-create', { definition }); |
39 | | - const polygon = this.doCreatePolygon(definition); |
40 | | - this.dispatchEvent('polygon:after-create', { polygon }); |
41 | | - this.polygons.push(polygon); |
42 | | - return polygon; |
43 | | - } |
44 | | - createPolyline(definition) { |
45 | | - this.dispatchEvent('polyline:before-create', { definition }); |
46 | | - const polyline = this.doCreatePolyline(definition); |
47 | | - this.dispatchEvent('polyline:after-create', { polyline }); |
48 | | - this.polylines.push(polyline); |
49 | | - return polyline; |
50 | | - } |
51 | | - createInfoWindow(args) { |
52 | | - const { definition, element } = args; |
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$1.values = { |
61 | | - providerOptions: Object, |
62 | | - view: Object, |
63 | | -}; |
64 | | - |
65 | 4 | let _google; |
66 | | -class default_1 extends default_1$1 { |
| 5 | +class default_1 extends AbstractMapController { |
67 | 6 | async connect() { |
68 | 7 | if (!_google) { |
69 | 8 | _google = { maps: {} }; |
|
0 commit comments