Ionic native google maps : how to recreate maps when i change marker position

how to recreate maps when i change marker position? i try to change position of the marker when i change ion-select using ionChange action, but the maps not change.

please help me, thanks.

this.map.remove();
this.map = GoogleMaps.create(...);

I have tried to add this.map.remove(); before this.map = GoogleMaps.create(…); but i found the error :
ERROR TypeError: Cannot read property ‘remove’ of undefined

please check my code below :

let mapOptions: GoogleMapOptions = {
camera: {
target: {
lat: map_lat,
lng: map_lng
},
zoom: 16,
tilt: 30
}
};

this.map.remove();
this.map = GoogleMaps.create(‘map_canvas’, mapOptions);

this.marker = this.map.addMarkerSync({
title: office_name,
icon: ‘red’,
animation: ‘DROP’,
position: {
lat: map_lat,
lng: map_lng
}
});

As the error says this.map is undefined.

My problem solved, i must create a map first before use this.map.remove().
Thank you…:slight_smile:

What do you exactly want to do? I don’t think that’s the most correct way if you just want to change the view of the map. There is a method called setCameraTarget(...) which can be used to see another zone in the map

I have tried your idea, but i found error : “[GoogleMaps] Minimum container dimention is 100x100 in pixels” when i use setCameraTarget or animateCamera or moveCamera, whereas i not found that error when i recreate a map