How to get paths of polygon when DragEnd in Sebm Google Maps? Angular 2

后端 未结 1 1415
后悔当初
后悔当初 2021-01-03 07:05

Every time I try to get the new polygon when I edit it, either by dragend or click, I always get the initial paths of my variable.

I initialize my paths variable wit

相关标签:
1条回答
  • 2021-01-03 07:48

    Late but I thought someone like me may get some help so adding the answer.

    The current release doesn't support it so you will need to make some changes to the current node_module. See this url:

    https://github.com/SebastianM/angular-google-maps/pull/991

    willshowell has explained what needs to be done.

    Steps:

    1. Update the sebm to agm (take the current release as of now)
    2. Second, update your angular to at least 2.3 because it will not work with 2.0.
    3. In the link above, he has committed various files to the branch. What he has done, is already explained in the issue.
    4. Short explanation: he has changed the Array to MVCArray so you can get the exact data type which google uses for it's map paths, added getPath() and getPaths() functions. I did same for Polygons you can download the files here to see what I need to change for getting new Paths for Polygons after DragEnd Dropbox link for files changed in @agm module

    Once you have made changes to Node Module, you can use the following code in the mouse up event of your PolyGon: @ViewChildren(AgmPolygon) polygonData: QueryList<AgmPolygon>; polyMouseUp($event: any, index:number, polygon: any) { var i =0; this.polygonData.forEach( x =>{ if(i==index){ x.getPath().then((y: any[]) => { console.log('-'); y.forEach(z => console.log(z.lat(), z.lng())); }); } i++; } ); }

    0 讨论(0)
提交回复
热议问题