Skip to content
This repository was archived by the owner on Jun 23, 2025. It is now read-only.

Commit b975c76

Browse files
committed
fix(SebmGoogleMap): show map when zoom is not set
This fixes the following (allowed) use of SebmGoogleMap. When the zoom was not set, the map was empty. ``` <sebm-google-map [latitude]="lat" [longitude]="lng"> </sebm-google-map> ``` closes #81
1 parent e1f0818 commit b975c76

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/directives/google-map.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ export class SebmGoogleMap implements OnChanges,
9696
}
9797

9898
private _initMapInstance(el: HTMLElement) {
99-
this._mapsWrapper.createMap(el, {center: {lat: this._latitude, lng: this._longitude}});
99+
this._mapsWrapper.createMap(
100+
el, {center: {lat: this._latitude, lng: this._longitude}, zoom: this._zoom});
100101
this._handleMapCenterChange();
101102
this._handleMapZoomChange();
102103
this._handleMapMouseEvents();
@@ -118,7 +119,7 @@ export class SebmGoogleMap implements OnChanges,
118119
* Sets the zoom level of the map. The default value is `8`.
119120
*/
120121
set zoom(value: number | string) {
121-
this._zoom = this._convertToDecimal(value);
122+
this._zoom = this._convertToDecimal(value, 8);
122123
if (typeof this._zoom === 'number') {
123124
this._mapsWrapper.setZoom(this._zoom);
124125
}
@@ -140,13 +141,13 @@ export class SebmGoogleMap implements OnChanges,
140141
this._updateCenter();
141142
}
142143

143-
private _convertToDecimal(value: string | number): number {
144+
private _convertToDecimal(value: string | number, defaultValue: number = null): number {
144145
if (typeof value === 'string') {
145146
return parseFloat(value);
146147
} else if (typeof value === 'number') {
147148
return <number>value;
148149
}
149-
return null;
150+
return defaultValue;
150151
}
151152

152153
private _updateCenter() {

0 commit comments

Comments
 (0)