|
1 | | -import { Controller } from '@hotwired/stimulus'; |
| 1 | +import AbstractMapController from '@symfony/ux-map'; |
2 | 2 | import 'leaflet/dist/leaflet.min.css'; |
3 | 3 | import * as L from 'leaflet'; |
4 | 4 |
|
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 { |
66 | 6 | connect() { |
67 | 7 | L.Marker.prototype.options.icon = L.divIcon({ |
68 | 8 | 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>', |
|
0 commit comments