Bing Maps: Handle right click event separately for map and for pin layer

Viewed 92

I am using the Bing Maps library (v8) and I have two different context menu's that I want to pop up, one when they right click on a blank area of the map and another one when they right click on a pin.

Here's my right click initialization code:

let map = new Microsoft.Maps.Map(/*element reference*/, {/*some options*/});

let pinLayer = new Microsoft.Maps.Layer();

Microsoft.Maps.Events.addHandler(pinLayer, 'rightclick', (e: any) => console.log("pin clicked");
map.layers.insert(pinLayer);

Microsoft.Maps.Events.addHandler(map, 'rightclick', (e: any) => console.log("map clicked");

It works just fine when I right click the map, I just get "map clicked"

But when I right click a pin, it says "map clicked" "pin clicked"

Is there a clean way for me to only fire the pin event when a pin is right clicked? (other than resorting to setTimeout)

0 Answers
Related