1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377
| <!DOCTYPE HTML>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>test-kit-SVG</title>
<meta name="Author" content="LaReineDAngleterre">
<style>
html { height: 100%; }
body {
margin: 20px 0 0 20px;
padding: 0;
font: 1em/1.5 Verdana,sans-serif;
height: calc(100% - 20px);
}
#dvg {
border: 1px solid red;
/*cadre rouge autour de la carte*/
width: 810px;
height: 820px;
position:relative;
overflow: hidden;
margin:auto;
background-color: rgb(60, 107, 119);
}
svg {
height: 820px;
}
svg a{
cursor:pointer
}
svg g path {
fill: rgb(25, 25, 44);
stroke: #cc4646;
stroke-width: 0.5;
transition: fill 0.1s;
}
svg g:hover path {
fill: rgb(39, 39, 85);
}
svg g a text {
fill: #e8e809;
font-size: 6px;
font-style: italic;
}
svg g:hover a text {
fill: #fdfefe;
font-weight: bold;
}
#commune_descriptif {
transform: scaleY(0);
transform-origin: 50% 0;
transition:transform .4s ease;
position:absolute;
top: 0;
left: ;
padding: 1em;
border: 1px solid green;
font-size: 1em;
color: #000;
background-color: rgba(255,255,255,.8);
pointer-events: none;
}
.commune_descriptif_affiche {
transform: scaleY(1) !important;
}
</style>
<script>
addEventListener('load',function(){
new zoom_svg('cadreSVG')
},false);
function zoom_svg(elem){
this.elem=document.getElementById(elem);
this.elem.style.marginLeft=window.getComputedStyle(this.elem, null).marginLeft;
this.elem.style.marginTop=window.getComputedStyle(this.elem, null).marginTop;
this.elem.onmousedown=this.prep_drag.bind(this);
this.elem.onmouseup=this.fin_drag.bind(this);
this.elem.addEventListener('wheel', this.dirizoom.bind(this), false);
this.rar=true;
this.setX=0;
this.setY=0;
this.deplacer=0;
var that=this;
this.drag=function(e){that.posi.call(that,e)}
var all=this.elem.getElementsByTagName('a');
for(var i=0;i<all.length;i++)
{
var lien=all[i].getAttribute('href')
all[i].removeAttribute('href')
all[i].addEventListener("mouseup", function(lien){
if(this.elem.style.marginLeft==this.deplacer){
document.location.href=lien
}
}.bind(this,lien)
, false)
}
}
zoom_svg.prototype={
//fonction pour le zoom directionnel
dirizoom:function(e){
var dde=document.documentElement.scrollTop ? document.documentElement : document.body;
e.preventDefault();
var val = e.deltaY > 0 ? -0.15 : 0.15;
var elem=this.elem;
var bound=elem.getBoundingClientRect();
var bound_parent=elem.parentNode.getBoundingClientRect();
var setX=e.pageX;
var setY = e.pageY;
var gauche=parseInt(this.elem.style.marginLeft)
var haut=parseInt(this.elem.style.marginTop)
var dirle=bound.width-setX+gauche+bound_parent.left+dde.scrollLeft;
var dirto=bound.height-setY+haut+bound_parent.top+dde.scrollTop;
var lf=bound.width;
var rf=bound.height;
elem.style.width=lf+(lf*val)+'px';
elem.style.height=rf+(rf*val)+'px';
var bound=elem.getBoundingClientRect();
elem.style.marginLeft=gauche-((bound.width-lf))+(dirle*val)+'px';
elem.style.marginTop=haut-((bound.height-rf))+(dirto*val)+'px';
},
//partie drag
prep_drag:function(evt){
if(this.rar){
evt.preventDefault();
this.setX=evt.clientX;
this.setY=evt.clientY;
document.documentElement.addEventListener("mousemove", this.drag, false)
this.rar=false;
this.deplacer=this.elem.style.marginLeft;
}
},
fin_drag:function(e){
if(!this.rar){
document.documentElement.removeEventListener("mousemove", this.drag, false)
this.rar=true;
}
},
posi:function(e){
e.preventDefault();
var bound=this.elem.getBoundingClientRect();
this.elem.style.marginLeft=parseInt(this.elem.style.marginLeft)-(this.setX-e.clientX)+"px";
this.elem.style.marginTop=parseInt(this.elem.style.marginTop)-(this.setY-e.clientY)+"px";
this.setX=e.clientX;
this.setY=e.clientY;
}
}
</script>
<script>
addEventListener('load',function(){
document.getElementById('cadreSVG').addEventListener('mousemove', OverSVG_element );
})
function OverSVG_element(e) {
var g_Desc=e.target.parentNode.parentNode;
var DivDesc = document.getElementById('commune_descriptif')
if (g_Desc.dataset.description || g_Desc.parentNode.dataset.description) {
let N_desc = g_Desc.dataset.description || g_Desc.parentNode.dataset.description;
if (N_desc != DivDesc.innerHTML)
{
DivDesc.innerHTML = N_desc;
}
DivDesc.style.left = e.clientX + window.scrollX + 'px';
DivDesc.style.top = e.clientY + window.scrollY + 'px';
DivDesc.classList.add('commune_descriptif_affiche');
}
else
{
DivDesc.innerHTML = '';
DivDesc.classList.remove('commune_descriptif_affiche');
}
}
</script>
</head>
<body>
<main>
<button id='bt_trace'>trace</button>
<h1>« Zoom » élément SVG</h1>
<div id='dvg'>
<svg id="cadreSVG" viewBox="130 128 400 410">
<g data-description="Alleriot<br> 0,00 Km² <br>0 habitants">
<a id="region-02" href="alleriot_cantons.html" data-img="img2" data-txt=" Alleriot">
<path id="02" title="Alleriot" d="M289.1,256.3 277.7,261.2 265.6,259.3 254.2,256.7 242,244.4 242.7,238.2 213.5,215.9 208.3,204.6 228.3,188.1 241.1,166.1 252.1,181 251.5,204.9 270,207.7 283,219z" />
<text transform="matrix(1 0 0 1 247.0518 232.501)">
<tspan x="5" y="0" class="texte">Alleriot</tspan>
</text>
</a>
</g>
<g data-description="Baudrieres<br> 0,00 Km² <br>0 habitants">
<a id="region-03" href="baudrieres_cantons.html" data-img="img3" data-txt=" Baudrieres">
<path id="03" title="Baudrieres" d="M296,521.5 276.7,488.4 271.6,484.4 258.8,486.3 268.5,436.3 293.3,430.2 311.6,412.4 322.8,418.4 345.1,406 353.5,415.2 347.4,480.7 335.4,484.1 333.4,490 341.6,506.3 330.2,521z" />
<text transform="matrix(1 0 0 1 286.791 466.0547)">
<tspan x="5" y="0" class="texte">Baudrieres</tspan>
</text>
</a>
</g>
<g data-description="Chatenoy En Bresse<br> 0,00 Km² <br>0 habitants">
<a id="region-04" href="chatenoy_en_bresse_cantons.html" data-img="img4" data-txt=" Chatenoy En Bresse">
<path id="04" title="Chatenoy En Bresse" d="M242,244.4 237.1,247.8 202.2,239.8 174.1,242 158.4,233.3 157.4,222.6 170.8,213.3 190.9,224.1 208.3,204.6 213.5,215.9 242.7,238.2z" />
<text transform="matrix(1 0 0 1 159.208 235.29)">
<tspan x="15" y="-3" class="texte">Chatenoy En Bresse</tspan>
</text>
</a>
</g>
<g data-description="Guerfand<br> 0,00 Km² <br>0 habitants">
<a id="region-05" href="guerfand_cantons.html" data-img="img5" data-txt=" Guerfand">
<path id="05" title="Guerfand" d="M363.1,272 332,273.8 320.8,259.5 327.5,230 333.3,232.4 348.7,222.7 354.8,224.4 366.4,253.5z" />
<text transform="matrix(1 0 0 1 326.5293 252.022)">
<tspan x="5" y="0" class="texte">Guerfand</tspan>
</text>
</a>
</g>
<g data-description="Lans<br> 0,00 Km² <br>0 habitants">
<a id="region-06" href="lans_cantons.html" data-img="img6" data-txt=" Lans">
<path id="06" title="Lans" d="M212.5,311.6 200.9,290.7 186.8,279 199.8,260.5 211.8,258.3 229.8,265.6 244.1,278.4 263.1,282.6 251.7,299.3 234,299.5z" />
<text transform="matrix(1 0 0 1 220.5591 291.0635)">
<tspan x="0" y="-5" class="texte">Lans</tspan>
</text>
</a>
</g>
<g data-description="Lessard En Bresse<br> 0,00 Km² <br>0 habitants">
<a id="region-07" href="lessard_en_bresse_cantons.html" data-img="img7" data-txt=" Lessard En Bresse">
<path id="07" title="Lessard En Bresse" d="M444.3,360.8 429.5,349.1 417,346.7 405.4,331.8 355.9,333.5 360.8,324.2 373,324.4 387.9,314.1 405.7,310.7 410.9,299.6 444.9,314.3 440.6,344.8 446.9,360.7z" />
<text transform="matrix(1 0 0 1 376.0293 329.4087)">
<tspan x="10" y="-4" class="texte">Lessard En Bresse</tspan>
</text>
</a>
</g>
<g data-description="L'Abergement Sainte Colombe<br> 0 Km² <br>0 habitants">
<a id="region-01" href="l_abergement_sainte_colombe_cantons.html" data-img="img1" data-txt=" L'Abergement Sainte Colombe">
<path id="01" title="L'Abergement Sainte Colombe" d="M352.8,343.5 325.5,327.9 318.6,341 287.8,325.7 291.2,318.8 297.2,322.2 306.3,294.9 302.4,276.6 307.3,265.2 320.8,259.5 332,273.8 363.1,272 376.4,296.5 405,287.2 410.9,299.6 405.7,310.7 387.9,314.1 373,324.4 360.8,324.2 355.9,333.5z" />
<text transform="matrix(1 0 0 1 307.7061 302.2188)">
<tspan x="10" y="6" class="texte">L'Abergement Sainte Colombe</tspan>
</text>
</a>
</g>
<g data-description="Montcoy<br> 0,00 Km² <br>0 habitants">
<a id="region-08" href="montcoy_cantons.html" data-img="img8" data-txt=" Montcoy">
<path id="08" title="Montcoy" d="M307.3,265.2 300.7,255.8 289.1,256.3 283,219 293.4,194.9 293.2,175.6 321.5,203.1 327.5,230 320.8,259.5z" />
<text transform="matrix(1 0 0 1 290.2764 232.501)">
<tspan x="5" y="0" class="texte">Montcoy</tspan>
</text>
</a>
</g>
<g data-description="Oslon<br> 0,00 Km² <br>0 habitants">
<a id="region-09" href="oslon_cantons.html" data-img="img9" data-txt=" Oslon">
<path id="09" title="Oslon" d="M263.1,282.6 244.1,278.4 229.8,265.6 211.8,258.3 199.8,260.5 202.2,239.8 237.1,247.8 242,244.4 254.2,256.7 265.6,259.3z" />
<text transform="matrix(1 0 0 1 237.9883 268.0566)">
<tspan x="0" y="-3" class="texte">Oslon</tspan>
</text>
</a>
</g>
<g data-description="Ouroux Sur Saone<br> 0,00 Km² <br>0 habitants">
<a id="region-10" href="ouroux_sur_saone_cantons.html" data-img="img10" data-txt=" Ouroux Sur Saone">
<path id="10" title="Ouroux Sur Saone" d="M234.9,412.4 223.7,384.1 214.2,376.5 192.3,360.4 213.2,349 212.5,311.6 234,299.5 251.7,299.3 254,311.1 248,321.1 271.4,340.6 288.9,339.7 295.3,349.9 293.1,361.5 280.2,375.3 275.5,393.5 258.4,411.8z" />
<text transform="matrix(1 0 0 1 216.376 362.1758)">
<tspan x="10" y="0" class="texte">Ouroux Sur Saone</tspan>
</text>
</a>
</g>
<g data-description="Saint Christophe En Bresse<br> 0,00 Km² <br>0 habitants">
<a id="region-11" href="saint_christophe_en_bresse_cantons.html" data-img="img11" data-txt=" Saint Christophe En Bresse">
<path id="11" title="Saint Christophe En Bresse" d="M337.9,375.1 314.2,377.6 304.2,362.8 293.1,361.5 295.3,349.9 288.9,339.7 271.4,340.6 248,321.1 254,311.1 251.7,299.3 263.1,282.6 265.6,259.3 277.7,261.2 289.1,256.3 300.7,255.8 307.3,265.2 302.4,276.6 306.3,294.9 297.2,322.2 291.2,318.8 287.8,325.7 318.6,341 325.5,327.9 352.8,343.5 360.5,352.1 339.7,363.2z" />
<text transform="matrix(1 0 0 1 297.9453 357.9932)">
<tspan x="-37" y="-60" class="texte">Saint-Christophe</tspan>
<tspan x="-30" y="-53" class="texte">en-Bresse</tspan>
</text>
</a>
</g>
<g data-description="Saint Germain Du Plain<br> 0,00 Km² <br>0 habitants">
<a id="region-12" href="saint_germain_du_plain_cantons.html" data-img="img12" data-txt=" Saint Germain Du Plain">
<path id="12" title="Saint Germain Du Plain" d="M250,487.4 236.4,424.8 234.9,412.4 258.4,411.8 275.5,393.5 280.2,375.3 293.1,361.5 304.2,362.8 314.2,377.6 337.9,375.1 351.1,386.3 342.7,400.5 345.1,406 322.8,418.4 311.6,412.4 293.3,430.2 268.5,436.3 258.8,486.3z" />
<text transform="matrix(1 0 0 1 277.7275 399.127)">
<tspan x="0" y="5" class="texte">Saint Germain Du Plain</tspan>
</text>
</a>
</g>
<g data-description="Tronchy<br> 0,00 Km² <br>0 habitants">
<a id="region-14" href="tronchy_cantons.html" data-img="img14" data-txt=" Tronchy">
<path id="14" title="Tronchy" d="M428.4,376.8 410,378.3 405,366.7 384.6,351.6 360.5,352.1 352.8,343.5 355.9,333.5 405.4,331.8 417,346.7 429.5,349.1 444.3,360.8z" />
<text transform="matrix(1 0 0 1 371.8467 344.7461)">
<tspan x="10" y="0" class="texte">Tronchy</tspan>
</text>
</a>
</g>
<g data-description="Villegaudin<br> 0,00 Km² <br>0 habitants">
<a id="region-15" href="villegaudin_cantons.html" data-img="img15" data-txt=" Villegaudin">
<path id="15" title="Villegaudin" d="M482,223.1 448.3,241.6 429.2,245 410.4,240.7 415.9,229.6 411.4,207 437.7,174 444,183.9 438.7,201.3 469.3,220.8 472.7,215.7z" />
<text transform="matrix(1 0 0 1 421.3457 226.2266)">
<tspan x="5" y="0" class="texte">Villegaudin</tspan>
</text>
</a>
</g>
<g data-description="Saint Martin En Bresse<br> 0,00 Km² <br>0 habitants">
<a id="region-13" href="saint_martin_en_bresse_cantons.html" data-img="img13" data-txt=" Saint Martin En Bresse">
<path id="13" title="Saint Martin En Bresse" d="M405,287.2 376.4,296.5 363.1,272 366.4,253.5 354.8,224.4 348.7,222.7 333.3,232.4 327.5,230 321.5,203.1 331.6,182.9 347.5,178.6 377,159 379.8,147.4 399,139.3 416.8,146.3 428.4,142.4 437.7,174 411.4,207 415.9,229.6 410.4,240.7 401.1,256.5 414.2,277 410.6,287.6z" />
<text transform="matrix(1 0 0 1 332.8042 196.9453)">
<tspan x="10" y="10" class="texte">Saint Martin En Bresse</tspan>
</text>
</a>
</g>
<!-- -->
</svg>
</div>
</main>
<div id="commune_descriptif"></div>
</body>
</html> |
Partager