admin管理员组文章数量:1430539
Let's say we have a Risk-like world map which is divided into regions of custom shape.
How does one enable the user to select an individual region using HTML5/JavaScript? I assume Canvas2D is the first step, but then what?
Let's say we have a Risk-like world map which is divided into regions of custom shape.
How does one enable the user to select an individual region using HTML5/JavaScript? I assume Canvas2D is the first step, but then what?
Share Improve this question edited Jun 20, 2020 at 9:12 CommunityBot 11 silver badge asked Jun 27, 2013 at 15:06 HowieHowie 2,7786 gold badges35 silver badges61 bronze badges 1- 2 raphaeljs has a demo that uses a svg to make a clickable map raphaeljs./australia.html – user18428 Commented Jun 27, 2013 at 15:08
2 Answers
Reset to default 4There are gazillions of great libraries. To name a few:
- http://d3js/
- http://raphaeljs./
- http://paperjs/
- http://box2d-js.sourceforge/
- http://threejs/
Specific examples:
- http://bl.ocks/mbostock/2206590
- http://raphaeljs./world/
- http://raphaeljs./australia.html
You can create a map tag that you then add to your img tag. In your map tag, you define different areas where the user can click. Then, you can define javascript functions to be call on the mousedown event of each area.
I don't like explanation, I prefer examples! So here a link I just found that describe this technique better :
http://www.tutorialspoint./javascript/javascript_image_map.htm
And by the way, you don't need to manually create the areas. There are a tons of WYSIWYG tools out there that will create it for you!
本文标签: Risklike (areabased) maps and HTMLJavaScriptStack Overflow
版权声明:本文标题:Risk-like (area-based) maps and HTMLJavaScript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745447256a2658720.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论