我有一个表用户外观
用户
Id |名字|电子邮件|纬度|经度
我想更新在Firebase中实时定位此用户,我是用户方法WatchPosition,但如何实时更新位置,请按照我在TS中的代码
addPosition() {
let watch = this.geolocation.watchPosition();
watch.subscribe((data) => {
this.myPosition = new google.maps.LatLng(data.coords.latitude, data.coords.longitude);
this.mapOptions = {
zoom: 19,
center: this.myPosition,
disableDefaultUI: true
}
this.map = new google.maps.Map(document.getElementById('map'), this.mapOptions);
this.directionsDisplay.setMap(this.map);
this.addMarker(this.myPosition);
const request = {
// Pode ser uma coordenada (LatLng), uma string ou um lugar
origin: this.myPosition,
// origin: new google.maps.LatLng(data.coords.latitude, data.coords.longitude),
destination: new google.maps.LatLng('-1.376040', '-48.435644'),
travelMode: 'DRIVING'
};
this.traceRoute(this.directionsService, this.directionsDisplay, request);
})
}