Fix for map location.
lbs-gitea/maptology/master This commit looks good

This commit is contained in:
Sebastian Roehl
2018-01-16 14:50:16 +01:00
parent 6908c06a14
commit a8d7d2991f
@@ -80,12 +80,6 @@ export class MapComponent implements OnInit, OnDestroy {
// this.marker.bindTooltip('Tooltip', {sticky: true});
this.setMapMarker(this.defaultLocation);
this.currentLocation = this.defaultLocation;
this.map.on('zoomend', () => {
this.consoleService.log('Zoom ended');
this.setMapMarker(this.currentLocation);
});
// If there is a given shareId in the URL, fetch the location from the API and
// start to update every x seconds
if (this.currentShare) {
@@ -104,16 +98,9 @@ export class MapComponent implements OnInit, OnDestroy {
// Query the API every 2 seconds
this.refreshInterval = setInterval(() => {
this.locationService.getLocation(this.currentShare);
this.setMapPosition(this.locationService.location.getValue(), 10);
}, 2000);
// subscribe to location updates
this.locationService.location.subscribe(location => {
this.consoleService.log('Lon: ' + location.coordinate.longitude + ' Lat: ' + location.coordinate.latitude);
if (location !== null) {
this.setMapPosition(location, 10);
}
});
} else {
setTimeout(() => this.showWarning('Warning', 'URL does not contain a valid share!'));
}