[英]How to set an image or colour on the map (html) coordinates?
I am trying to use colors in the coordinates of map instead of the transparent clickable space. 我正在尝试在地图的坐标中使用颜色,而不是在透明的可点击空间中使用颜色。 When I click the circle (I am working only with circles) the colour should change (example from red to blue).
当我单击圆圈(我仅使用圆圈)时,颜色应该改变(例如,从红色变为蓝色)。
I have tried with background-color but this doesn't work, I think the correct way to do this is with javascript or jquery. 我已经尝试过使用background-color,但这是行不通的,我认为正确的方法是使用javascript或jquery。
<img src="mapworld.jpg" width="600" height="400" alt="mapworld" usemap="#mapworld">
<map name = "mapworld">
<area id = "s1" target="_blank" alt="Circle1" title="Position 1"
href="www.google.com.ec" coords="10, 20, 4" shape="circle">
</map>
After doing some research I have discovered this JQuery library which takes care of highlighting areas automatically and all you have to do is call the .maphilight()
on your image when the document
is ready
. 经过研究后,我发现了这个JQuery库,它会自动突出显示区域,您要做的就是在
ready
document
时在图像上调用.maphilight()
。
You will need to download and implement these two files in your html file: 您将需要在html文件中下载并实现这两个文件:
JQuery: https://code.jquery.com/jquery-3.3.1.min.js jQuery的: https : //code.jquery.com/jquery-3.3.1.min.js
This one will have to be in a seperate file and included after JQuery
(in your html file ofc). 这将必须在单独的文件中,并包含在
JQuery
之后 (在您的html文件ofc中)。
MapHighlight lib: https://raw.githubusercontent.com/kemayo/maphilight/master/jquery.maphilight.js MapHighlight库: https ://raw.githubusercontent.com/kemayo/maphilight/master/jquery.maphilight.js
Here's a JSFiddle to show a demo : http://jsfiddle.net/8Lw7saf6/1/ 这是一个展示示例的JSFiddle: http : //jsfiddle.net/8Lw7saf6/1/
Usage: 用法:
/* JQUERY */
$(document).ready(function(){
$('img[usemap]').maphilight();
});
here are two demos from the doc : 这是doc的两个演示:
https://davidlynch.org/projects/maphilight/docs/demo_usa.html https://davidlynch.org/projects/maphilight/docs/demo_usa.html
https://davidlynch.org/projects/maphilight/docs/demo_world.html https://davidlynch.org/projects/maphilight/docs/demo_world.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.