Click here to Skip to main content
15,949,741 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
I want to show marker one by one....Means when I run application only one marker is shown...after some time may be 2 or 5 sec another marker will shown...

My idea is to set a marker and use setTimeout to wait 2 seconds and then set the next marker...
I tried this from last days..but not archive this...please anyone help me..

Thank you.
Posted
Updated 26-Sep-12 6:10am
v4
Comments
fjdiewornncalwe 25-Sep-12 14:27pm    
Show us some relevant code snippets. Without them we have no idea what you are really trying to accomplish beyond a very high level.
Member 9332883 26-Sep-12 11:37am    
plz give any suggestion...i need it urgently..
fjdiewornncalwe 26-Sep-12 12:11pm    
We could care less that it is urgent to you. It isn't to us. Adding comments like that to your questions and comments will actually cause many experts to ignore your question completely.
Member 9332883 26-Sep-12 13:02pm    
give me any idea about that..how i can do this...
i attached my sample code below..
Member 9332883 26-Sep-12 0:30am    
my code for multiple marker is as follows...

var locations = [
['loan 1', 17.22, 78.28, 'address 1'],
['loan 2', 13.5, 79.2, 'address 2'],
['loan 3', 15.24, 77.16, 'address 3']
];

function initialize()
{
var myOptions = {
center: new google.maps.LatLng(21.16536,72.79387),
zoom: 5,
mapTypeId: google.maps.MapTypeId.ROADMAP

};
var map = new google.maps.Map(document.getElementById("map"), myOptions);
setMarkers(map,locations)

}

function setMarkers(map,locations)
{
var marker, i

for (i = 0; i < locations.length; i++)
{

var loan = locations[i][0]
var lat = locations[i][1]
var long = locations[i][2]
var add = locations[i][3]

latlngset = new google.maps.LatLng(lat, long);

var marker = new google.maps.Marker({
map: map, title: loan , position: latlngset

});
map.setCenter(marker.getPosition())
//setTimeout(function(){marker.close();}, '5000')


var content = "Loan Number: " + loan + '' + "Address: " + add

var infowindow = new google.maps.InfoWindow()

google.maps.event.addListener(marker,'click', (function(marker,content,infowindow){
return function() {
infowindow.setContent(content);
infowindow.open(map,marker);
};
})(marker,content,infowindow));

}
}
window.onload=initialize;


but i want to set marker one by one not all at same time...plz help..

1 solution

Use this code...
C#
function setMarkers(map,locations)
  {
      var marker, i

      for (i = 0; i < locations.length; i++)
      {

         var loan = locations[i][0]
         var lat = locations[i][1]
         var long = locations[i][2]
         var add =  locations[i][3]

        latlngset = new google.maps.LatLng(lat, long);

        setTimeout(function() {createMarker(loan,latlngset,add);},5000);

     }
  }
  function createMarker(titleText, point,add){


        var marker = new google.maps.Marker({
        map: map, title: titleText , position: point

        });
        map.setCenter(point)
        //setTimeout(function(){marker.close();}, '5000')


        var content = "Loan Number: " + titleText +  '' + "Address: " + add

        var infowindow = new google.maps.InfoWindow()

        google.maps.event.addListener(marker,'click', (function(marker,content,infowindow){
        return function() {
        infowindow.setContent(content);
        infowindow.open(map,marker);
        };
        })(marker,content,infowindow));
  }


Hope this will solve ur problem......
 
Share this answer
 
Comments
Member 9332883 26-Sep-12 11:36am    
thank u for answer..but is not work...plz help me...i need it urgently....

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