It creates markers by changing lat and long


#1

Hello what happens is that I am adding a marker but when the lat is changed and lng adds me another marker.
How do I do to update only the marker and do not create me markers?

 loadMap(lat,lng){
    let location : LatLng= new LatLng(lat,lng)
   this.map=new GoogleMap('map',{
      'controls':{
        'compass':true,
        'myLocationButton':true,
        'indoorPiker':true,
        'zoom':true
      },
      'gestures':{
        'scroll':true,
        'tilt':true,
        'rotate':true,
        'zoom':true
      },
      'camera':{
        'latLng':location,
        'tilt':30,
        'zoom':15,
        'bearing':50


      }

    })
    this.choferA.forEach(marker=>{
      
        this.addMarker(marker.lat,marker.lng);
        console.log("esto es:"+marker)
        

        
      });
      

  }



  addMarker(lat,lng){
  let markerOptions: MarkerOptions = {
    
    position: new LatLng(lat,lng),
    icon:'www/assets/img/busA.png',
   // title: this.chofer.ruta
  };
  this.map.addMarker(markerOptions);
  
}


#2

How about removing the old one before adding a new one?


#3

Why aren’t you using ionic-native?


#4

If you have to remove the one you are using before


#5

If I’m using native google map


#6

I just need to update latitude and longitude without creating another new marker