Can I turn off layer events, and still hook mouse events and pass some to map?

1012
11
11-04-2011 05:46 AM
RexBradford
New Contributor II
I have developed some Javascript code to solve the problem of selecting markers where there are multiple markers overlapping.  By default, the UI seems to act as if obscured markers just don't exist.  My replacement system tracks all my layer markers, spatially organizes them for fast lookup, and then has a UI for tooltips and clicking which presents all the markers under the mouse cursor tip, rather than just the topmost.

It works fine, except that to get the mouse event in the first place to my system, I have had to tie into the layer's event handlers.  I.e., each layer gets its mouse events, and then just hands them off to the new system, which handles all layers together.  I would much rather turn off the marker layers' event handlers altogether, as I don't need them anymore, and just handle all mouse events directly, but still pass those that aren't over a marker on to the underlying map event handlers (for pan, zoom, etc.).  This would be faster (the toolkit has an unnecessary delay when clicking on markers in crowded areas), and I wouldn't have to worry about my marker detection having any pixel-level inaccuracies vis-a-vis the layer's detection, which is currently the "mouse gatekeeper".

Is there a way to capture all the mouse events in the map area, and then grab those I want, and pass the rest on?

Thanks,

Rex Bradford
Direct Relief International
0 Kudos
11 Replies
RexBradford
New Contributor II
Just brain storming here but are you adding your onClick handler to each graphic or is it on the actual graphicsLayer?


Just one handler, on the layer.

dojo.connect(layer, "onClick", function(evt) {
console.log("click!");     // this can take a couple of seconds in crowded area...
layerUI.handleClick(evt);
});
0 Kudos
derekswingley1
Frequent Contributor
So much for that...let us know when we can see this in action somewhere?
0 Kudos