-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
132 lines (122 loc) · 4.12 KB
/
main.js
File metadata and controls
132 lines (122 loc) · 4.12 KB
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
//set default to Denver
var myLatLng = {
lat: 39.7558146,
lng: -105.0426646
};
//control bottom ticker
ScrollSpeed = 200;
ScrollChars = 1
ScrollValue = ''
function ScrollMarquee() {
window.setTimeout('ScrollMarquee()',ScrollSpeed);
var msg = document.ticker.text.value;
document.ticker.text.value =
msg.substring(ScrollChars) +
msg.substring(0,ScrollChars);
}
ScrollMarquee()
//set up clickable map zoomed in on Dever
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 4,
center: myLatLng,
mapTypeControl: true,
mapTypeControlOptions: {
style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR,
position: google.maps.ControlPosition.TOP_CENTER
},
zoomControl: true,
zoomControlOptions: {
position: google.maps.ControlPosition.LEFT_CENTER
},
scaleControl: true,
streetViewControl: true,
streetViewControlOptions: {
position: google.maps.ControlPosition.LEFT_TOP
},
fullscreenControl: true
});
var marker = new google.maps.Marker({
position: myLatLng,
map: map
});
map.addListener('click', function(event) {
myLatLng = {
lat: Math.round(event.latLng.lat()),
lng: Math.round(event.latLng.lng())
};
// console.log(marker.position);
checkWind(Math.round(event.latLng.lat()),
Math.round(event.latLng.lng()));
console.log(checkWind)
initMap();
});
}
//determine kite position based on mph of wind
function setKiteHeight(speed) {
var balloon = document.querySelector('.balloon')
if (speed < 5) {
balloon.classList = ""
balloon.classList.add('balloon')
balloon.classList.add('noWind')
}
else if (speed >= 5 && speed < 10) {
balloon.classList = ""
balloon.classList.add('reallyLowWind')
balloon.classList.add('wiggleVertical')
balloon.classList.add('wiggleHorizontal')
balloon.classList.add('balloon')
}
else if (speed >= 10 && speed < 15) {
balloon.classList = ""
balloon.classList.add('lowWind')
balloon.classList.add('wiggleVertical')
balloon.classList.add('wiggleHorizontal')
balloon.classList.add('balloon')
}
else if (speed >= 15 && speed < 20) {
balloon.classList = ""
balloon.classList.add('medWind')
balloon.classList.add('wiggleVertical')
balloon.classList.add('wiggleHorizontal')
balloon.classList.add('balloon')
}
else if (speed >= 20 && speed < 25) {
balloon.classList = ""
balloon.classList.add('highWind')
balloon.classList.add('wiggleVertical')
balloon.classList.add('wiggleHorizontal')
balloon.classList.add('balloon')
}
else if (speed >= 25) {
balloon.classList = ""
balloon.classList.add('reallyHighWind')
balloon.classList.add('balloon')
}
}
//get data from api on weather
function checkWind(lat, lng) {
var url = "https://api.wunderground.com/api/68e3e7c9b741eaf5/geolookup/conditions/q/" + lat + ',' + lng + '.json';
$.get(url).then(function(data) {
// console.log(data);
// console.log(data.current_observation.wind_mph);
// console.log(data.current_observation.wind_dir);
// console.log(data.location.city);
// console.log(data.location.state);
// console.log(data.location.country);
// console.log(data.current_observation.local_time_rfc822);
ScrollValue = ""
ScrollValue += " City: " + data.location.city.toString();
ScrollValue += ", " + data.location.state.toString();
ScrollValue += " Wind: " + data.current_observation.wind_string.toString();
ScrollValue += " " + data.current_observation.observation_time.toString();
ScrollValue += " Weather: " + data.current_observation.weather.toString();
ScrollValue += " Temperature: " + data.current_observation.temperature_string.toString();
$('INPUT').val(ScrollValue)
$('#location').text(data.location.city + ", " + data.location.state)
// $('#localTime').text('Local Time: ' + data.current_observation.local_time_rfc822)
$('#windSpeed').text('Wind Speed: ' + data.current_observation.wind_mph + " MPH")
$('#windDirection').text('Wind Direction: ' + data.current_observation.wind_dir)
setKiteHeight(data.current_observation.wind_mph)
});
}