Skip to content

Commit 4cb91ef

Browse files
committed
[Map] Fix default values of Stimulus Map Controller
1 parent ec4cfa1 commit 4cb91ef

File tree

7 files changed

+43
-12
lines changed

7 files changed

+43
-12
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ export default abstract class<MapOptions, Map, MarkerOptions, Marker, InfoWindow
5656
polygonsValue: Array<PolygonDefinition<PolygonOptions, InfoWindowOptions>>;
5757
polylinesValue: Array<PolylineDefinition<PolylineOptions, InfoWindowOptions>>;
5858
optionsValue: MapOptions;
59+
hasCenterValue: boolean;
60+
hasZoomValue: boolean;
61+
hasFitBoundsToMarkersValue: boolean;
62+
hasMarkersValue: boolean;
63+
hasPolygonsValue: boolean;
64+
hasPolylinesValue: boolean;
65+
hasOptionsValue: boolean;
5966
protected map: Map;
6067
protected markers: globalThis.Map<string, Marker>;
6168
protected polygons: globalThis.Map<string, Polygon>;

src/Map/assets/dist/abstract_map_controller.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ class default_1 extends Controller {
1515
this.createMarker = this.createDrawingFactory('marker', this.markers, this.doCreateMarker.bind(this));
1616
this.createPolygon = this.createDrawingFactory('polygon', this.polygons, this.doCreatePolygon.bind(this));
1717
this.createPolyline = this.createDrawingFactory('polyline', this.polylines, this.doCreatePolyline.bind(this));
18-
this.map = this.doCreateMap({ center: this.centerValue, zoom: this.zoomValue, options });
18+
this.map = this.doCreateMap({
19+
center: this.hasCenterValue ? this.centerValue : null,
20+
zoom: this.hasZoomValue ? this.zoomValue : null,
21+
options,
22+
});
1923
this.markersValue.forEach((definition) => this.createMarker({ definition }));
2024
this.polygonsValue.forEach((definition) => this.createPolygon({ definition }));
2125
this.polylinesValue.forEach((definition) => this.createPolyline({ definition }));

src/Map/assets/src/abstract_map_controller.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,14 @@ export default abstract class<
112112
declare polylinesValue: Array<PolylineDefinition<PolylineOptions, InfoWindowOptions>>;
113113
declare optionsValue: MapOptions;
114114

115+
declare hasCenterValue: boolean;
116+
declare hasZoomValue: boolean;
117+
declare hasFitBoundsToMarkersValue: boolean;
118+
declare hasMarkersValue: boolean;
119+
declare hasPolygonsValue: boolean;
120+
declare hasPolylinesValue: boolean;
121+
declare hasOptionsValue: boolean;
122+
115123
protected map: Map;
116124
protected markers = new Map<Identifier, Marker>();
117125
protected polygons = new Map<Identifier, Polygon>();
@@ -140,7 +148,11 @@ export default abstract class<
140148
this.createPolygon = this.createDrawingFactory('polygon', this.polygons, this.doCreatePolygon.bind(this));
141149
this.createPolyline = this.createDrawingFactory('polyline', this.polylines, this.doCreatePolyline.bind(this));
142150

143-
this.map = this.doCreateMap({ center: this.centerValue, zoom: this.zoomValue, options });
151+
this.map = this.doCreateMap({
152+
center: this.hasCenterValue ? this.centerValue : null,
153+
zoom: this.hasZoomValue ? this.zoomValue : null,
154+
options,
155+
});
144156
this.markersValue.forEach((definition) => this.createMarker({ definition }));
145157
this.polygonsValue.forEach((definition) => this.createPolygon({ definition }));
146158
this.polylinesValue.forEach((definition) => this.createPolyline({ definition }));

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ class default_1 extends Controller {
1616
this.createMarker = this.createDrawingFactory('marker', this.markers, this.doCreateMarker.bind(this));
1717
this.createPolygon = this.createDrawingFactory('polygon', this.polygons, this.doCreatePolygon.bind(this));
1818
this.createPolyline = this.createDrawingFactory('polyline', this.polylines, this.doCreatePolyline.bind(this));
19-
this.map = this.doCreateMap({ center: this.centerValue, zoom: this.zoomValue, options });
19+
this.map = this.doCreateMap({
20+
center: this.hasCenterValue ? this.centerValue : null,
21+
zoom: this.hasZoomValue ? this.zoomValue : null,
22+
options,
23+
});
2024
this.markersValue.forEach((definition) => this.createMarker({ definition }));
2125
this.polygonsValue.forEach((definition) => this.createPolygon({ definition }));
2226
this.polylinesValue.forEach((definition) => this.createPolyline({ definition }));
@@ -121,12 +125,12 @@ class map_controller extends default_1 {
121125
super.connect();
122126
}
123127
centerValueChanged() {
124-
if (this.map && this.centerValue) {
128+
if (this.map && this.hasCenterValue && this.centerValue) {
125129
this.map.setCenter(this.centerValue);
126130
}
127131
}
128132
zoomValueChanged() {
129-
if (this.map && this.zoomValue) {
133+
if (this.map && this.hasZoomValue && this.zoomValue) {
130134
this.map.setZoom(this.zoomValue);
131135
}
132136
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,13 @@ export default class extends AbstractMapController<
8686
}
8787

8888
public centerValueChanged(): void {
89-
if (this.map && this.centerValue) {
89+
if (this.map && this.hasCenterValue && this.centerValue) {
9090
this.map.setCenter(this.centerValue);
9191
}
9292
}
9393

9494
public zoomValueChanged(): void {
95-
if (this.map && this.zoomValue) {
95+
if (this.map && this.hasZoomValue && this.zoomValue) {
9696
this.map.setZoom(this.zoomValue);
9797
}
9898
}

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ class default_1 extends Controller {
1717
this.createMarker = this.createDrawingFactory('marker', this.markers, this.doCreateMarker.bind(this));
1818
this.createPolygon = this.createDrawingFactory('polygon', this.polygons, this.doCreatePolygon.bind(this));
1919
this.createPolyline = this.createDrawingFactory('polyline', this.polylines, this.doCreatePolyline.bind(this));
20-
this.map = this.doCreateMap({ center: this.centerValue, zoom: this.zoomValue, options });
20+
this.map = this.doCreateMap({
21+
center: this.hasCenterValue ? this.centerValue : null,
22+
zoom: this.hasZoomValue ? this.zoomValue : null,
23+
options,
24+
});
2125
this.markersValue.forEach((definition) => this.createMarker({ definition }));
2226
this.polygonsValue.forEach((definition) => this.createPolygon({ definition }));
2327
this.polylinesValue.forEach((definition) => this.createPolyline({ definition }));
@@ -112,12 +116,12 @@ class map_controller extends default_1 {
112116
super.connect();
113117
}
114118
centerValueChanged() {
115-
if (this.map && this.centerValue && this.zoomValue) {
119+
if (this.map && this.hasCenterValue && this.centerValue && this.hasZoomValue && this.zoomValue) {
116120
this.map.setView(this.centerValue, this.zoomValue);
117121
}
118122
}
119123
zoomValueChanged() {
120-
if (this.map && this.zoomValue) {
124+
if (this.map && this.hasZoomValue && this.zoomValue) {
121125
this.map.setZoom(this.zoomValue);
122126
}
123127
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ export default class extends AbstractMapController<
4848
}
4949

5050
public centerValueChanged(): void {
51-
if (this.map && this.centerValue && this.zoomValue) {
51+
if (this.map && this.hasCenterValue && this.centerValue && this.hasZoomValue && this.zoomValue) {
5252
this.map.setView(this.centerValue, this.zoomValue);
5353
}
5454
}
5555

5656
public zoomValueChanged(): void {
57-
if (this.map && this.zoomValue) {
57+
if (this.map && this.hasZoomValue && this.zoomValue) {
5858
this.map.setZoom(this.zoomValue);
5959
}
6060
}

0 commit comments

Comments
 (0)