我有一个PHP / JavaScript的问题我已经在互联网上的硬件项目的示例中下载了。
下面是脚本,我有一个带有GPS坐标的文件服务器端,名为" gps.txt"。通过放置旧的' "我在这里"文本命令我能够发现脚本似乎没有打开" gps.txt"因此,这就是Google地图没有使用标记进行更新的原因。
真的很感激你们的任何建议。
<!-- Load Jquery -->
<script language="JavaScript" type="text/javascript" src="jquery-1.10.1.min.js"></script>
<!-- Load Google Maps Api -->
<!-- IMPORTANT: change the API v3 key -->
<script src="http://maps.googleapis.com/maps/api/js?key=AIzaSyCU0-w2UAK0Y1rFwVsaQxkMS0upbw-Cqyk&sensor=false"></script>
<!-- Initialize Map and markers -->
<script type="text/javascript">
var myCenter=new google.maps.LatLng(26.707687,-80.054420);
var marker;
var map;
var mapProp;
function initialize()
{
mapProp = {
center:myCenter,
zoom:15,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
setInterval('mark()',5000);
}
function mark()
{
map=new google.maps.Map(document.getElementById("googleMap"),mapProp);
var file = "gps.txt";
$.get(file, function(txt) {
var lines = txt.split("\n");
for (var i=0;i<lines.length;i++){
console.log(lines[i]);
var words=lines[i].split(",");
if ((words[0]!="")&&(words[1]!=""))
{
marker=new google.maps.Marker({
position:new google.maps.LatLng(words[0],words[1]),
});
marker.setMap(map);
map.setCenter(new google.maps.LatLng(words[0],words[1]));s
}
}
marker.setAnimation(google.maps.Animation.BOUNCE);
});
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
<!-- Draw information table and Google Maps div -->
<div>
<center><br />
<b> SIM908 GPS position DEMO </b><br /><br />
<div id="superior" style="width:800px;border:1px solid">
<table style="width:100%">
<tr>
<td>Time</td>
<td>Satellites</td>
<td>Speed OTG</td>
<td>Course</td>
</tr>
<tr>
<td id="time">2015 Apr 24 - 15:04</td>
<td id="sat"></td>
<td id="speed"></td>
<td id="course"></td>
</tr>
</table>
</div>
<br /><br />
<div id="googleMap" style="width:800px;height:700px;"></div>
</center>
</div></body>
答案 0 :(得分:0)
通过评论讨论后,我们发现这个问题的答案是修复jQuery <html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="outer_border">
<div class="inner_border">
<!--just use a div to represent the image -->
<div class ="image">
</div>
<span class="upper_left_text">
upper left
</span>
<span class ="header">
<h2>
Header
</h2>
</span>
<span class="upper_right_text">
upper right
</span>
<button class="button1">Button</button>
<textarea class="text_area">Text Area</textarea>
<button class="button2">Button 2</button>
</div>
</div>
</body>
</html>
.outer_border {
border: 1px solid black;
width: 600px;
height: 500px;
}
.inner_border {
border: 3px solid black;
width: 400px;
height: 300px;
float: right;
}
.image {
border: 1px solid black;
display: inline-block;
width: 50px;
height: 100px;
margin: 5px;
float: left;
}
.the_header {
text-align: center;
display: inline-block;
}
.button1 {
float: right;
}
.button2 {
float: right;
width: 80px;
height: 60px;
}
.text_area {
clear: both;
display: block;
width: 100%;
height: 150px;
margin: 5px;
/*I have no idea how to position this*/
}
.upper_left_text {
float: left;
}
.upper_right_text {
float: right;
}
标记。