Is it possible to calculate width and height for each poly area on image map using coords?
I have an image and use image map with multiple different sized polys. I need to find center point each one.
Is it possible to calculate width and height for each poly area on image map using coords?
I have an image and use image map with multiple different sized polys. I need to find center point each one.
To find the center point, you need to find the minimum and maximum X and Y coordinates of the polygon, and then take the midpoint of each to get the average center point. Here's a function that will do this for an array of imagemap areas. The function accepts an array rather than just one area in case you need a center point from several areas, as are typical in geographical image maps.
Working example here that will draw a circle on the center point of the chose US state: http://jsfiddle.net/jamietre/6ABfa/