Check for null coordinate in location object.
lbs-gitea/maptology/master This commit looks good

This commit is contained in:
Sebastian Roehl
2018-01-31 13:46:39 +01:00
parent 9574a7c62c
commit 9890adbed2
@@ -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());
}
});