More or less working now

This commit is contained in:
Willem Dantuma
2020-09-18 14:20:33 +02:00
parent 22e007b70b
commit 15d1f14ee1
8 changed files with 51 additions and 32 deletions

View File

@@ -1,4 +1,4 @@
import { Component, OnInit, Input, ViewChild, ElementRef, OnChanges, SimpleChanges } from '@angular/core';
import { Component, OnInit, Input, ViewChild, ElementRef, OnChanges, SimpleChanges ,Host} from '@angular/core';
import { MapComponent } from 'ngx-openlayers';
import Overlay from 'ol/Overlay';
import { fromLonLat, toLonLat } from 'ol/proj';
@@ -23,9 +23,10 @@ export class GpsLocation implements OnInit,OnChanges{
public path: string = "";
public rotate: string = "";
private resolution: number = 0;
initialized:boolean = false;
@ViewChild('location', { static: true }) locationElement: ElementRef;
constructor(private map: MapComponent) {
constructor(@Host() private map: MapComponent) {
}
@@ -54,12 +55,13 @@ export class GpsLocation implements OnInit,OnChanges{
this.resolution = evt.target.get('resolution');
this.recalcLocationTolerance();
});
this.initialized = true;
}
ngOnChanges(changes: SimpleChanges) {
if (changes.position && this.instance) {
var p = changes.position.currentValue as Position;
if(p) {
if(p && this.initialized) {
this.instance.setPosition(fromLonLat([p.coords.longitude, p.coords.latitude]));
this.locationTolerance = p.coords.accuracy;
this.recalcLocationTolerance();