forked from 10bestdesign/jqvmap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
112 lines (98 loc) · 3.46 KB
/
index.html
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
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<script src="bowers/jquery/dist/jquery.js" type="text/javascript"></script>
<script src="bowers/underscore/underscore.js" type="text/javascript"></script>
<link href="jqvmap/jqvmap.css" media="screen" rel="stylesheet" type="text/css"/>
<script src="jqvmap/jquery.vmap.js" type="text/javascript"></script>
<script src="data/jquery.vmap.world.js" type="text/javascript"></script>
<script src="data/pins.js" type="text/javascript"></script>
<script>
$(function () {
var deadline;
$('#vmap').vectorMap({
map: 'world_en',
backgroundColor: '#ffffff',
color: '#336633',
hoverOpacity: 0.7,
selectedColor: '#ff6600',
enableZoom: false,
showTooltip: false,
scaleColors: ['#ffffff', '#000000'],
normalizeFunction: 'polynomial',
onRegionOver: function (event, code, region) {
clearTimeout(deadline);
var $pin = $('.clown_pin');
var template = _.template($('#clown_pin_template').html());
$pin.html(template(pins[code] || pins['unknown'])).one('mouseenter', function () {
clearTimeout(deadline);
});
var placeholder = $('#jqvmap1_' + code + '_pin'),
pinPosition = {
top: placeholder.position().top - $pin.outerHeight() / 2,
left: placeholder.position().left
};
if (pinPosition.left + $pin.outerWidth() + 20 > $('#vmap').innerWidth()) {
pinPosition.left = placeholder.position().left - $pin.outerWidth();
}
$pin.stop().show(0).animate(pinPosition, 350);
},
onRegionOut: function (event, code, region) {
deadline = setTimeout(function () {
$('.clown_pin').fadeOut();
}, 350);
},
pinMode: 'placeholder'
});
});
</script>
<style>
.clown_pin {
display: none;
width: 200px;
font-family: Consolas, Menlo, Monaco, monospace;
font-size: 12px;
position: absolute;
background: #ffffff;
box-shadow: 0 5px 15px #333333;
padding: 10px;
}
.clown_pin h2 {
margin: 0;
}
.clown_pin img {
height: 32px;
width: 32px;
display: block;
margin: -20px 0 0 -20px;
background: #333333;
}
.clown_pin ul {
padding: 0;
margin: 0;
list-style: none;
}
.clown_pin ul > li {
padding: 0;
margin: 0;
display: inline;
}
</style>
<title>Advanced Pins</title>
</head>
<body>
<div id="vmap" style="width: 800px; height: 600px;">
<div class="clown_pin"></div>
</div>
<script type="text/template" id="clown_pin_template">
<img src="<%= img %>" alt="Icon"/>
<h2><%= name %></h2>
<ul>
<% $.each(links, function(index, link){ %>
<li><a href="<%= link.href %>"><%= link.text %></a></li>
<% }); %>
</ul>
</script>
</body>
</html>