0

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.

jsfiddle

fabio
  • 1,210
  • 2
  • 26
  • 55
  • i think there is no image present in your selected area. its working. [check](https://jsfiddle.net/durga598/dhkh7/64/) – Durga Jul 24 '17 at 09:11
  • @Durga look this https://jsfiddle.net/dhkh7/65/ please – fabio Jul 24 '17 at 09:39
  • 1
    Check [this](https://jsfiddle.net/durga598/dhkh7/66/) its because of position of paper, i guess . check for [more](https://github.com/DmitryBaranovskiy/raphael/issues/512) – Durga Jul 24 '17 at 09:46

0 Answers0