[英]How to get the new coordinates of a polygon after editing it?
我只是想知道如何在編輯后得到多邊形的新坐標?
我確實將多邊形的Editable
屬性設置為true,然后我開始在地圖中更改多邊形的邊界,當我完成編輯時,我想將新坐標轉換為多邊形,因此我可以將它們存儲在MYSQL中數據庫。
這是我的Polygon的代碼,
PS:我的多邊形的坐標是從MYSQL數據庫中檢索的。
cordonnees = [<?php echo $Cordinaates; ?>];
poly_edit = new google.maps.Polygon({
paths: cordonnees,
strokeColor: "#0FF000",
strokeOpacity: 0.8,
editable:true,
strokeWeight: 2,
fillColor: "#0FF000",
fillOpacity: 0.35
});
poly_edit.setMap(map);
api參考是您的朋友: https : //developers.google.com/maps/documentation/javascript/reference#Polygon
var currentPaths = poly_edit.getPaths();
答對了,
我找到了,這是我使用過的兩個聽眾:
第一個聽眾:
google.maps.event.addListener(patths, 'set_at', function() {
new_paths = poly_edit.getPath();
...
});
第二個聽眾:
google.maps.event.addListener(patths, 'insert_at', function() {
new_lentgh = patths.getLength();
new_paths = poly_edit.getPath();
...
});
它像一個魅力^^
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.