Blame view

wave/map1.php 6.31 KB
cf76164e6   Ting Chan   20190709
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
  <!DOCTYPE html>
  <?php
  	$open_file = '../../../../home/pi/Desktop/vAlert/bin/vAlert8.cfg';
  	$handle = fopen($open_file,"r");
  	$localarray = array("LOCAL_LONGITUDE","LOCAL_LATITUDE","#LOCAL_LONGITUDE","#LOCAL_LATITUDE","!LOCAL_LONGITUDE","!LOCAL_LATITUDE");
  	$nn = 0;
  	while(($data = fgetcsv($handle,1000,"
  ")) != false){
  		$i = 0;
  		foreach($data as $key => $value){
  			$value = str_replace('[','',$value);
  			$value = str_replace(']','',$value);
  			$aa[$nn][$i] = $value;		
  			$i++;
  		}
  		$nn++;
  	} 
  	//取得location 座標
  	foreach($aa as $key=>$value){
  		if(in_array($value[0] , $localarray)){
  			$location[] = $aa[$key+1][0];
  		}
  	}
  	$location[0] =  ($location[0] != "") ? $location[0]:'116.400244';
  	$location[1] =  ($location[1] != "") ? $location[1]:'39.92556';
  	//print_r($location);
  ?>
  <html>
  <head>
  	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  	<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
  	<style type="text/css">
  		body, html{width: 100%;height: 100%;margin:0;font-family:"微软雅黑";}
  		#allmap{height:100%;width:100%;}
  		#r-result{width:100%;}
  	</style>
  	<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=jG5Ee8caLHGHml2XOR4D7xOq8WyP4IBd"></script>
  	<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.1.js"></script>
  </head>
  <body>
  	<div id="allmap"></div>
  	<div class="introduction">
  		<?php
  		if($_GET['event'] != ''){
  			$point = explode(",",$_GET['location']);
  			$earthpoint = $point[0];
  			$earthpoint1 = $point[1];
  			$new_point = $_GET['location'];
  			$strtime = $_GET['strtime'];
  			$earthquaketime = strtotime($strtime)+28800;
  			$diff = time()-$earthquaketime."<br>";
  			//echo microtime(true);
  
  		}
  		?>
  	</div>
  </body>
  </html>
  <script type="text/javascript">
  	// baidu API
  	var map = new BMap.Map("allmap");
  	var point = new BMap.Point(<?php echo ($new_point == '') ? $location['0'].",".$location['1']:$new_point; ?>);  //create earthquake point
  	map.centerAndZoom(point, 6);
  	var icon = new BMap.Icon('pin.png', new BMap.Size(20, 32), {anchor: new BMap.Size(10, 30)});
  	var marker2 = new BMap.Marker(new BMap.Point(<?php echo $location['0'].",".$location['1']; ?>),{icon:icon}); //create sensor laocal point
  	map.addOverlay(marker2);
  	var top_left_control = new BMap.ScaleControl({anchor: BMAP_ANCHOR_TOP_LEFT});//
  	map.addControl(top_left_control);
  	i=0;
  
  	<?php
  		if($new_point != ''){
  	?>
  		var stop = <?php echo $_GET['clock'];?>;
  		var p_wave = <?php echo ($diff)*7000 ?>+<?php echo $_GET['clock'];?>*1000;
  		var dis = map.getDistance(new BMap.Point(<?php echo $location['0'].",".$location['1']; ?>),new BMap.Point(<?php echo $new_point; ?>)).toFixed(2);
  		//console.log(dis);
  		setTimeout(function(){ resetMkPoint(i);},1000); //1 second update
  	<?php
  		}
  	?>
  
  
  	function resetMkPoint(i){
  		//var p_wave = <?php echo ($diff)*7000*$_GET['clock']; ?>;
  		var math = new Array();
  		var myLabel = new Array();
  		var vibration = new Array();
  		var new_circle = new Array();
  		if(i<=stop ){
  			remove_overlay()
  			timer = setTimeout(function(){i++;resetMkPoint(i);},1000);
  			var marker2 = new BMap.Marker(new BMap.Point(<?php echo $location['0'].",".$location['1']; ?>),{icon:icon}); 
  			map.addOverlay(marker2);
  			var s_wave = <?php echo ($diff)*3550 ?>+i*1000;
  			var marker = new BMap.Marker(new BMap.Point(<?php echo $new_point; ?>)); 
  			var circle = new BMap.Circle(point,<?php echo ($diff)*7000 ?>+i*7000,{fillColor:"red",strokeWeight:2,fillOpacity:0.1,strokeOpacity:0.1});
  			var circle1 = new BMap.Circle(point,<?php echo ($diff)*3550 ?>+i*3550,{strokeColor:'blue', strokeWeight:1}); 
  
  			<?php
  				$num = 0;
  				for($num=0;$num<$_GET['level'];$num++){
  			?>
  				var num = <?php echo $num;?>;
  				math[num] = (Math.pow(10,((<?php echo $_GET['level']-$num;?>)/4.357))-1)*10000;
  				new_circle[num] = new BMap.Point(<?php echo round($earthpoint+(pow(10,((($_GET['level']-$num)/4.357)-1))-0.1),2).",".round($earthpoint1,2); ?>);
  				myLabel[num] = new BMap.Label(" "+num,{offset:new BMap.Size(0,0),position:new_circle[num]}); 
  
  				<?php
  
  				}
  			?>
  			//console.log(new_circle);
  			for (a = 1; a < math.length; a++) {
  				vibration[a] = new BMap.Circle(point,math[a].toFixed(2),{strokeColor:"black",strokeWeight:2,fillOpacity:0.1,strokeOpacity:1,strokeStyle:'dashed'});
  				map.addOverlay(vibration[a]);
  				map.addOverlay(myLabel[a]);
  			}
  
  			map.addOverlay(marker);
  			map.addOverlay(circle);
  			map.addOverlay(circle1);
  
  		}else {
  
  			remove_overlay()
  			timer = setTimeout(function(){i++;resetMkPoint(i);},1000);
  			var marker2 = new BMap.Marker(new BMap.Point(<?php echo $location['0'].",".$location['1']; ?>),{icon:icon}); 
  			map.addOverlay(marker2);
  			var marker = new BMap.Marker(new BMap.Point(<?php echo $new_point; ?>)); 
  			var circle = new BMap.Circle(point,<?php echo ($diff)*7000 ?>+i*7000,{fillColor:"red",strokeWeight:2,fillOpacity:0.1,strokeOpacity:0.1}); 
  			var circle1 = new BMap.Circle(point,<?php echo ($diff)*3550 ?>+i*3550,{strokeColor:'blue', strokeWeight:1}); 
  			var s_dis = i*3550+<?php echo ($diff)*3550 ?>;
  			<?php
  				$num = 0;
  				for($num=0;$num<$_GET['level'];$num++){
  			?>
  				var num = <?php echo $num;?>;
  				math[num] = (Math.pow(10,((<?php echo $_GET['level']-$num;?>)/4.357))-1)*10000;
  				new_circle[num] = new BMap.Point(<?php echo round($earthpoint+(pow(10,((($_GET['level']-$num)/4.357)-1))-0.1),2).",".round($earthpoint1,2); ?>);
  				myLabel[num] = new BMap.Label(" "+num,{offset:new BMap.Size(0,0),position:new_circle[num]});
  			<?php
  				}
  			?>
  
  			for (a = 1; a < math.length; a++) {
  				vibration[a] = new BMap.Circle(point,math[a].toFixed(2),{strokeColor:"black",strokeWeight:2,fillOpacity:0.1,strokeOpacity:1,strokeStyle:'dashed'});
  				map.addOverlay(vibration[a]);
  				map.addOverlay(myLabel[a]);
  			}
  
  			map.addOverlay(marker);
  			map.addOverlay(circle);
  			map.addOverlay(circle1);
  
  			if(dis <= s_dis){
  				  clearTimeout(timer);
  			}
  
  		}
  	}
  
  	function add_overlay(){
  		val = 15 * 1000;
  		selectedDate = new Date().valueOf() + val;
  		$('.text_bold_nounderline').show();
  		$('.clock').countdown(selectedDate, function(event) {
  			   $(this).html(event.strftime('%S'));
  			   $('.text_bold_nounderline').hide();
  		});
  	}
  
  	function remove_overlay(){
  		map.clearOverlays();
  	}
  
  </script>