Click here to Skip to main content
15,921,660 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
i have following code which plot all marker at same time on map...
but i want to plot those marker after some time interval like 2 or 5 second..
give me some idea..
Thank you !!!

Here is my code...

map.aspx page :

C#
<script src="http://maps.google.com/maps/api/js?sensor=false" 
          type="text/javascript"></script>
          
  <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&v=3&libraries=geometry"></script>
  <script type="text/javascript" charset="UTF-8" src="http://maps.gstatic.com/intl/en_ALL/mapfiles/400d/maps2.api/mod_api_gc.js"></script>
 <script type="text/javascript">
        
        
    var locations = [<%=data%>];
        
    var map = new google.maps.Map(document.getElementById('map'), {
      zoom: 15,
      center: new google.maps.LatLng(<%=slat%>, <%=slong%>),
      mapTypeId: google.maps.MapTypeId.ROADMAP
    });

    var infowindow = new google.maps.InfoWindow();
    
    var marker, i;

    for (i = 0; i < locations.length; i++) {  
   
      marker = new google.maps.Marker({
        position: new google.maps.LatLng(locations[i][1], locations[i][2]),
        animation: google.maps.Animation.DROP,
        map: map
       
      });
      
      google.maps.event.addListener(marker, 'click', (function(marker, i) {
        return function() {
          infowindow.setContent(locations[i][0]);
          infowindow.open(map, marker);
        }
      })(marker, i));
    }
  </script>




map.aspx.cs page :



C#
protected void Page_Load(object sender, EventArgs e)
    {
        SqlDataAdapter adp = new SqlDataAdapter("select lat,long from data", con);
        DataTable dt = new DataTable();
        adp.Fill(dt);
        if (dt.Rows.Count > 0)
        {
            int cnt = dt.Rows.Count;
            int j = dt.Rows.Count / 2;
            slat = dt.Rows[j]["lat"].ToString();
            slong = dt.Rows[j]["long"].ToString();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                
                data += "['navsari'," + dt.Rows[i]["lat"].ToString() + "," + dt.Rows[i]["long"].ToString() + "]";
                data += ",";
            }
        }

        data = data.TrimEnd(',');
}
Posted
Updated 5-Nov-12 1:13am
v2
Comments
ZurdoDev 5-Nov-12 8:51am    
in you JS you can use the setTimeout method and then call a function that just plots the marker. http://www.w3schools.com/js/js_timing.asp
Member 9332883 6-Nov-12 0:12am    
i have try that...but it plot all marker at same time..
i want to plot markers one by one after some time of interval...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900