描画マネージャを使用してポリゴンを描画したいので、編集したいと思います。問題はポリゴンをクリックすると警告メッセージが表示されないことです。クリックイベントが発生していないようです。bingマップのポリゴンにclickイベントを追加したい
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);
});
});
問題は何ですか?希望する結果と問題を記述してください –
ポリゴンをクリックすると警告メッセージが表示されません。クリックイベントが発生していないようです。 Plsヘルプ –
クリックイベントがポリゴンで機能しています。私はdrawingmanagerでポリゴンをバインドしているときには動作しません。 –