Hi, i have array with markets, and my current position too, but every 3 or 4 seconds reload all map, how i can reload only my market position??? Thanks its my code=>
loadMap() {
this.geolocation.watchPosition().subscribe((position) => {
this.lng = position.coords.longitude;
this.lat = position.coords.latitude;
console.log('loadmapa');
console.log('this.lat' + 'this.lng');
console.log(this.lat + '' + this.lng);
// create a new map by passing HTMLElement
let mapEle: HTMLElement = document.getElementById('map');
// create LatLng object
let myLatLng = { lat: this.lat, lng: this.lng };
this.myposition = { latitude: this.lat, longitude: this.lng, name: '.', icon: 'img/car-placeholderb.png' };
//alert(JSON.stringify(myLatLng));
this.map = new google.maps.Map(mapEle, {
center: myLatLng,
zoom: 12
});
this.http.get('assets/markers.json')
.map((res) => res.json())
.subscribe(data => {
data.push(this.myposition);
console.log('all data');
console.log(data);
for (let i = 0; i < data.length; i++) {
google.maps.event.addListenerOnce(this.map, 'idle', () => {
let marker = new google.maps.Marker({
position: { lat: data[i].latitude, lng: data[i].longitude },
map: this.map,
icon: data[i].icon,
label: data[i].name
});
mapEle.classList.add('show-map');
});
}
});
}, (err) => {
console.log(err);
});
}