extract the unique node id given the x and y coordinates

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • avvz
    New Member
    • Mar 2009
    • 3

    extract the unique node id given the x and y coordinates

    Hi,

    I need to get the unique node assosicated given 2 sets of x and y coordinates.
    I have the start and end coordinates of a selected region. And now I need to get the unique ID associated with both of it.

    Please do let me know as soon as possible as to how I can go about doing this.

    Thanks..
    avz
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Originally posted by avvz
    Hi,

    I need to get the unique node assosicated given 2 sets of x and y coordinates.
    I have the start and end coordinates of a selected region. And now I need to get the unique ID associated with both of it.
    You have to give some more detail: how are those x,y,ID triples stored? What is/are stored in those two sets? Just (x,y) coordinates or the Carthesian product of all coordinates? Are you looking for a position on a (geographical) map?

    kind regards,

    Jos

    Comment

    • avvz
      New Member
      • Mar 2009
      • 3

      #3
      Hi Jos,

      Thank you for replying.
      The x and y coordinates, are the coordinates where the screen starts at (0,0),
      So when the mouse clicks to select an area, (assume a square ), then i get the top left x y position and the bottom right x y position.
      So now that I have these values, I need to get the unique ID from the DOM tree. I learnt that for each element on the HTML page there is a unique node id associated with it.
      So I need to get the unique node ids with the pair of x n y coordinates I have got.
      Please do let me know if you need more information.

      Thanks,
      Avanthi

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        For every component in that DOM tree you need to get the (x,y) (w,h) values (the top/left coordinate and width and height) and check whether or not they lie inside the given (x,y) (w, h) values. If the z value of those components is available as well, take the component which is nearest to the top of the z stack.

        kind regards,

        Jos

        Comment

        • avvz
          New Member
          • Mar 2009
          • 3

          #5
          Hi Jos,

          Thanks for the reply. Actually that is simliar to the logic I was thinking, but I just needed some code to go about doing this. So is there some code which I could get from anywhere?

          Comment

          • JosAH
            Recognized Expert MVP
            • Mar 2007
            • 11453

            #6
            Originally posted by avvz
            Hi Jos,

            Thanks for the reply. Actually that is simliar to the logic I was thinking, but I just needed some code to go about doing this. So is there some code which I could get from anywhere?
            Do you know how to iterate over your components in your DOM? If so you have solved the major part of your problem already.

            kind regards,

            Jos

            Comment

            Working...