I'm using on my angular project this version of Angular Google Maps "@agm/core": "1.0.0-beta.2" . My concern is about how to re-draw the polygon I have drawn on my google Map, I'm storing the latitude and longitude, How can I redraw my polygon ?
<agm-map [latitude]="latitudeMapUpdate"
[longitude]="longitudeMapUpdate"
[disableDefaultUI]="false"
[zoom]="13"
(mapReady)="onMapReady($event)">
</agm-map>
onMapReady(map) {
this.initDrawingManager(map);
}
initDrawingManager(map: any) {
const self = this;
const options = {
drawingControl: true,
drawingControlOptions: {
drawingModes: ["polygon"]
},
polygonOptions: {
draggable: true,
editable: true
},
drawingMode: google.maps.drawing.OverlayType.POLYGON
};
const drawingManager = new google.maps.drawing.DrawingManager(options);
drawingManager.setMap(map);
google.maps.event.addListener(
drawingManager,
'overlaycomplete',
(event) => {
alert(event.overlay.getPath().getArray());
const paths = event.overlay.getPaths();
drawingManager.setDrawingMode(null);
self.updatePointList(event.overlay.getPath());
const newShape = event.overlay;
newShape.type = event.type;
google.maps.event.addListener(newShape, 'click', () => {
this.setSelectionPolygons(newShape)
});
this.setSelectionPolygons(newShape)
});
google.maps.event.addListener(drawingManager, 'drawingmode_changed', this.clearSelection);
google.maps.event.addListener(map, 'click', this.clearSelection);
google.maps.event.addDomListener(document.getElementById('delete-map-button'), 'click', this.deleteSelectedShape);
console.log({map});
}