node page: fix bug if navigator.geolocation.watchPosition() returns 0 as id

This commit is contained in:
Oliver Gerlich 2018-07-15 22:46:37 +02:00 committed by Geno
parent 7f498b4a6e
commit ad7cc8d0aa
1 changed files with 3 additions and 3 deletions

View File

@ -94,13 +94,13 @@ export class NodeView extends View {
this.btnGPS.classList.add('btn'); this.btnGPS.classList.add('btn');
this.btnGPS.innerHTML = 'Start follow position'; this.btnGPS.innerHTML = 'Start follow position';
this.btnGPS.addEventListener('click', () => { this.btnGPS.addEventListener('click', () => {
if (this.editLocationGPS) { if (this.editLocationGPS != null) {
if (this.btnGPS.innerHTML === 'Stop following') { if (this.btnGPS.innerHTML === 'Stop following') {
updatePosition(); updatePosition();
} }
this.btnGPS.innerHTML = 'Start follow position'; this.btnGPS.innerHTML = 'Start follow position';
navigator.geolocation.clearWatch(this.editLocationGPS); navigator.geolocation.clearWatch(this.editLocationGPS);
this.editLocationGPS = false; this.editLocationGPS = null;
return; return;
} }
@ -177,7 +177,7 @@ export class NodeView extends View {
this.hostnameInput.value = node.hostname; this.hostnameInput.value = node.hostname;
this.ownerInput.value = node.owner; this.ownerInput.value = node.owner;
if (!this.editLocationGPS && node.location && node.location.latitude && node.location.longitude) { if (this.editLocationGPS == null && node.location && node.location.latitude && node.location.longitude) {
// eslint-disable-next-line one-var // eslint-disable-next-line one-var
const latlng = [node.location.latitude, node.location.longitude]; const latlng = [node.location.latitude, node.location.longitude];