簡體   English   中英

如何獲取已編輯形狀的新坐標並動態計算中心

[英]How to get new coordinates of the edited shape and calculate the center dynamically

我在我的應用程序中使用ngmap 我能夠使用shape從其坐標顯示多邊形。 現在我想讓這個多邊形可編輯。 我引用了這個鏈接 ,我的多邊形現在可以編輯了。 問題是我無法找到如何獲得新坐標。

drawing-manager是否存在onMapOverlayCompleted事件?

我怎樣才能獲得新坐標?

另外,我如何動態計算center屬性的值

它取決於形狀類型,在Rectangle情況下確定可以使用bounds_changed事件的調整大小的邊界。 以下示例演示如何打印調整大小的矩形:

 var app = angular.module('myapp', ['ngMap']); app.controller('DrawingManagerCtrl', function (NgMap) { var vm = this; NgMap.getMap().then(function (map) { vm.map = map; }); vm.rectShapeResized = function (e) { var rect = vm.map.shapes[0]; //get the first instance of shape console.log(rect.getBounds().toString()); //print a new bounds }; }); 
 <script src="https://maps.google.com/maps/api/js?libraries=placeses,visualization,drawing,geometry,places"></script> <script src="https://code.angularjs.org/1.3.15/angular.js"></script> <script src="https://rawgit.com/allenhwkim/angularjs-google-maps/master/build/scripts/ng-map.js"></script> <div ng-app="myapp" ng-controller="DrawingManagerCtrl as vm"> <ng-map zoom="7" center="48.8588377,2.2775177" map-type-id="ROADMAP" street-view-control-options="{position: 'LEFT_CENTER'}"> <shape name="rectangle" editable="true" on-bounds_changed="vm.rectShapeResized()" bounds="[ [48.190, 2.649], [48.899, 3.443] ]"> </shape> </ng-map> </div> 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM