-2
我想用绘图管理器绘制多边形,因为我也想编辑它们。问题是,一旦我点击多边形,它不会显示警告消息。似乎点击事件没有被解雇。想要在bing地图上添加多边形点击事件
var map = new Microsoft.Maps.Map(document.getElementById('myMap'), {
credentials: 'Your Bing Maps Key'
});
var center = map.getCenter();
var nose = new Microsoft.Maps.Pushpin(center, null);
var polygon1 = new Microsoft.Maps.Polygon([
new Microsoft.Maps.Location(center.latitude + 0.01, center.longitude - 0.03),
new Microsoft.Maps.Location(center.latitude + 0.01, center.longitude - 0.11),
new Microsoft.Maps.Location(center.latitude + 0.05, center.longitude - 0.07)
]);
Microsoft.Maps.Events.addHandler(polygon1, 'click', function() { alert('polygonClick1'); });
var polygon2 = new Microsoft.Maps.Polygon([
new Microsoft.Maps.Location(center.latitude + 0.01, center.longitude + 0.03),
new Microsoft.Maps.Location(center.latitude + 0.01, center.longitude + 0.11),
new Microsoft.Maps.Location(center.latitude + 0.05, center.longitude + 0.07)
]);
Microsoft.Maps.Events.addHandler(polygon2, 'click', function() { alert('polygonClick2'); });
var mouth = new Microsoft.Maps.Polyline([
new Microsoft.Maps.Location(center.latitude - 0.02, center.longitude - 0.10),
new Microsoft.Maps.Location(center.latitude - 0.05, center.longitude - 0.07),
new Microsoft.Maps.Location(center.latitude - 0.05, center.longitude + 0.07),
new Microsoft.Maps.Location(center.latitude - 0.02, center.longitude + 0.10)
]);
Microsoft.Maps.loadModule('Microsoft.Maps.DrawingTools', function() {
var tools = new Microsoft.Maps.DrawingTools(map);
tools.showDrawingManager(function (manager) {
manager.setPrimitives([mouth]);
manager.add(polygon1);
manager.add(polygon2);
manager.add(nose);
});
});
问题是什么?描述你想要的结果和问题 –
一旦我点击多边形,它不会显示警告消息。似乎点击事件没有被解雇。请帮助 –
我有使用多边形的点击事件。当我使用绘图管理器绑定多边形时,它不起作用。 –