javascript - Convert absolute coordinates to relative coordinates -


i have image can place markers wherever click.: http://jsbin.com/ojahel/10/edit

i need save marker positions in json array , send server. have done. coordinates i'm sending absolute think. because need use them in page, , when display same image before markers not in same position, since not being place coordinates relative image self, screen coordinates.

any idea how can convert them when submit form, , function "convert" relative coordinates absolute when display image in page?

i think have find out @ coordinates image placed on first page. let call them x_abs(picture),y_abs(picture). can compute relative coordinates of marker by

x_rel(marker) = x_abs(marker) - x_abs(picture) y_rel(marker) = y_abs(marker) - y_abs(picture) 

on next page have find out again image placed, , retain absolute coordinates of marker by

x_abs(marker) = x_rel(marker) + x_abs(picture) y_abs(marker) = y_abs(marker) + y_abs(picture) 

note x_abs(picture),y_abs(picture) referring absolute coordinates of picture in second page. hope helps


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -