From 9890adbed2d7cb4871961d048fd5d112fefa06bd Mon Sep 17 00:00:00 2001 From: Sebastian Roehl Date: Wed, 31 Jan 2018 13:46:39 +0100 Subject: [PATCH] Check for null coordinate in location object. --- .../src/app/views/components/map/map.component.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/web/angular/src/app/views/components/map/map.component.ts b/web/angular/src/app/views/components/map/map.component.ts index d51b1dc..4021d38 100755 --- a/web/angular/src/app/views/components/map/map.component.ts +++ b/web/angular/src/app/views/components/map/map.component.ts @@ -102,11 +102,16 @@ export class MapComponent implements OnInit, OnDestroy { // Subscribe to location updates this.getLocation().subscribe(l => { if (l !== null) { - if (this.firstPositionUpdate) { - this.map.setView(new L.LatLng(l.coordinate.latitude, l.coordinate.longitude), 10); - this.firstPositionUpdate = false; + if (l.coordinate !== null) { + if (this.firstPositionUpdate) { + const latLang = new L.LatLng(l.coordinate.latitude, l.coordinate.longitude); + this.map.setView(latLang, 8); + this.setMapMarker(latLang); + this.firstPositionUpdate = false; + } else { + this.setMapPosition(l, this.map.getZoom()); + } } - this.setMapPosition(l, this.map.getZoom()); } });