initial commit
[map.git] / honeymap-master / static / map.js
1 // small helper method to format the hover labels
2 function event_count_summary(hash) {
3   var summary = "";
4   var total = 0;
5   for(type in hash) {
6     if(total == 0) { summary += "<hr/>"; }
7     summary += "<b>" + type + "</b>: " + (hash[type] ? hash[type] : 0) + "<br/>";
8     total += hash[type];
9   }
10   if(total > 0) {
11     summary += "<hr/><b>total</b>: " + total + " events";
12   }
13   return summary;
14 }
15
16 $('#world-map').vectorMap({
17   backgroundColor: '',
18   markerStyle: {
19     initial: {
20       fill: markersrc_color.fill,
21       stroke: markersrc_color.stroke,
22       r: 3
23     }
24   },
25   series: {
26     markers: [],
27     regions: [{
28       scale: [ '#FFFFFF', '#0071A4' ],
29       attribute: 'fill',
30       normalizeFunction: 'linear',
31       values: regionhits
32     }]
33   },
34   onRegionLabelShow: function(ev, label, code) {
35     label.html("<big>" + label.html() + "</big>");
36     label.append(event_count_summary(regionhits[code]));
37   },
38   onMarkerLabelShow: function(ev, label, code) {
39     label.html(markercaptions[code]);
40     label.append(event_count_summary(markerhits[code]));
41   }
42 });
43 var mapobj = $('#world-map').vectorMap('get', 'mapObject');
44 mapobj.regions['US'].config.name = "USA";