-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathep14.html
107 lines (78 loc) · 2.43 KB
/
ep14.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
<!DOCTYPE html>
<html>
<head>
<style>
#entrada{
border:50px;
}
#map {
height: 400px;
width:100%;
}
</style>
</head>
<body>
<div id="entrada">
<input type='file' accept='text/plain' onchange='openFile(event)'><br>
</div>
<div id="map"></div>
<script>
var openFile = function(event) {
var input = event.target;
var reader = new FileReader();
reader.onload = function(){
var text = reader.result.split('\n');
placeMarkers(text);
//console.log(reader.result.substring(0,20));
//console.log(typeof(text));
//console.log(text[0]);
};
reader.readAsText(input.files[0]);
};
var map;
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
center: {lat: 30, lng: 0},
zoom: 3
});
}
function placeMarkers(text)
{
for( var i = 0; i < text.length; i++ ) {
var segments = text[i].split(' ');
var intensidade = parseFloat(segments[2]);
var lat = parseFloat(segments[1]);
var lng = parseFloat(segments[0]);
var location={lat,lng};
//console.log(lat);
//console.log(lng);
//console.log(intensidade);
var positions = {
map: map,
position:location,
icon: setIcon(intensidade)
};
function setIcon(intensidade) {
var icons = {
0:'http://maps.google.com/mapfiles/kml/pal3/icon57.png',
1:'http://maps.google.com/mapfiles/kml/pal3/icon8.png',
2:'http://maps.google.com/mapfiles/kml/pal3/icon9.png',
3:'http://maps.google.com/mapfiles/kml/pal3/icon10.png',
4:'http://maps.google.com/mapfiles/kml/pal3/icon11.png',
5:'http://maps.google.com/mapfiles/kml/pal3/icon12.png',
6:'http://maps.google.com/mapfiles/kml/pal3/icon13.png',
7:'http://maps.google.com/mapfiles/kml/pal3/icon14.png',
8:'http://maps.google.com/mapfiles/kml/pal3/icon15.png',
9:'http://maps.google.com/mapfiles/kml/pal3/icon16.png',
}
return icons[Math.floor(intensidade)]
}
// Add the marker for the earthquake
var marker = new google.maps.Marker(positions);
};
};
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCTRMDK9qncMynrv-rpWAWouwWY1ct5D3Q&callback=initMap"
async defer></script>
</body>
</html>