-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjs_code.js
71 lines (62 loc) · 2.37 KB
/
js_code.js
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
var bubble = [];
var map;
function bubble_markers(){
for (var j=0; j < bubble.length; j++)
{
bubble[j].setMap(null);
};
}
$(document).ready(function(){
$("#form_detail").submit(function(event){
event.preventDefault();
bubble_markers() ;
var contentstring = 'Stay Home, Stay Safe';
//Get Input From Form
var informationbubble = new google.maps.InfoWindow({
content: contentstring
})
var country = $(this).serializeArray()[0].value;
// setting up the marker position
$.ajax( {
method: "get",
url: "http://localhost:8080/getcountry?country=" + country,
dataType: "json"
}).done( function(country_covid_details) {
latlngset = new google.maps.LatLng(country_covid_details.lat, country_covid_details.long);
map.setCenter(latlngset);
marker = new google.maps.Marker({
//getting marker over location
position: latlngset,
title: country_covid_details.name,
animation: google.maps.Animation.DROP,
icon:image,
map: map,
});
bubble.push(marker);
marker.addListener('click', function() {
informationbubble.setContent('<br><h1> '+"" + country_covid_details.name+ ' </h1><h1> '+"" + country_covid_details.date+ ' </h1><div><h3>'+"Total COVID-19 Cases: "+country_covid_details.total_cases+'</h3><div><br><h3> '+"COVID-19 Cases per million: " + country_covid_details.total_cases_per_million+ ' </h3><br><h3> '+"COVID-19 New Cases: " + country_covid_details.new_cases+ ' </h3><br><h3> '+"Total COVID-19 Deaths: " + country_covid_details.total_deaths+ ' </h3><br><h3> '+"COVID-19 Deaths per million: " + country_covid_details.total_deaths_per_million+ ' </h3><br><h3> '+"COVID-19 New Deaths: " + country_covid_details.new_deaths+ ' </h3><br><h3> '+"Total COVID-19 Recovered Patients: " + country_covid_details.total_recovered+ ' </h3><br><h3> '+"Total COVID-19 Active Cases: " + country_covid_details.total_active+ ' </h3>')
informationbubble.open(map, this);
},toggleBounce());
})
.fail(function(error) {
alert("Oops! Invaid Entry: Country name not in scope or not present in Casestudy!!");
})
$("#country").val("");
})
});
var image ='css/markericon.png';
function initialize() {
map = new google.maps.Map(document.getElementById('map'), {
icon:image,
zoom: 4,
center:new google.maps.LatLng(38.963745,35.243322)
});
}
// Adding animation to marker
function toggleBounce() {
if (marker.getAnimation()!== null) {
marker.setAnimation(null);
} else {
marker.setAnimation(google.maps.Animation.BOUNCE);
}
}