简体   繁体   中英

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. 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

 <%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

use setInterval example: setInterval(function(){alert("Hello")},3000);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM