Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect area tag onClick in a Image Map in React

I want to detect the onClick & onHover on different parts of a image.

<img src={physicalimage} id="physicalimage" usemap="#image-map"/>
   <map name="image-map">
   <area target="" onClick={this.consoleMessage("bpleft")} alt="bpleft" title="bpleft"  coords="223,201,269,254" shape="rect" />
   <area target="" onClick={this.consoleMessage("bpright")} alt="bpright" title="bpright" coords="60,199,101,259" shape="rect" />
   <area target="" onClick={this.consoleMessage("heart")} alt="heartrate"  title="heartrate" coords="169,124,219,183" shape="rect" />
</map>

I use react library for developing my website. I am not able to detect the onClick event. Are there any other alternative?

like image 820
Pabba Anu Bharath Avatar asked Feb 15 '18 05:02

Pabba Anu Bharath


1 Answers

I suggested you to use a maintained library with the all feature of react-image-mapper with extra functionality like responsive

https://github.com/NishargShah/react-img-mapper

https://www.npmjs.com/package/react-img-mapper

like image 160
Nisharg Shah Avatar answered Sep 22 '22 00:09

Nisharg Shah