Bing Maps V8 dispatchevent not working

heyyy 96 Reputation points
2021-08-12T05:25:17.23+00:00

When clicking on a pushpin, need to programmatically click on something else.

Microsoft.Maps.Events.addHandler(layer, 'click', function(evt){
            console.log("layerHandler");
            simulateClick();
        });

function simulateClick() {
            console.log("in simulateClick");
          const event = new MouseEvent('click', {
            //view: window,
            bubbles: true,
            cancelable: false
          });
          const elem = [some div]
          console.log("elem: " + elem);

          elem.dispatchEvent(event);
        }

simulateClick() works great on its own, outside the Microsoft.Maps.Events.addHandler code block.

The dispatchEvent does not work when simulateClick is called from inside the Microsoft.Maps.Events.addHandler code block. I see all the console messages, but dispatchEvent does not work.

Have spent 3 days trying to troubleshoot. I understand the MS team has worked hard to provide a Bing Maps product but there have been more than a few bugs that I have wasted several days to discover. I expect better from Microsoft.

Please fix.

Also no tags for bing maps and can't enter custom tags. Aggravated and frustrated. What is going on here.

Windows Maps
Windows Maps
A Microsoft app that provides voice navigation and turn-by-turn driving, transit, and walking directions.
257 questions
0 comments No comments
{count} votes

Accepted answer
  1. heyyy 96 Reputation points
    2021-08-12T15:48:53.967+00:00

    Nvm it was because of event bubbling. My bad lol

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.