I have a multilayer canvas
My html
:
<div style='display:inline-block; width:100%; position:relative; top: 0px; left: 0px;'>
<div id='canvas_map_1' class='canvas canvas_map' style='overflow:scroll; background-color: #B4B4B4; z-index: 1; position:absolute; left:133px; top:0px;'></div>
<div id='canvas_map_2' class='canvas canvas_map' style='overflow:scroll; z-index: 2; position:absolute; left:133px; top:0px;'></div>
...
</div>
Given a set of coordinates I want to know if there are some images under it. I'm using Raphael and I want to try the getElementByPoint function (as alternative I could snap the coordinates to a grid and iterate all the images of the canvas to see if some have the same application point (top left corner) and it works but I thinks that will be slow, so I'm looking for faster solutions).
My javascript
:
var paper_map_1 = Raphael(canvas_map_1, '100%', '100%');
var image = paper_map_1.image(image_selected, 27, 42, 33, 27);
var myimage = paper_map_1.getElementByPoint(30, 50) // or (27, 42) but shouldn't do difference
console.log(myimage) // null
myimage
is null while I expected something because there is an image in that position on that canvas. I can select it, move it, etc. Off course the code is much simplified but I don't know what to add.