我有以下代码,它应该在更改多边形形状时触发警报。仅在形状更改两次后才会显示此警报。意思是,我必须在触发事件之前两次调整形状大小。
有什么可能导致这种行为的想法吗?
function drawListener(drawingManager) {
var coord_listener = google.maps.event.addListener(drawingManager, 'polygoncomplete', function (polygon) {
var coordinates = (polygon.getPath().getArray()); //get
var bounds = new google.maps.LatLngBounds();
var people = [];
google.maps.event.addListener(polygon.getPath(), 'set_at', function () { //check to see if the item has been changed //THIS ONLY GETS CALLED AFTER POLYGON HAS BEEN CHANGED TWICE
alert('changed');
});
});
答案 0 :(得分:1)
我找到了答案:除了'set_at'
之外,我还必须使用'insert_at' google.maps.event.addListener(polygon.getPath(), 'set_at', function () {
alert('changed');
});
google.maps.event.addListener(polygon.getPath(), 'insert_at', function () {
alert('also changed');
});
感谢。