diff --git a/src/Map/src/Bridge/Google/assets/dist/map_controller.js b/src/Map/src/Bridge/Google/assets/dist/map_controller.js index 5e18af2261b..469052d6fff 100644 --- a/src/Map/src/Bridge/Google/assets/dist/map_controller.js +++ b/src/Map/src/Bridge/Google/assets/dist/map_controller.js @@ -1,8 +1,68 @@ -import AbstractMapController from '@symfony/ux-map'; +import { Controller } from '@hotwired/stimulus'; import { Loader } from '@googlemaps/js-api-loader'; +let default_1$1 = class default_1 extends Controller { + constructor() { + super(...arguments); + this.markers = []; + this.infoWindows = []; + this.polygons = []; + this.polylines = []; + } + connect() { + const { center, zoom, options, markers, polygons, polylines, fitBoundsToMarkers } = this.viewValue; + this.dispatchEvent('pre-connect', { options }); + this.map = this.doCreateMap({ center, zoom, options }); + markers.forEach((marker) => this.createMarker(marker)); + polygons.forEach((polygon) => this.createPolygon(polygon)); + polylines.forEach((polyline) => this.createPolyline(polyline)); + if (fitBoundsToMarkers) { + this.doFitBoundsToMarkers(); + } + this.dispatchEvent('connect', { + map: this.map, + markers: this.markers, + polygons: this.polygons, + polylines: this.polylines, + infoWindows: this.infoWindows, + }); + } + createMarker(definition) { + this.dispatchEvent('marker:before-create', { definition }); + const marker = this.doCreateMarker(definition); + this.dispatchEvent('marker:after-create', { marker }); + this.markers.push(marker); + return marker; + } + createPolygon(definition) { + this.dispatchEvent('polygon:before-create', { definition }); + const polygon = this.doCreatePolygon(definition); + this.dispatchEvent('polygon:after-create', { polygon }); + this.polygons.push(polygon); + return polygon; + } + createPolyline(definition) { + this.dispatchEvent('polyline:before-create', { definition }); + const polyline = this.doCreatePolyline(definition); + this.dispatchEvent('polyline:after-create', { polyline }); + this.polylines.push(polyline); + return polyline; + } + createInfoWindow({ definition, element, }) { + this.dispatchEvent('info-window:before-create', { definition, element }); + const infoWindow = this.doCreateInfoWindow({ definition, element }); + this.dispatchEvent('info-window:after-create', { infoWindow, element }); + this.infoWindows.push(infoWindow); + return infoWindow; + } +}; +default_1$1.values = { + providerOptions: Object, + view: Object, +}; + let _google; -class default_1 extends AbstractMapController { +class default_1 extends default_1$1 { async connect() { if (!_google) { _google = { maps: {} }; diff --git a/src/Map/src/Bridge/Leaflet/assets/dist/map_controller.js b/src/Map/src/Bridge/Leaflet/assets/dist/map_controller.js index 0087754f43d..f391cd06b36 100644 --- a/src/Map/src/Bridge/Leaflet/assets/dist/map_controller.js +++ b/src/Map/src/Bridge/Leaflet/assets/dist/map_controller.js @@ -1,8 +1,68 @@ -import AbstractMapController from '@symfony/ux-map'; +import { Controller } from '@hotwired/stimulus'; import 'leaflet/dist/leaflet.min.css'; import * as L from 'leaflet'; -class map_controller extends AbstractMapController { +class default_1 extends Controller { + constructor() { + super(...arguments); + this.markers = []; + this.infoWindows = []; + this.polygons = []; + this.polylines = []; + } + connect() { + const { center, zoom, options, markers, polygons, polylines, fitBoundsToMarkers } = this.viewValue; + this.dispatchEvent('pre-connect', { options }); + this.map = this.doCreateMap({ center, zoom, options }); + markers.forEach((marker) => this.createMarker(marker)); + polygons.forEach((polygon) => this.createPolygon(polygon)); + polylines.forEach((polyline) => this.createPolyline(polyline)); + if (fitBoundsToMarkers) { + this.doFitBoundsToMarkers(); + } + this.dispatchEvent('connect', { + map: this.map, + markers: this.markers, + polygons: this.polygons, + polylines: this.polylines, + infoWindows: this.infoWindows, + }); + } + createMarker(definition) { + this.dispatchEvent('marker:before-create', { definition }); + const marker = this.doCreateMarker(definition); + this.dispatchEvent('marker:after-create', { marker }); + this.markers.push(marker); + return marker; + } + createPolygon(definition) { + this.dispatchEvent('polygon:before-create', { definition }); + const polygon = this.doCreatePolygon(definition); + this.dispatchEvent('polygon:after-create', { polygon }); + this.polygons.push(polygon); + return polygon; + } + createPolyline(definition) { + this.dispatchEvent('polyline:before-create', { definition }); + const polyline = this.doCreatePolyline(definition); + this.dispatchEvent('polyline:after-create', { polyline }); + this.polylines.push(polyline); + return polyline; + } + createInfoWindow({ definition, element, }) { + this.dispatchEvent('info-window:before-create', { definition, element }); + const infoWindow = this.doCreateInfoWindow({ definition, element }); + this.dispatchEvent('info-window:after-create', { infoWindow, element }); + this.infoWindows.push(infoWindow); + return infoWindow; + } +} +default_1.values = { + providerOptions: Object, + view: Object, +}; + +class map_controller extends default_1 { connect() { L.Marker.prototype.options.icon = L.divIcon({ html: '', diff --git a/src/TwigComponent/src/ComponentFactory.php b/src/TwigComponent/src/ComponentFactory.php index e0a64e03ed7..9e2d618bd3f 100644 --- a/src/TwigComponent/src/ComponentFactory.php +++ b/src/TwigComponent/src/ComponentFactory.php @@ -240,4 +240,3 @@ public function reset(): void $this->mountMethods = []; } } -