Skip to content

Commit 21b8f69

Browse files
committed
[Map] Split "view" attribute into multiple attributes
1 parent cdaf504 commit 21b8f69

File tree

8 files changed

+45
-52
lines changed

8 files changed

+45
-52
lines changed

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

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,6 @@ export type Point = {
33
lat: number;
44
lng: number;
55
};
6-
export type MapView<Options, MarkerOptions, InfoWindowOptions, PolygonOptions> = {
7-
center: Point | null;
8-
zoom: number | null;
9-
fitBoundsToMarkers: boolean;
10-
markers: Array<MarkerDefinition<MarkerOptions, InfoWindowOptions>>;
11-
polygons: Array<PolygonDefinition<PolygonOptions, InfoWindowOptions>>;
12-
options: Options;
13-
};
146
export type MarkerDefinition<MarkerOptions, InfoWindowOptions> = {
157
position: Point;
168
title: string | null;
@@ -39,7 +31,12 @@ export default abstract class<MapOptions, Map, MarkerOptions, Marker, InfoWindow
3931
providerOptions: ObjectConstructor;
4032
view: ObjectConstructor;
4133
};
42-
viewValue: MapView<MapOptions, MarkerOptions, InfoWindowOptions, PolygonOptions>;
34+
centerValue: Point | null;
35+
zoomValue: number | null;
36+
fitBoundsToMarkersValue: boolean;
37+
markersValue: Array<MarkerDefinition<MarkerOptions, InfoWindowOptions>>;
38+
polygonsValue: Array<PolygonDefinition<PolygonOptions, InfoWindowOptions>>;
39+
optionsValue: MapOptions;
4340
protected map: Map;
4441
protected markers: Array<Marker>;
4542
protected infoWindows: Array<InfoWindow>;

src/Map/assets/dist/abstract_map_controller.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ class default_1 extends Controller {
88
this.polygons = [];
99
}
1010
connect() {
11-
const { center, zoom, options, markers, polygons, fitBoundsToMarkers } = this.viewValue;
11+
const options = this.optionsValue;
1212
this.dispatchEvent('pre-connect', { options });
13-
this.map = this.doCreateMap({ center, zoom, options });
14-
markers.forEach((marker) => this.createMarker(marker));
15-
polygons.forEach((polygon) => this.createPolygon(polygon));
16-
if (fitBoundsToMarkers) {
13+
this.map = this.doCreateMap({ center: this.centerValue, zoom: this.zoomValue, options });
14+
this.markersValue.forEach((marker) => this.createMarker(marker));
15+
this.polygonsValue.forEach((polygon) => this.createPolygon(polygon));
16+
if (this.fitBoundsToMarkersValue) {
1717
this.doFitBoundsToMarkers();
1818
}
1919
this.dispatchEvent('connect', {

src/Map/assets/src/abstract_map_controller.ts

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,6 @@ import { Controller } from '@hotwired/stimulus';
22

33
export type Point = { lat: number; lng: number };
44

5-
export type MapView<Options, MarkerOptions, InfoWindowOptions, PolygonOptions> = {
6-
center: Point | null;
7-
zoom: number | null;
8-
fitBoundsToMarkers: boolean;
9-
markers: Array<MarkerDefinition<MarkerOptions, InfoWindowOptions>>;
10-
polygons: Array<PolygonDefinition<PolygonOptions, InfoWindowOptions>>;
11-
options: Options;
12-
};
13-
145
export type MarkerDefinition<MarkerOptions, InfoWindowOptions> = {
156
position: Point;
167
title: string | null;
@@ -71,25 +62,30 @@ export default abstract class<
7162
view: Object,
7263
};
7364

74-
declare viewValue: MapView<MapOptions, MarkerOptions, InfoWindowOptions, PolygonOptions>;
65+
declare centerValue: Point | null;
66+
declare zoomValue: number | null;
67+
declare fitBoundsToMarkersValue: boolean;
68+
declare markersValue: Array<MarkerDefinition<MarkerOptions, InfoWindowOptions>>;
69+
declare polygonsValue: Array<PolygonDefinition<PolygonOptions, InfoWindowOptions>>;
70+
declare optionsValue: MapOptions;
7571

7672
protected map: Map;
7773
protected markers: Array<Marker> = [];
7874
protected infoWindows: Array<InfoWindow> = [];
7975
protected polygons: Array<Polygon> = [];
8076

8177
connect() {
82-
const { center, zoom, options, markers, polygons, fitBoundsToMarkers } = this.viewValue;
78+
const options = this.optionsValue;
8379

8480
this.dispatchEvent('pre-connect', { options });
8581

86-
this.map = this.doCreateMap({ center, zoom, options });
82+
this.map = this.doCreateMap({ center: this.centerValue, zoom: this.zoomValue, options });
8783

88-
markers.forEach((marker) => this.createMarker(marker));
84+
this.markersValue.forEach((marker) => this.createMarker(marker));
8985

90-
polygons.forEach((polygon) => this.createPolygon(polygon));
86+
this.polygonsValue.forEach((polygon) => this.createPolygon(polygon));
9187

92-
if (fitBoundsToMarkers) {
88+
if (this.fitBoundsToMarkersValue) {
9389
this.doFitBoundsToMarkers();
9490
}
9591

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ let default_1$1 = class default_1 extends Controller {
99
this.polygons = [];
1010
}
1111
connect() {
12-
const { center, zoom, options, markers, polygons, fitBoundsToMarkers } = this.viewValue;
12+
const options = this.optionsValue;
1313
this.dispatchEvent('pre-connect', { options });
14-
this.map = this.doCreateMap({ center, zoom, options });
15-
markers.forEach((marker) => this.createMarker(marker));
16-
polygons.forEach((polygon) => this.createPolygon(polygon));
17-
if (fitBoundsToMarkers) {
14+
this.map = this.doCreateMap({ center: this.centerValue, zoom: this.zoomValue, options });
15+
this.markersValue.forEach((marker) => this.createMarker(marker));
16+
this.polygonsValue.forEach((polygon) => this.createPolygon(polygon));
17+
if (this.fitBoundsToMarkersValue) {
1818
this.doFitBoundsToMarkers();
1919
}
2020
this.dispatchEvent('connect', {

0 commit comments

Comments
 (0)