ionic-team / ionic-team/ionic-native-google-maps

The new marker has updated its location but old marker not remove in ionic native google map

Aperta
#363 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
TypeScript
Stelle
215
Fork
119
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

The marker is updating to new position and set a new marker but problem with old position marker not remove. marker.remove() not work under this if condition. How I remove old marker? any solution please. here is my code =>

```
loadMap() {

this.map = GoogleMaps.create('map_canvas', {
controls: {
myLocationButton : true,
myLocation : true
},
camera: {
target: {
lat: this.latitude, lng: this.longitude
},
zoom: 18,
tilt: 30
},
});

this.map.addMarker({
position: { lat: this.latitude, lng: this.longitude },
draggable: true,
disableAutoPan: true,
icon: 'blue',
title: 'Avirup'
}).then((marker: Marker) => {
marker.showInfoWindow();

const subscription = this.geolocation.watchPosition().subscribe(position => {
let geoposition = (position as Geoposition);
let latitude = geoposition.coords.latitude;
let longitude = geoposition.coords.longitude;
let marker : Marker
marker = this.map.addMarkerSync({
position: { lat: latitude, lng: longitude },
draggable: true,
disableAutoPan: true,
icon: { url: './assets/image/addresspin.png' ,
size: {
width: 30 ,
height: 30
}},
title: 'Move'
})
marker.showInfoWindow();
if(marker.getPosition().lat == latitude && marker.getPosition().lng == longitude){
marker.remove()
}
})
} ```

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Start in the loadMap method, especially the geolocation.watchPosition callback and its addMarkerSync call. Trace which marker instance is retained across position updates and verify the removal condition; done means the previous-position marker is no longer displayed while the current marker remains.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
typescript
Ambito
mobile
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.