Bing 地图多边形更改侦听器

Bing Map Polygon Change Listener

我需要一个事件侦听器来获取 bing 地图 V8 中多边形的变化。我用谷歌搜索了足够多,几乎什么也没发现。我在 Google 中是这样做的;

 google.maps.event.addListener(regionPolygon, 'click', function () {
        var ang = regionPolygon.getPath();
        google.maps.event.addListener(ang, 'set_at', function () {
            var newPoints = [];
            newPoints = regionPolygon.getPath().getArray();
            var a = newPoints.length;
            var x = regionPolygon.getPath();
            var bounds = new google.maps.LatLngBounds();
            var strx = "";
            //var b = 0;
            for (b = 0; b < a; b++) {
                var i = b + 1;
                strx = strx + newPoints[b].lat() + ',';

                if (i != a)
                {
                    strx = strx + newPoints[b].lng() + ',';
                }
                else if (i == a)
                {
                    strx = strx + newPoints[b].lng();
                }
            }     
                isFinished = true;
                updateRegion(regionName, strx);
                setTimeout(function () { loadRegions(); },2500);                 
        });}

我无法在 bing 地图中找到。顺便说一下,我设置了一个像这样的可编辑多边形

var polygon = new Microsoft.Maps.Polygon(points, { 行程粗细:1 });

        Microsoft.Maps.loadModule('Microsoft.Maps.DrawingTools', function () {
            //Create an instance of the DrawingTools class and bind it to the map.
            var tools = new Microsoft.Maps.DrawingTools(_this.mapBings);

            //Pass the polygon to the drawing tools to be edited.
            tools.edit(polygon);
        });

        var bestView = Microsoft.Maps.LocationRect.fromLocations(points);

        setTimeout((function () {
            this.mapBings.setView({ bounds: bestView });
        }).bind(_this), 10);

        _this.polygonOverlay = polygon;
        // _this.mapBings.entities.push(polygon);

        Microsoft.Maps.Events.addHandler(polygon, 'click',
            function ()
            {
                alert('hey')
            });

向绘图管理器添加一个事件。如此处所述,有几个可供选择:https://msdn.microsoft.com/en-us/library/mt750463.aspx

如果您使用 drawingChanged 事件,它会在您编辑多边形时触发。您可以在此处找到演示何时触发这些事件的实时代码示例:http://bingmapsv8samples.azurewebsites.net/#DrawingTools_Events