Skip to content

Commit a125ebb

Browse files
committed
leaflet first attempt
1 parent ae88a1d commit a125ebb

File tree

7 files changed

+562
-898
lines changed

7 files changed

+562
-898
lines changed

css/main.css

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ body {
179179
header {
180180
position: fixed;
181181
top: 0;
182-
left; 0;
182+
left: 0;
183183
padding: 0;
184184
margin: 0;
185185
height: 50px;
@@ -737,6 +737,16 @@ header .search form input[type='submit'] {
737737
display: none;
738738
}
739739

740+
.leaflet-tooltip.serialtooltip {
741+
background-color: transparent;
742+
border: 0px;
743+
box-shadow: none;
744+
font-size: 12px;
745+
font-weight: bold;
746+
font-family: 'Roboto';
747+
text-shadow: -1px 0 white, 0 1px white, 1px 0 white, 0 -1px white;
748+
}
749+
740750
@media only screen and (min-width: 900px) {
741751
}
742752

img/markers/antenna-green-dark.png

1.58 KB
Loading

index.html

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ <h4>Recovered a Sonde?</h4>
8989
Click the 'car' icon on the top-right to submit a recovery notification.
9090

9191
<h4>Support Us!</h4>
92-
Google Maps and AWS hosting unfortunately does not come cheap. If you're seeing a greyed out map, that's because we've exceeded our free Google Maps page loads. <br/>
92+
AWS hosting unfortunately does not come cheap. <br/>
9393
If you use SondeHub regularly, please consider <a href="https://www.patreon.com/sondehub" target="_blank">supporting us on Patreon</a>, or with a <a href="https://sondehub.org/go/donate" target="_blank">donation on Paypal</a>.
9494

9595
<h4>Amateur HAB Launches?</h4>
@@ -102,7 +102,7 @@ <h4>SondeHub Status Page</h4>
102102
<br/>
103103
<h2>Under Beta!</h2>
104104
<hr/>
105-
Welcome to the new SondeHub Tracker v2!
105+
Welcome to the new SondeHub Tracker v2 (leaflet edition)!
106106
<br/>
107107
This site uses data from the <a href="https://github.com/projecthorus/sondehub-infra/wiki" target="_blank">SondeHub v2</a> database, which will remove the radiosonde
108108
load from the Habitat tracking database. We are still working to being this tracker up to feature-parity with the previous
@@ -211,18 +211,6 @@ <h4>Other</h4>
211211
<input type="checkbox" id="opt_offline">
212212
</div>
213213
</div>
214-
<div class="row option">
215-
<span><b>Mobile station</b></span>
216-
<div class="switch off" id="sw_station">
217-
<span class="thumb"></span>
218-
<input type="checkbox" id="opt_station">
219-
</div>
220-
</div>
221-
<div class="row info">
222-
<span>
223-
Chase car equipped with radio receiver
224-
</span>
225-
</div>
226214
<div class="row option">
227215
<span><b>Force check for new version</b></span>
228216
<div class="switch off" id="sw_cache">
@@ -247,7 +235,7 @@ <h2>Weather
247235
</svg>
248236
</h2>
249237
<hr>
250-
<p>Here you can access various weather overlays. This an <b>experimental feature</b>. Mobile users be aware that this can quickly eat your data allowance.</p>
238+
<p>Here you can access various weather overlays.</p>
251239
</div>
252240
</div>
253241
<div id="chasecarbox" style="display: none" class="flatpage">
@@ -266,7 +254,7 @@ <h2>Chase car mode</h2>
266254
<span class="r"><input type="text" id="cc_callsign" style="width: 140px;"/></span>
267255
</div>
268256
<div class="row">
269-
<span><b>Notice: If you enable this, your location will be uploaded to habitat; making it publicly visible on the map.</b></span>
257+
<span><b>Notice: If you enable this, your location will be uploaded to SondeHub; making it publicly visible on the map.</b></span>
270258
</div>
271259
<hr>
272260
<div class="row">
@@ -376,16 +364,17 @@ <h3>Report Recovery</h3>
376364
<!-- Was 3.31-->
377365
<script src="https://maps.google.com/maps/api/js?v=3.44&libraries=map,common,controls,util,marker,onion,kml,ga,infowindow,stats,poly,overlay,weather,weather_impl,geometry&language=en_us&key=AIzaSyCiFklq0gbg7DqUn81NqYBN17bwgK4YFf0" type="text/javascript"></script>
378366
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
379-
<script type="text/javascript" language="javascript" src="js/mobile.js"></script>
380-
<!--
367+
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" />
368+
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
369+
<script src='https://api.mapbox.com/mapbox.js/plugins/leaflet-fullscreen/v1.0.1/Leaflet.fullscreen.min.js'></script>
370+
<link href='https://api.mapbox.com/mapbox.js/plugins/leaflet-fullscreen/v1.0.1/leaflet.fullscreen.css' rel='stylesheet' />
371+
<script src="https://unpkg.com/@joergdietrich/leaflet.terminator"></script>
381372
<script type="text/javascript" language="javascript" src="js/gmaps_extentions.js"></script>
382373
<script type="text/javascript" language="javascript" src="js/jquery-1.12.4-min.js"></script>
383374
<script type="text/javascript" language="javascript" src="js/chasecar.lib.js"></script>
384375
<script type="text/javascript" language="javascript" src="js/iscroll.js"></script>
385-
<script type="text/javascript" language="javascript" src="js/nite-overlay.js"></script>
386376
<script type="text/javascript" language="javascript" src="js/tracker.js"></script>
387377
<script type="text/javascript" language="javascript" src="js/app.js"></script>
388-
-->
389378

390379
<!--
391380
<script type="text/javascript">

js/app.js

Lines changed: 43 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function lhash_update(history_step) {
1313
var hash = "";
1414

1515
// generate hash
16-
hash += "mt=" + map.getMapTypeId();
16+
hash += "mt=" + selectedLayer;
1717
hash += "&mz=" + map.getZoom();
1818

1919
if(!/^[a-z0-9]{32}$/ig.exec(wvar.query)) {
@@ -22,8 +22,8 @@ function lhash_update(history_step) {
2222

2323
if(follow_vehicle === null || manual_pan) {
2424
var latlng = map.getCenter();
25-
hash += "&mc=" + roundNumber(latlng.lat(), 5) +
26-
"," + roundNumber(latlng.lng(), 5);
25+
hash += "&mc=" + roundNumber(latlng.lat, 5) +
26+
"," + roundNumber(latlng.lng, 5);
2727
}
2828

2929
if(follow_vehicle !== null) {
@@ -35,11 +35,6 @@ function lhash_update(history_step) {
3535
$("header .search input[type='text']").val(wvar.query);
3636
}
3737

38-
// other vars
39-
if(wvar.nyan) {
40-
hash += "&nyan=1";
41-
}
42-
4338
hash = encodeURI(hash);
4439
// set state
4540
if(history_supported) {
@@ -85,7 +80,6 @@ function load_hash(no_refresh) {
8580
zoom: true,
8681
focus: "",
8782
query: "",
88-
nyan: false,
8983
};
9084

9185
parms.forEach(function(v) {
@@ -95,7 +89,10 @@ function load_hash(no_refresh) {
9589

9690
switch(k) {
9791
case "mt":
98-
map.setMapTypeId(v);
92+
if( baseMaps.hasOwnProperty(v) ) {
93+
selectedLayer = v;
94+
map.addLayer(baseMaps[v]);
95+
}
9996
break;
10097
case "mz":
10198
map.setZoom(parseInt(v));
@@ -104,8 +101,8 @@ function load_hash(no_refresh) {
104101
def.zoom = false;
105102
manual_pan = true;
106103
v = v.split(',');
107-
var latlng = new google.maps.LatLng(v[0], v[1]);
108-
map.setCenter(latlng);
104+
var latlng = new L.LatLng(v[0], v[1]);
105+
map.setView(latlng);
109106
break;
110107
case "f":
111108
refocus = (follow_vehicle != v);
@@ -127,7 +124,7 @@ function load_hash(no_refresh) {
127124
});
128125

129126
// check if we should force refresh
130-
['mode','query','nyan'].forEach(function(k) {
127+
['mode','query'].forEach(function(k) {
131128
if(wvar[k] != def[k]) refresh = true;
132129
});
133130

@@ -585,11 +582,11 @@ $(window).ready(function() {
585582

586583
if(elm.hasClass("active")) {
587584
elm.removeClass('active');
588-
hysplit[name].setMap(null);
585+
map.removeLayer(hysplit[name]);
589586
}
590587
else {
591588
elm.addClass('active');
592-
hysplit[name].setMap(map);
589+
map.addLayer(hysplit[name]);
593590
}
594591
});
595592

@@ -728,13 +725,13 @@ $(window).ready(function() {
728725
//CHASE_enabled = false;
729726

730727
// blue man reappers :)
731-
if(currentPosition && currentPosition.marker) currentPosition.marker.setVisible(true);
728+
if(currentPosition && currentPosition.marker) map.addLayer(currentPosition.marker);
732729

733730
// analytics
734731
if(typeof _gaq == 'object') _gaq.push(['_trackEvent', 'Functionality', 'Turn Off', 'Chase Car']);
735732
// turning the switch on
736733
} else {
737-
if(callsign.length < 5) { alert('Please enter a valid callsign, at least 5 characters'); return; }
734+
if(callsign.length == null || callsign.length < 5) { alert('Please enter a valid callsign, at least 5 characters'); return; }
738735
if(!callsign.match(/^[a-zA-Z0-9\_\-]+$/)) { alert('Invalid characters in callsign (use only a-z,0-9,-,_)'); return; }
739736

740737
field.attr('disabled','disabled');
@@ -759,7 +756,7 @@ $(window).ready(function() {
759756
//CHASE_enabled = true;
760757

761758
// hide the blue man
762-
if(currentPosition && currentPosition.marker) currentPosition.marker.setVisible(false);
759+
if(currentPosition && currentPosition.marker) map.removeLayer(currentPosition.marker);
763760

764761
// analytics
765762
if(typeof _gaq == 'object') _gaq.push(['_trackEvent', 'Functionality', 'Turn On', 'Chase Car']);
@@ -856,8 +853,15 @@ $(window).ready(function() {
856853
refreshUI();
857854
break;
858855
case "opt_daylight":
859-
if(on) { nite.show(); }
860-
else { nite.hide(); }
856+
if(on) {
857+
nite.addTo(map);
858+
niteupdate = setInterval(function() {
859+
nite.setTime();
860+
}, 60000); // Every minute
861+
} else {
862+
nite.remove();
863+
clearInterval(nite);
864+
}
861865
break;
862866
case "opt_hide_receivers":
863867
if(on) {
@@ -942,13 +946,13 @@ $(window).ready(function() {
942946
// Enable the chase-car option for all browsers, not just mobile ones.
943947
$(".chasecar").show();
944948
$("#locate-me,#app_name").attr('style','').click(function() {
945-
if(map && currentPosition) {
949+
if(currentPosition) {
946950
// disable following of vehicles
947951
stopFollow();
948952
// open map
949953
$('.nav .home').click();
950954
// pan map to our current location
951-
map.panTo(new google.maps.LatLng(currentPosition.lat, currentPosition.lon));
955+
map.flyTo(new L.LatLng(currentPosition.lat, currentPosition.lon));
952956

953957
//analytics
954958
if(typeof _gaq == 'object') _gaq.push(['_trackEvent', 'Functionality', 'Locate me']);
@@ -969,32 +973,13 @@ $(window).ready(function() {
969973
// list of overlays
970974
var overlayList = [
971975
['Global', [
972-
['google-radar','Google Earth Radar'],
973-
['nrl-global-cloudtop','NRL Monterey Cloudtop'],
974-
['nrl-global-ir','NRL Monterey IR'],
975-
['nrl-global-vapor','NRL Monterey Vapor']
976-
]],
977-
['Europe/Africa', [
978-
['meteosat-Odeg-MPE', 'METEOSAT Precip. Estimate']
979-
]],
980-
['Indian Ocean', [
981-
['meteosat-iodc-MPE', 'METEOSAT IODC Precip. Est.']
976+
['rainviewer', 'RainViewer Static'],
982977
]],
983978
['North America', [
984979
['nexrad-n0q-900913', 'NEXRAD Base Reflectivity'],
985980
['goes-ir-4km-900913', 'GOES NA Infrared ~4km'],
986981
['goes-wv-4km-900913', 'GOES NA Water Vapor ~4km'],
987982
['goes-vis-1km-900913', 'GOES NA Visible ~1km'],
988-
['goes-east-ir-4km-900913', 'GOES East CONUS Infrared'],
989-
['goes-east-wv-4km-900913', 'GOES East CONUS Water Vapor'],
990-
['goes-east-vis-1km-900913', 'GOES East CONUS Visible'],
991-
['goes-west-ir-4km-900913', 'GOES West CONUS Infrared'],
992-
['goes-west-wv-4km-900913', 'GOES West CONUS Water Vapor'],
993-
['goes-west-vis-1km-900913', 'GOES West CONUS Visible'],
994-
['hawaii-vis-900913', 'GOES West Hawaii Visible'],
995-
['alaska-vis-900913', 'GOES West Alaska Visible'],
996-
['alaska-ir-900913', 'GOES West Alaska IR'],
997-
['alaska-wv-900913', 'GOES West Alaska Water Vapor'],
998983
['q2-n1p-900913', 'Q2 1 Hour Precipitation'],
999984
['q2-p24h-900913', 'Q2 24 Hour Precipitation'],
1000985
['q2-p48h-900913', 'Q2 48 Hour Precipitation'],
@@ -1029,13 +1014,23 @@ $(window).ready(function() {
10291014
}
10301015
}
10311016

1017+
var weatherLayer;
1018+
10321019
// the magic that makes the switches do things
10331020
elm.find(".switch").click(function() {
10341021
var e = $(this);
10351022
var name = e.attr('id').replace('sw', 'opt');
10361023
var id = name.replace("opt_weather_","");
10371024
var on;
10381025

1026+
try {
1027+
map.removeLayer(weatherLayer);
1028+
} catch (err) {};
1029+
1030+
try {
1031+
map.removeLayer(RainRadarAus);
1032+
} catch (err) {};
1033+
10391034
if(e.hasClass('on')) {
10401035
e.removeClass('on').addClass('off');
10411036
on = 0;
@@ -1046,26 +1041,14 @@ $(window).ready(function() {
10461041
on = 1;
10471042
}
10481043

1049-
weatherImageOverlay.setMap(null);
1050-
weatherGoogleRadar.setMap(null);
1051-
map.overlayMapTypes.setAt("0", null);
1052-
10531044
if(on) {
1054-
if(id == "google-radar") {
1055-
weatherGoogleRadar.setMap(map);
1056-
return;
1057-
} else if(id in weatherImageOverlayList) {
1058-
var o = weatherImageOverlayList[id];
1059-
var sw = new google.maps.LatLng(o[1][0][0], o[1][0][1]);
1060-
var ne = new google.maps.LatLng(o[1][1][0], o[1][1][1]);
1061-
var bounds = new google.maps.LatLngBounds(sw, ne);
1062-
weatherImageOverlay = new google.maps.GroundOverlay(o[0], bounds, {opacity: 0.7});
1063-
weatherImageOverlay.setMap(map);
1064-
return;
1045+
if (id.includes("rainviewer")) {
1046+
RainRadarAus.addTo(map);
1047+
} else {
1048+
weatherLayer = L.tileLayer('https://mesonet.agron.iastate.edu/cache/tile.py/1.0.0/' + id + '/{z}/{x}/{y}.png?' + (new Date()).getTime(), {
1049+
opacity: 0.6
1050+
}).addTo(map);
10651051
}
1066-
1067-
weatherOverlayId = id;
1068-
map.overlayMapTypes.setAt("0", weatherOverlay);
10691052
}
10701053
});
10711054

0 commit comments

Comments
 (0)