Nvm it was because of event bubbling. My bad lol
Bing Maps V8 dispatchevent not working
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.