[英]How can I move a marker on Google Maps using latitude & longitude pair from MSExcel and refresh every 10 seconds
This is my code: it's retrieving data from excel database and i have to move the marker by taking one by one co-ordinate from excel.it is actually for bus tracking.i already have all the co-ordinates in latitude-longitude format. 这是我的代码:它正在从excel数据库中检索数据,我必须通过从excel逐个获取一个坐标来移动标记。它实际上是用于公交车跟踪的。我已经具有所有经度-纬度格式的坐标。 Just to retrieve the values by jsp and place the values one by one in javascript by placing the new marker,i also want to delete the old marker.pls help 只是通过jsp检索值,然后通过放置新标记将这些值一个一地放置在javascript中,我也想删除旧标记。pls帮助
<%response.setIntHeader("Refresh", 5);
Connection conn=null;
Statement stmt=null;
String sql="";
ResultSet rs=null;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conn=DriverManager.getConnection("jdbc:odbc:kashimiraz","","");
stmt=conn.createStatement(
ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
sql="select * from [Sheet1$]";
rs=stmt.executeQuery(sql);
rs.next();
String latitude =rs.getString("lat");
String longitude = rs.getString("lon");
String last = latitude;
String lastt= longitude;
rs.close();
stmt.close();
conn.close();
rs=null;
stmt=null;
conn=null; %>
<script type="text/javascript">
function initialize()
{
var value="<%=last%>";
var valuee="<%=lastt%>";
var myCenter=new google.maps.LatLng(value,valuee);
var mapProp = {
center:myCenter,
zoom:15,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
var map=new google.maps.Map(document.getElementById("googleMap"),mapProp);
var marker=new google.maps.Marker({
position:myCenter,
});
marker.setMap(map);
var infowindow = new google.maps.InfoWindow({
content:"Bus# 57"
});
infowindow.open(map,marker);
}google.maps.event.addDomListener(window, 'load', initialize);
</script>
<div id="googleMap" style="width:1200px;height:500px;"></div>
</section>
</body></html>
I think your answer is here: http://www.w3schools.com/js/js_timing.asp 我认为您的答案在这里: http : //www.w3schools.com/js/js_timing.asp
use setInterval
example: setInterval(function(){alert("Hello")},3000);
使用setInterval
示例: setInterval(function(){alert("Hello")},3000);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.