Bing Map Drawing Tool - Events

I am using Bing Map Ajax Control V7 for testing / training. I created some pushpins with infoboxes 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 a DrawningToolModule to display.

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 the data, the reaction of pushpins to a click is fine. After adding custom pushpins from DrawingTool - the events are fine. After drawing any shape (polygon, polyfile, circle) - my button events are not called.

I added a helper function to check if an event is 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 as a result, I believe.

Is this an event blocking bug or am I missing something?

+3


source to share


1 answer


The likely problem is that your polygon is above your buttons, thus blocking the click event or a problem arises. Alternatively, there is an EntityCollection label above the keys that have polygons. This is a known issue with Bing Maps v7. Try to set how polygons are displayed with the following code:



map.getMode().setOptions({drawShapesInSingleLayer: true });

      

+1


source







All Articles