JSFiddle - React, Tailwind, and code Playground
by neveldo
HTML
<script src="https://cdn.rawgit.com/DmitryBaranovskiy/raphael/v2.1.4/raphael-min.js"></script>
<script src="https://cdn.rawgit.com/neveldo/jQuery-Mapael/1.1.0/js/jquery.mapael.js"></script>
<script src="https://cdn.rawgit.com/neveldo/jQuery-Mapael/1.1.0/js/maps/france_departments.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.12/jquery.mousewheel.min.js"></script>
<div class="container">
<h1>Map with href on areas and plotted cities</h1>
<div class="mapcontainer">
<div class="map">
<span>Alternative content for the map</span>
</div>
</div>
</div>
CSS
.map {
background-color:#cddee0;
margin-bottom:10px;
position:relative;
}
/* CSS for the zoom-in and zoom-out buttons */
.zoomIn, .zoomOut {
background-color:#fff;
border:1px solid #ccc;
color:#000;
width:15px;
height:15px;
line-height: 15px;
text-align:center;
border-radius:3px;
cursor:pointer;
position:absolute;
top : 10px;
font-weight:bold;
left : 10px;
-webkit-user-select: none; // For Webkit
-khtml-user-select: none;
-moz-user-select: none; // For Mozilla
-o-user-select: none;
user-select: none; // Default
}
.zoomOut {
top:30px;
}
/* CSS for the tooltip displayed on mousehover on elements */
.mapTooltip {
position : fixed;
background-color : #474c4b;
moz-opacity:0.70;
opacity: 0.70;
filter:alpha(opacity=70);
border-radius:10px;
padding : 10px;
z-index: 1000;
max-width: 200px;
display:none;
color:#fff;
}
body {
font-family:Helvetica,Arial,sans-serif;
}
h1 {
color:#5d5d5d;
font-size:30px;
}
.container {
max-width: 800px;
margin:auto;
}
JavaScript
$(function(){
$(".mapcontainer").mapael({
map : {
name : "france_departments"
// Enable zoom on the map
, zoom : {
enabled : true
}
// Set default plots and areas style
, defaultPlot : {
attrs : {
fill: "#004a9b"
, opacity : 0.6
}
, attrsHover : {
opacity : 1
}
, text : {
attrs : {
fill : "#505444"
}
, attrsHover : {
fill : "#000"
}
}
}
, defaultArea: {
attrs : {
fill : "#f4f4e8"
, stroke: "#ced8d0"
}
, attrsHover : {
fill: "#a4e100"
}
, text : {
attrs : {
fill : "#505444"
}
, attrsHover : {
fill : "#000"
}
}
}
},
// Customize some areas of the map
areas: {
"department-56" : {
text : {content : "Morbihan", attrs : {"font-size" : 10}},
tooltip: {content : "Morbihan (56)"},
href:"http://fr.wikipedia.org/wiki/Morbihan"
},
"department-21" : {
attrs : {
fill : "#488402"
}
, attrsHover : {
fill: "#a4e100"
},
href:"http://fr.wikipedia.org/wiki/C%C3%B4te-d%27Or",
target:"_blank"
}
},
// Add some plots on the map
plots : {
// Image plot
'paris' : {
type : "image",
url: "http://www.neveldo.fr/mapael/assets/img/marker.png",
width: 12,
height: 40,
latitude : 48.86,
longitude: 2.3444,
attrs : {
opacity : 1
},
attrsHover: {
transform : "s1.5"
},
href:"http://fr.wikipedia.org/wiki/Paris",
target:"_blank"
},
// Circle plot
'lyon' : {
type: "circle",
size:50,
latitude :45.758888888889,
longitude: 4.8413888888889,
value : 700000,
tooltip: {content : "<span style=\"font-weight:bold;\">City :</span> Lyon"},
text : {content : "Lyon"},
href:"http://fr.wikipedia.org/wiki/Lyon"
},
// Square plot
'rennes' : {
type :"square",
size :20,
latitude : 48.114166666667,...