Hi all, I just wanted to know how can I remove marker from google map.
The initial marker is the current position of the device itself and I’m working on tracking other users so need to remove the marker as soon as the admin selects another user to track.
loadMap() {
let mapOptions = {
zoom: 13,
mapTypeId: google.maps.MapTypeId.ROADMAP,
mapTypeControl: false,
streetViewControl: false,
fullscreenControl: false
}
this.map = new google.maps.Map(this.mapElement.nativeElement, mapOptions);
this.geolocation.getCurrentPosition().then(pos => {
let latLng = new google.maps.LatLng(pos.coords.latitude, pos.coords.longitude);
this.map.setCenter(latLng);
this.map.setZoom(16);
this.addMarker();
}).catch((error) => {
console.log('Error getting location', error);
});
}
addMarker() {
let marker = new google.maps.Marker({
map: this.map,
animation: google.maps.Animation.DROP,
position: this.map.getCenter(),
});
this.markers.push(marker);
}
}