Search code examples
jqueryhtmlcoordinatesimagemap

Check Element Position Inside Image Map


Is there any easy way to know if a DIV element is positioned inside the polygon image map?

I need a draggable element to be put on a predefined place of an image e.g. Russia country, and I use the image map coordinates poly to set the area of drop.

Note that i must do this because I'm extracting the data from an existing XML which has been used for Flash, and I would appreciate to not changing the ways it has been done.


Solution

  • I guess you can check poly-poly intersection using javascript (http://wikicode.wikidot.com/check-for-polygon-polygon-intersection). First poly - moveable DIV, second one - map you're placing DIV on (or list of countries polygons). On the "move" event of the object you need to place on the map - check the intersection and if it's true - make something accordingly.