Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 对于Google Map DrawingManager多边形的每个循环?_Angular_Typescript_Google Maps_Ionic Framework - Fatal编程技术网

Angular 对于Google Map DrawingManager多边形的每个循环?

Angular 对于Google Map DrawingManager多边形的每个循环?,angular,typescript,google-maps,ionic-framework,Angular,Typescript,Google Maps,Ionic Framework,我已经使用Angular 8和google maps组件建立了一个Ionic 4应用程序。在组件中,我需要绘制多个多边形,能够编辑它们,并最终将它们的顶点保存在数据库中 如果我可以硬编码一些多边形,那么通过polygon.getPath()或polygon.getPath()方法,这是一项非常简单的任务 但是,我使用的是google.maps.drawing.DrawingManager组件,我看到人们提取点的唯一方法是使用事件监听器,就像前面提到的那样。我在这里实现了类似的功能: google

我已经使用Angular 8和google maps组件建立了一个Ionic 4应用程序。在组件中,我需要绘制多个多边形,能够编辑它们,并最终将它们的顶点保存在数据库中

如果我可以硬编码一些多边形,那么通过polygon.getPath()或polygon.getPath()方法,这是一项非常简单的任务

但是,我使用的是google.maps.drawing.DrawingManager组件,我看到人们提取点的唯一方法是使用事件监听器,就像前面提到的那样。我在这里实现了类似的功能:

google.maps.event.addListener(drawingManager, 'polygoncomplete', (polygon) =>  {
  console.log(polygon.getPath());
});
这篇文章建议在这个函数中嵌套一个mouseup监听器,这可能有效,也可能无效,但我认为应该有更好的方法来解决这个问题

是否有一些“for each”循环类型的功能可以从使用drawingManager工具创建的每个多边形提取数据?我们的想法是点击提交按钮,一次抓取页面上多边形的每个实例

HTML


离子图
提交

我不确定这是否是您想要的,因此我将在评论中分享一些代码,看看这是否是您想要的,否则这只是一种帮助方法。

this.watch=Geolocation.watchPosition({},(position,err)=>{if(position){this.addNewLocation(position.coords.latitude,position.coords.longitude,position.timestamp);}});this.markers.map(marker=>marker.setMap(null));this.markers=[];for(让位置的loc){let latLng=new google.maps.latLng(loc.lat,loc.lng);让marker=new google.maps.marker({map:this.map,animation:google.maps.animation.DROP,position:latLng});this.markers.push(marker);}第一个用于存储数据,第二个用于将数据提取到map.app中。