Reputation: 595
I'm using Bing Map Ajax Control V7 for test / learning. I created a few pushpins with infobox, and added events:
function InsertEvent(mark, infoBox)
{
var obj = {marker : {}, infoWind : {}};
obj.marker.entity = mark;
obj.marker.eID = Microsoft.Maps.Events.addHandler(mark, "click", function(e) {toggleInfo(e, infoBox, true)});
obj.infoWind.entity = infoBox;
obj.infoWind.eID = Microsoft.Maps.Events.addHandler(infoBox, "mouseleave", function(e) {toggleInfo(e, infoBox, false)});
eventsID.push(obj);
}
So, these events work well, until I add DrawningToolModule to map.
function GetMap()
{
map = new Microsoft.Maps.Map(document.getElementById("mapDiv"),
{credentials: "My extra top secret Bing Map Key",
center: new Microsoft.Maps.Location(51.201547622680664, 16.16974449157715), zoom: 15 });
Microsoft.Maps.loadModule('Microsoft.Maps.Search', { callback: searchModuleLoaded });
Microsoft.Maps.registerModule("DrawingToolsModule", "DrawingToolsModule/DrawingToolsModule.js");
Microsoft.Maps.loadModule("DrawingToolsModule", { callback: function () {
drawTools = new DrawingTools.DrawingManager(map, {toolbarContainer : document.getElementById("toolbarContainer")});
}
});
}
After loading data, pushpins reaction on click is fine. After adding custom pushpins by DrawingTool - events are fine. After drawing any shape (polygon, polyfil, circle) - my events for pushpins aren't invoking.
I added a function helper to check if event is still available:
function showEventsCount()
{
alert("Registered events: " + eventsID.length + "\nFirst entity has click event: " +
Microsoft.Maps.Events.hasHandler(eventsID[0].marker.entity, "click") /*map.entities.getLength()*/);
}
And in result I get true.
Is this a bug with blocking events, or am I missing something?
Upvotes: 3
Views: 987
Reputation: 17954
The likely issue is that your polygon is above your pushpins thus blocking the click event or there is an issue. Alternatively there is an EntityCollection above the pushpins that has the polygons in them. This is a known issue with Bing Maps v7. Try flatting the way the map renders polygons with the following code:
map.getMode().setOptions({drawShapesInSingleLayer: true });
Upvotes: 1