-
Notifications
You must be signed in to change notification settings - Fork 1
/
indexmaps2.html
329 lines (254 loc) · 13.1 KB
/
indexmaps2.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
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
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="author" content="Roman S. Stepanov" />
<link href="css/bootstrap.min.css" rel="stylesheet"/>
<link href="css/bootstrap-responsive.css" rel="stylesheet"/>
<link href="css/base.css" rel="stylesheet"/>
<script type="text/javascript" src="js/jquery.js"></script>
<script> $183 = jQuery.noConflict();</script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/raphael.js"></script>
<script type="text/javascript" src="js/jquery.mousewheel.js"></script>
<script type="text/javascript" src="js/mapsvg.min.js?v=5.5.4"></script>
<script type="text/javascript" src="http://j.maxmind.com/app/geoip.js"></script>
<div class="location_select">
<script type="text/javascript">
if(window.location.protocol=="file:"){
$183(document).ready(function(){
$183('#main-body').prepend('<div class="alert alert-error" style="margin-top: 20px;">SVG map files can\'t be loaded when HTML file is just opened from local folder - because JavaScript don\'t have access to files on your local machine. Please upload demo to server to see maps.</div>');
});
}
</script>
</head>
<script type="text/javascript">
var currentLocation = [geoip_latitude(), geoip_longitude()];
$183('#mapsvg-2').mapSvg({
source: 'maps/world_with_states.svg', // Path to SVG map
colors: {stroke: '#aaaaaa', selected: -20, hover: 7},
width: 1170,
onClick: function(e,m){
if(this.node.id=='Mongolia') return;
var obj = this.mapsvg_type == 'region' ? '<b>'+this.node.id+'</b>' : 'a <b>marker</b>';
m.showPopover(e,'You clicked '+obj+' and this is a pop-up info box with close button. <br />You can put <ins>any</ins> <strong>HTML</strong> <em>tags</em> here. <br />Also it\'s useful for links: <a href="http://google.com" target="_blank">google.com</a>');
},
marks: [
{ c: currentLocation,
attrs: {'src': 'markers/pin1_red.png'},
tooltip: '<strong>You are here!</strong><br />'
+geoip_city()+'<br />'
+geoip_country_name()+'<br />'
+'Coordinates: '+currentLocation
},
{ c: [38.927099,-77.021713],
attrs: {'src': 'markers/pin1_yellow.png'},
tooltip: '<strong>Washington, DC</strong><br />This marker is set by latitude / longitude coordinates:<br />38.893438, -77.03167'
},
{ c: [51.49763,-0.148315],
attrs: {'src': 'markers/pin1_green.png'},
tooltip: '<strong>London</strong><br />Coordinates: 51.49763, -0.148315'
}
,
{ c: [33.504759,100.283203],
attrs: {'src': 'markers/pin1_blue.png'},
tooltip: '<strong>China</strong> is disabled for demonstration purpose -<br />so it isn\'t clickable or selectable.'
}
],
regions: {
Mexico: {
tooltip: 'You can set any colors and styles for any region.<br />',
attr:{fill: '#F3E4B2'}
},
Russia: {
tooltip: '<strong>Russia:</strong> Click here to see a popover box',
attr:{fill: '#FF9176'},
popover: 'This is info box with close button. <br />You can put <ins>any</ins> <strong>HTML</strong> <em>tags</em> here. <br />Also it\'s useful for links: <a href="http://google.com" target="_blank">google.com</a>'
},
China: {
disabled: true,
attr: {fill: '#F7D5BA'}
},
Mongolia: {
tooltip: '<strong>Mongolia:</strong> link to <em>google.com</em> is attached to this country. <br />Try to click! (link will open in new window).',
attr:{fill: '#A4DFA3', href: 'http://map/&t=1'}
},
Kazakhstan: {
tooltip: '<strong>Kazakhstan:</strong> tooltips can contain any HTML:<br /><img src="http://farm9.staticflickr.com/8162/7706013408_80a182713f_m.jpg"/>',
attr:{fill: '#F9DD7B'}
}
},
tooltipsMode: 'combined',
zoom: 1,
pan:1,
responsive:1,
zoomLimit: [-100,100]
});
</script>
<pre id="js-code" style="display: none;">
var currentLocation = [geoip_latitude(), geoip_longitude()];
$183('#mapsvg-2').mapSvg({
source: 'maps/world_high.svg', // Path to SVG map
colors: {base: '#cccccc', stroke: '#aaaaaa', selected: 10},
tooltipsMode: 'combined',
zoom: true,
pan: true,
responsive: true,
width: 1170,
zoomLimit: [0,100],
onClick: function(e,m){
if(this.node.id=='Mongolia') return;
var obj = this.mapsvg_type == 'region' ? '<b>'+this.node.id+'</b>' : 'a <b>marker</b>';
m.showPopover(e,'You clicked '+obj+' and this is a pop-up info box with close button. <br />You can put <ins>any</ins> <strong>HTML</strong> <em>tags</em> here. <br />Also it\'s useful for links: <a href="http://google.com" target="_blank">google.com</a>');
},
marks: [
{ c: currentLocation,
attrs: {'src': 'markers/pin1_red.png'},
tooltip: '<strong>You are here!</strong><br />'
+geoip_city()+'<br />'
+geoip_country_name()+'<br />'
+'Coordinates: '+currentLocation
},
{ c: [38.893438,-77.03167],
attrs: {'src': 'markers/pin1_yellow.png'},
tooltip: '<strong>Washington, DC</strong><br />This marker is set by latitude / longitude coordinates:<br />38.893438, -77.03167'
},
{ c: [51.49763,-0.148315],
attrs: {'src': 'markers/pin1_green.png'},
tooltip: '<strong>London</strong><br />Coordinates: 51.49763, -0.148315'
}
,
{ c: [33.504759,100.283203],
attrs: {'src': 'markers/pin1_blue.png'},
tooltip: '<strong>China</strong> is disabled for demonstration purpose -<br />so it isn't clickable or selectable.'
}
],
regions: {
USA: {
tooltip: '<strong>USA:</strong> As you can see, you can paint regions in any colors.<br />',
attr:{fill: '#F3E4B2'}
},
Russia: {
tooltip: '<strong>Russia:</strong> Click here to see a popover box',
attr:{fill: '#FF9176'},
},
China: {
disabled: true,
attr: {fill: '#F7D5BA'}
},
Mongolia: {
tooltip: '<strong>Mongolia:</strong> link to <em>google.com</em> is attached to this country. <br />Try to click! (link will open in new window).',
attr:{fill: '#A4DFA3', href: 'http://google.com', target: 'blank'}
},
Kazakhstan: {
tooltip: '<strong>Kazakhstan:</strong> tooltips can contain any HTML:<br /><img src="http://farm9.staticflickr.com/8162/7706013408_80a182713f_m.jpg"/>',
attr:{fill: '#F9DD7B'}
}
}
});
</pre>
<div class="row" style="overflow: hidden;">
<div class="span6">
<a style="cursor:pointer;" id="gobackNE">return to New England</a>
<a style="cursor:pointer;" id="gobackUSA">return to USA</a>
<div id="mapsvg-usa"></div>
<div id="mapsvg-states" style="min-height: 200px;"></div>
</div>
</div>
<script type="text/javascript">
$183('#gobackNE').hide();
$183("#locationprompt").css({"display":"block"});
$183('#mapsvg-usa').mapSvg({source: 'maps/usa.svg', width: 1200, responsive: 1,
colors: {background: 'transparent', hover: 4, selected: 10, stroke: '#4374E0'},
tooltipsMode: 'names',
regions: {'TX': {selected: true}},
onClick: function(){
$183('#mapsvg-usa').hide();
$183('#gobackNE').show();
var file = 'usa-'+this.name.toLowerCase()+'.svg';
console.log($183('#mapsvg-states').html());
if($183('#mapsvg-states').find('svg').length){
$183('#mapsvg-usa').hide();
$183('#mapsvg-states').mapSvg().destroy();
}
$183( "#gobackNE" ).click(function() {
$183('#mapsvg-states').mapSvg().destroy();
$183('#mapsvg-usa').show();
});
$183('#mapsvg-states').mapSvg({
source : 'maps/counties/'+file,
//responsive: 1,
colors: {background: 'transparent', base: "#DDDDDD", stroke: '#ffffff'},
width: $183('#mapsvg-usa').width(),
height: $183('#mapsvg-usa').height(),
tooltipsMode: 'names',
zoomButtons: {show: true, location: 'right'},
zoom: 1,
pan: 1
});
}
});
</script>
<script type="text/javascript">
$183('#maplinks a').on('click', function(e){
e.preventDefault();
var file = $183(this).attr('data-svg');
if($183('#mapsvg-other').find('svg').length){
$183('#mapsvg-other').empty().mapSvg().destroy();
}
$183('#mapsvg-other').mapSvg({
source : 'maps/'+file,
responsive: 1,
width: $183('#mapsvg-other-cont').width(),
height: $183('#mapsvg-other-cont').height(),
tooltipsMode: 'names',
zoomButtons: {show: true, location: 'left'},
zoom: 1,
pan: 1
});
});
</script>
<br /><br />
<div class="alert alert-info">
↓ Select any map from menu
</div>
<div class="row" style="overflow: hidden;">
<div class="span3">
<ul id="maplinks" class="nav nav-tabs nav-stacked other-maps">
<li><a href="#" data-svg="world_high.svg">World</a></li>
<li><a href="#" data-svg="world_with_states.svg">World with USA states</a></li>
<li><a href="#" data-svg="usa.svg">USA</a></li>
<li><a href="#" data-svg="usa-labels.svg">USA + short labels</a></li>
<li><a href="#" data-svg="usa-labels-full.svg">USA + full labels</a></li>
<li><a href="#" data-svg="europe.svg">Europe</a></li>
<li><a href="#" data-svg="asia.svg">Middle Asia</a></li>
</ul>
</div>
<div class="span9" id="mapsvg-other-cont">
<div id="mapsvg-other"></div>
</div>
</div>
<script type="text/javascript">
$183('#maplinks a').on('click', function(e){
e.preventDefault();
var file = $183(this).attr('data-svg');
if($183('#mapsvg-other').find('svg').length){
$183('#mapsvg-other').empty().mapSvg().destroy();
}
$183('#mapsvg-other').mapSvg({
source : 'maps/'+file,
responsive: 1,
colors: {base: '#cccccc', stroke: "#999999", selected: 9, hover: 5},
regions: {labels: {attr: {fill: '#555555'}}},
width: $183('#mapsvg-other-cont').width(),
tooltipsMode: 'names',
zoomButtons: {show: true, location: 'left'},
zoom: 1,
pan: 1
});
});
</script>
</div>
</body>
</html>