6 <title>hurricane</title>
7 <meta name="viewport" content="width=device-width, minimum-scale=1, maximum-scale=1">
9 <meta name="description" content="Displaying storm activity in the Atlantic">
10 <meta name="author" content="Ryan Westphal">
11 <link rel="stylesheet" type="text/css" href="css/style.css" />
12 <style type="text/css">
24 border: solid 1px #444;
42 <a href="../" class="docLink">< docs</a>
43 <h1>Hurricane tracking</h1>
44 <p>Displaying a snapshot of storm data extracted from <a href="http://stormpulse.com">stormpulse.com</a></p>
47 <script id="tmplHurricane" type="text/x-jquery-tmpl">
48 <h2>{{=category}}</h2>
50 <tr><th>date</th><td>{{=date}}</td></tr>
51 <tr><th>accuracy</th><td>{{=accuracy}}/40</td></tr>
52 <tr><th>eye diameter</th><td>{{=eyeDiameter}}</td></tr>
53 <tr><th>direction</th><td>{{#if direction}}{{=direction}}°{{/if}}</td></tr>
54 <tr><th>pressure</th><td>{{=pressure}}</td></tr>
55 <tr><th>wind radii</th><td>{{=windRadii}}</td></tr>
56 <tr><th>wind speed</th><td>{{=windSpeed}}</td></tr>
57 <tr><th>gusts</th><td>{{=gusts}}</td></tr>
60 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
61 <script src="js/iecors.js"></script>
62 <script src="http://code.jquerygeo.com/jquery.geo-1.0a4.min.js"></script>
65 $.template( "hurricane", $( "#tmplHurricane" ) );
67 var map = $("#map").geomap({
68 center: [-76.6, 30.4],
71 cursors: { find: "default" },
72 move: function (e, geo) {
73 $("#popup").hide().html("");
74 var tracks = map.geomap("find", geo, 4);
76 $.each(tracks, function() {
77 if (this.type == "Feature") {
78 $( "#popup" ).append( $.render( this.properties, "hurricane" ) );
79 var popupLocation = map.geomap( "toPixel", geo.coordinates );
81 left: popupLocation[ 0 ],
82 top: popupLocation[ 1 ]
83 }).css("display", "inline-block");
90 url: "http://data.jquerygeo.com/hurricane.json",
92 success: function (result) {
98 $.each(result.stormData.storms.tracks[0].track, function(i) {
104 parseFloat(this[16]),
109 eyeDiameter: this[0],
112 accuracy: this[10] || 0,
121 if (trackPoint.properties.date != null) {
122 var dateStr = trackPoint.properties.date.toString(),
123 year = dateStr.substr(0, 4),
124 month = dateStr.substr(4, 2),
125 day = dateStr.substr(6);
126 trackPoint.properties.date = year + "-" + month + "-" + day;
129 switch (trackPoint.properties.category) {
130 case "Tropical Storm":
131 shapeStyle.color = "#eee";
134 case "Hurricane - Category 1":
135 shapeStyle.color = "#ff8";
138 case "Hurricane - Category 2":
139 shapeStyle.color = "orange";
142 case "Major Hurricane - Category 3":
143 shapeStyle.color = "#f88";
147 shapeStyle.color = "gray";
151 if (trackPoint.properties.accuracy != null) {
152 var pos = trackPoint.geometry.coordinates,
153 a = .2 + (40 - trackPoint.properties.accuracy)/40;
155 shapeStyle.strokeOpacity = trackPoint.properties.accuracy/40;
157 map.geomap("append", {
160 [pos[0] - a, pos[1] - a],
161 [pos[0] - a, pos[1] + a],
162 [pos[0] + a, pos[1] + a],
163 [pos[0] + a, pos[1] - a],
164 [pos[0] - a, pos[1] - a]
166 }, $.extend({}, shapeStyle));
169 map.geomap("append", trackPoint, { color: "#444" });
172 error: function (xhr) {
173 alert("Sorry, we were unable to read the storm data.");