在多边形Google地图中拖动多边形后,无法获取多边形的坐标。
以下我尝试过的示例代码:
<agm-map [latitude]="polygonlat" [longitude]="polygonlng"
[zoom]="polygonzoom" [disableDefaultUI]="false" [zoomControl]="true">
<agm-polygon [paths]="polygonpaths" [fillColor]="'#F5A623'"
[strokeColor]="'#F79A04'" [strokeWeight]="2"
[polyDraggable]="true" [editable]="true"
(polyDragEnd)="polyDragEndChange($event,this)">
</agm-polygon>
</agm-map>
在ts文件中:
import { MapsAPILoader } from "@agm/core";
//Inside class
@ViewChild("AgmPolygon") static polygonStatic: any;
polygonlat: number = 39.155564;
polygonlng: number = -75.524654;
polygonzoom: number = 12;
polygonpaths: any[] = [
{ lat: 39.155564, lng: -75.524654 },
{ lat: 39.155032, lng: -75.569630},
{ lat: 39.169317, lng: -75.546498},
{ lat: 39.179520, lng: -75.528088}
];
polyDragEndChange($event,polygon){
console.log("Polygon=-==>",$event);
}
有一个可用的接口方法getPaths()
,但不能使用它。有人可以帮我拖动多边形后获取路径。