I want the color of the area to change when the mouse hovers over the area.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
area:hover{
filter: opacity(0.9) drop-shadow(0 0 0 #ff0000);
}
</style>
</head>
<body>
<!-- Image Map Generated by http://www.image-map.net/ -->
<img src="전국지도.png" usemap="#image-map">
<map name="image-map">
<area target="_blank" alt="서울 관광지" title="서울 관광지" href="" coords="140,147,139,153,143,157,148,163,157,164,165,164,172,160,174,152,169,145,165,135,159,139,153,141,149,145" shape="poly">
<area target="_blank" alt="인천 관광지" title="인천 관광지" href="" coords="121,146,121,159,122,170,125,175,133,170,135,155,131,149" shape="poly">
<area target="_blank" alt="경기 관광지" title="경기 관광지" href="" coords="115,126,128,127,128,105,140,98,147,86,156,81,156,73,174,71,181,81,186,77,187,86,198,87,205,99,217,110,209,131,237,154,229,195,214,212,185,229,170,223,141,229,139,210,140,201,125,194,117,185,140,182,130,176,120,165,120,159,123,149,117,143,115,137" shape="poly">
</map>
</body>
</html>
area 태그를 css로 선택하여 background color를 바꾸어 보았으나 실패하였습니다.
Instead of helping (trying to figure out, actually) with images and map areas I decided to show you how you can create an interactive country map with an in-document SVG.
Compared to an <img>
with <map><area>
an in-doc SVG will give you much more control over user interaction with the map. An SVG is essentially an XML document you can style and manipulate with all the benefits of CSS and Javascript, where an image is nothing more than a static, graphical element.
I downloaded a free SVG map of South Korea and modified it to have an interactive country map in the below snippet.
You can find plenty of SVG references online, so I won't go into specifics, but here is a summary of what I did:
width="0" height="0"
.<defs>
section inside the SVG.<path>
elements as <symbol>
inside <defs>
for later use (reusable elements because symbols don't show up in the viewport, they are just 'definitions').<symbol>
(provinces and specials) as new <symbol>
(entire country), to be used in the main document HTML.<svg><use href="#South-Korea"></svg>
in the main HTML document to show the final interactive map.Once that has been done, you can use 'regular' CSS to control colors, line styles, hover effects, animations, etc.
I inserted an anchor <a>
in the <symbol>
for Seoul linking to its Wikipedia page, just to show how that is done.
It may not be the answer you wanted, but it might well be the answer you needed. Let me know...
Check out d-maps.com South Korea for more interesting SVG maps you could use.
The number of character in my answer and code exceed the maximum allowed on Stackoverflow so I have to post the link to my Codepen Demo. Sorry for that, but upside is that you can fork it and easily modify it to your needs.
snippet with only a partial country.
.country {
height: calc(100vh - 4em);
padding: 2rem;
}
svg {
display: block;
width : 100%;
height: 100%;
}
/*****************************/
/* Styling of the in-doc SVG */
/*****************************/
path { fill: #f5f5f5; stroke: #000; stroke-width: 2px }
path:hover { fill: #ff0000; filter: opacity(90%)/* url(#dropshadow)*/ }
circle { fill: blue; stroke: red; stroke-width: 4 }
circle:hover { fill: red; stroke: blue }
/* Seoul */
a path:hover { fill: green }
/***********************/
/* DEMO page eye-candy */
/***********************/
* { box-sizing: border-box }
body {
margin: 0;
width: 100%; min-height: 100vh;
background-color: #ddd;
}
h3 {
margin: 0;
padding: 1em;
background-color: black; color: white;
text-align: center;
}
<h3>Showing usage of an in-doc SVG country (parts) map</h3>
<div class="country">
<svg><use href="#South-Korea"></use></svg>
</div>
<!--
In document SVG, hidden from view because of width/height=0
Various <path> define the country/province outlines
<symbol><use> combines various <symbol> into collections
<svg><use> In <body> shows the selected <symbol>
-->
<svg width="0" height="0" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!--
Copyright (c) 2017 Pareto Softare, LLC DBA Simplemaps.com
Free for Commercial Use, full terms at http://simplemaps.com/resources/svg-license
Attribution is appreciated! http://simplemaps.com
map downloaded from: https://simplemaps.com/resources/svg-kr
-->
<style>
/* All styling is done in the document main CSS section */
</style>
<defs>
<filter id="dropshadow" x="0" y="0" width="200%" height="200%">
<feOffset result="offOut" in="SourceAlpha" dx="5" dy="5" />
<feGaussianBlur result="blurOut" in="offOut" stdDeviation="3" />
<feBlend in="SourceGraphic" in2="blurOut" mode="normal" />
</filter>
<!-- Define Province/Islands symbols that make up the entire country -->
<symbol vi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ewbox="0 0 1000 1064" id="KOR2497" name="Seoul">
<a target="_blank" rel="noopener" href="https://en.wikipedia.org/wiki/Seoul">
<path d="M398.4 211.4l-1.5 5.7 4.4-0.1 3.7-1.3 3.2-0.1 1.2 2.9-0.4 3-2.2 1.1-2.4 1.6 0 3.6 1.3 1.5-2.7 3.7-1.5 2.6-4.1 2.4-4.5 1.1-4.7 2.3-1.8-4.1-3.9 0.9-4 1.2-2.7 1.6-2.9 0.5-6.8-0.3-4.7-6.1-4.6-1.4-3.1-2-0.8-5.8-3.2-4.4-3.7-4.6 2.3-5.1 4.5 0.2 5 3.1 3.8-1.2 3.4-2.1 0.2-3.4 0.9-3.2 7.1-0.7 3.7-4.6 2.2-4.8 3.2-3.3 4.9-1.2 5.7 0.4 2.7 4.7 1.1 6.4 1.6 4.4 0.1 4.9z">
<title>Seoul (links to info at Wikipedia)</title>
</path>
</a>
</symbol>
<symbol viewbox="0 0 1000 1064" id="KOR2498" name="Gyeonggi"><path d="M245.6 280.6l-0.7 1.2-2 2.1-1.4 0.6-1.9 0.3-1.6-0.7-1.4-2.9-1.5 0.8-0.7-0.2 0.5-4 0.9-2.7 1.1-1.6 1.3 0.9 1.1 1.9 1.2 0.9 3.9 2.1 1.2 1.3z m50.4-1.9l-1.3 1.6-1.8 0.4-1.2-0.9-1.3 0.1-1.1-0.6-0.3-2.5 0.3-2.6 1.3-1.8 2.8-1.5 3.6 0.3 1.6 1.1 0.6 2.4-0.7 0.9-1.7 0.5-0.6 1.3-0.2 1.3z m15.2-7.5l0.6 1.6 1.9 1.1 3 1.2 0.8 0.9 0.8 2.6-0.8 1.8-8.1 6.5-3.7 0.4 0.1-1 1.7-2.3 0.2-1.4-0.7-1.1 2-2.4 0.1-2.4-0.8-2.9-1.2-2-1.2-1.4 0.4-0.4 2.6 1.3 2.2-2 0.5 0.2-0.4 1.7z m-139.3-74.8l-0.9 0.4-1.4-3.5 0.2-1.8 1.2-0.2 1.8 0.3 1.1 1.1-0.5 2.2-1.5 1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9 3.6-2.1 3.6 0.9 4.5-1.2 4.5-9.7 20.8-7.1 17.4-8.5 15.9z m-76.3-89.2l-0.1-4.9-1.6-4.4-1.1-6.4-2.7-4.7-5.7-0.4-4.9 1.2-3.2 3.3-2.2 4.8-3.7 4.6-7.1 0.7-0.9 3.2-0.2 3.4-3.4 2.1-3.8 1.2-5-3.1-4.5-0.2-2.3 5.1 3.7 4.6 3.2 4.4 0.8 5.8 3.1 2 4.6 1.4 4.7 6.1 6.8 0.3 2.9-0.5 2.7-1.6 4-1.2 3.9-0.9 1.8 4.1 4.7-2.3 4.5-1.1 4.1-2.4 1.5-2.6 2.7-3.7-1.3-1.5 0-3.6 2.4-1.6 2.2-1.1 0.4-3-1.2-2.9-3.2 0.1-3.7 1.3-4.4 0.1 1.5-5.7z"><title>Gyeonggi</title></path></symbol>
<!-- Define cities, villages, locations, water, roads etc -->
<symbol id="symbol-south-korea-specials" viewbox="0 0 1000 1064">
<!-- Not sure what these are for. Cities, capitals? -->
<circle r="15" cx="382.7" cy="319.5" id="0"><title>some city 1</title></circle>
<circle r="15" cx="449.5" cy="323.2" id="1"><title>some city 2</title></circle>
</symbol>
<!-- Construct the country from <symbol> definitions -->
<symbol id="symbol-south-korea">
<use href="#KOR2496"></use>
<use href="#KOR2497"></use>
<use href="#KOR2498"></use>
</symbol>
<symbol id="South-Korea">
<use href="#symbol-south-korea"></use>
<use href="#symbol-south-korea-specials"></use>
</symbol>
</defs>
</svg>