-
Notifications
You must be signed in to change notification settings - Fork 0
/
display_tv.html
341 lines (285 loc) · 7.66 KB
/
display_tv.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
330
331
332
333
334
335
336
337
338
339
340
341
<!DOCTYPE html>
<html>
<head>
<!-- <script src="elabel.js" type="text/javascript"></script> -->
<title>TV Shows around the world </title>
<script src="countryCodeToName.js" type="text/javascript"></script>
<style>
#map {
height: 600px;
width: 100%;
}
/* Optional: Makes the sample page fill the window. */
html,
body {
height: 100%;
margin: 0;
padding: 0;
}
h3,h2{
text-align: center;
}
.Prior1{
font-size: 20px;
}
.Prior2{
font-size: 15px;
}
.Prior3{
font-size: 12px;
}
.Prior4{
font-size: 9px;
}
.Prior5{
font-size: 6px;
}
.popup-tip-anchor {
height: 0;
position: absolute;
/*The max width of the info window.*/
width: 200px;
}
/* The bubble is anchored above the tip. */
.popup-bubble-anchor {
position: absolute;
width: 100%;
bottom: /* TIP_HEIGHT= */
8px;
left: 0;
}
/* Draw the tip. */
.popup-bubble-anchor::after {
content: "";
position: absolute;
top: 0;
left: 0;
/* Center the tip horizontally. */
transform: translate(-50%, 0);
/* The tip is a https://css-tricks.com/snippets/css/css-triangle/ */
width: 0;
height: 0;
/* The tip is 8px high, and 12px wide. */
border-left: 6px solid transparent;
border-right: 6px solid transparent;
border-top: /* TIP_HEIGHT= */
8px solid white;
}
/* The popup bubble itself. */
.popup-bubble-content {
position: absolute;
top: 0;
left: 0;
transform: translate(-50%, -100%);
/* Style the info window. */
background-color: white;
padding: 5px;
border-radius: 5px;
font-family: sans-serif;
overflow-y: auto;
/* font-size: 9px; */
max-height: 40px;
box-shadow: 0px 2px 10px 1px rgba(0, 0, 0, 0.5);
}
</style>
</head>
<body>
<h3> <a href="display_movie.html"> For Movies Click Here </a> </h3>
<h2>TV Shows around globe</h2>
<div id="map"></div>
<script>
var JSTR = {};
var count = 0;
function Get(yourUrl) {
var Httpreq = new XMLHttpRequest(); // a new request
Httpreq.open("GET", yourUrl, false);
Httpreq.send(null);
return Httpreq.responseText;
}
function hitTvApi() {
var json_obj1 = JSON.parse(Get('https://api.themoviedb.org/3/tv/on_the_air?api_key=39fda37c1a2b7aca9c188eb7d67a34e1&page=1'));
for (let index = 1; index <= json_obj1.total_pages; index++) {
var url = 'https://api.themoviedb.org/3/tv/on_the_air?api_key=39fda37c1a2b7aca9c188eb7d67a34e1&page=' + index;
var json_obj = JSON.parse(Get(url));
var i = 0;
while (i < json_obj.results.length) {
if (json_obj.results[i].origin_country.length == 0) {
//No country TODO
}
else {
var id = "id" + count;
var TVtitle = json_obj.results[i].original_name;
var key = json_obj.results[i].origin_country[0];
var dictLatLon = getRANLATLONTV(key);
if(dictLatLon.avail==false){
i++;
continue;
}
var popularity = json_obj.results[i].popularity;
var lat = dictLatLon.lat;
var lon = dictLatLon.lon;
//make marker
var dictTemp = {
"id": id,
"title": TVtitle,
"key": key,
"lat": lat,
"lon": lon,
};
var priority = "Prior4";
if(popularity > 200)
priority = "Prior1";
else if(popularity > 150)
priority = "Prior2";
else if(popularity > 100)
priority = "Prior3";
else if(popularity > 10 )
priority = "Prior4";
else
priority = "Prior5";
JSTR[id] = dictTemp;
document.write("<div id=" + '"' + id + '" class ="'+priority+'">' + TVtitle + " </div>");
var e1 = document.getElementById("p"+id);
if(e1){
e1.addEventListener("click", function(){ e1.style.display = "none"; });
}
count++;
}
i++;
}
}
}
function getJSON() {
return JSTR;
}
function getCount(){
return count;
}
window.onload = hitTvApi();
</script>
<script>
var map, popup, Popup;
function initMap() {
definePopupClass();
var uluru = { lat: 28.34, lng: 77.12 };
var uluru1 = { lat: 28.34, lng: 50 };
map = new google.maps.Map(document.getElementById('map'), {
zoom: 2,
center: uluru
});
map.setOptions({ styles: styles['hide'] });
addPopup(map);
}
var styles = {
default: null,
hide: [
{
featureType: 'all',
elementType: 'labels',
stylers: [{ visibility: 'off' }]
},
{
featureType: 'administrative.country',
elementType: 'labels',
stylers: [{ visibility: 'on' }]
},
{
featureType: 'administrative.country',
elementType: 'labels.text',
stylers: [{ lightness: '70' }]
},
{
featureType: 'transit',
elementType: 'labels.icon',
stylers: [{ visibility: 'off' }]
}
]
};
function addPopup(map) {
var str = getJSON();
console.log(str);
// for (var key in str) {
// popup = new Popup(
// new google.maps.LatLng(str[key].lat, str[key].lon),
// document.getElementById(key));
//
// popup.setMap(map);
// }
var c = getCount();
var i = c-1;
for(i=c-1;i>=0;i--){
var key = "id"+i;
popup = new Popup(
new google.maps.LatLng(str[key].lat, str[key].lon),
document.getElementById(key));
popup.setMap(map);
}
}
/** Defines the Popup class. */
function definePopupClass() {
/**
* A customized popup on the map.
* @param {!google.maps.LatLng} position
* @param {!Element} content
* @constructor
* @extends {google.maps.OverlayView}
*/
Popup = function (position, content) {
this.position = position;
content.classList.add('popup-bubble-content');
var pixelOffset = document.createElement('div');
pixelOffset.classList.add('popup-bubble-anchor');
pixelOffset.appendChild(content);
this.anchor = document.createElement('div');
this.anchor.classList.add('popup-tip-anchor');
this.anchor.appendChild(pixelOffset);
// Optionally stop clicks, etc., from bubbling up to the map.
this.stopEventPropagation();
};
// NOTE: google.maps.OverlayView is only defined once the Maps API has
// loaded. That is why Popup is defined inside initMap().
Popup.prototype = Object.create(google.maps.OverlayView.prototype);
/** Called when the popup is added to the map. */
Popup.prototype.onAdd = function () {
this.getPanes().floatPane.appendChild(this.anchor);
};
/** Called when the popup is removed from the map. */
Popup.prototype.onRemove = function () {
if (this.anchor.parentElement) {
this.anchor.parentElement.removeChild(this.anchor);
}
};
/** Called when the popup needs to draw itself. */
Popup.prototype.draw = function () {
var divPosition = this.getProjection().fromLatLngToDivPixel(this.position);
// Hide the popup when it is far out of view.
var display =
Math.abs(divPosition.x) < 4000 && Math.abs(divPosition.y) < 4000 ?
'block' :
'none';
if (display === 'block') {
this.anchor.style.left = divPosition.x + 'px';
this.anchor.style.top = divPosition.y + 'px';
}
if (this.anchor.style.display !== display) {
this.anchor.style.display = display;
}
};
/** Stops clicks/drags from bubbling up to the map. */
Popup.prototype.stopEventPropagation = function () {
var anchor = this.anchor;
anchor.style.cursor = 'auto';
[ 'dblclick', 'contextmenu', 'wheel', 'mousedown', 'touchstart',
'pointerdown']
.forEach(function (event) {
anchor.addEventListener(event, function (e) {
e.stopPropagation();
});
});
};
}
</script>
<script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBKoqSfq36RAA8V4agXV2iP5e4Ixipd-HM&callback=initMap">
</script>
</body>
</html>