GoogleMaps api for javascript demo 动态按顺序加载marker

GoogleMaps api for javascript demo 动态按顺序加载marker

@{
    
}




    
        


        

        
        我的站点标题
        
        
    


  

  

function initialize() {
        var centerMap = new google.maps.LatLng(31.373965502830007, 120.95897912979126);
        var myOptions = {
            zoom: 14,
            center: centerMap,
            mapTypeId: google.maps.MapTypeId.ROADMAP,
            scrollwheel: true
        }

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

        google.maps.event.addListenerOnce(map, 'tilesloaded', function () {
            setMarkers(map, sites);
        });
        infowindow = new google.maps.InfoWindow({
            content: "loading..."
        });
    }




    function setMarkers(map, markers) {
        // TESTING ONLY, remove later
        //markers.splice(0, 200 - howMany);

        //markers.sort(latitudeSort);

        for (var i = 0; i < markers.length; i++) {
            var sites = markers[i];
            var siteLatLng = new google.maps.LatLng(sites[2], sites[3]);
            (function (i, siteLatLng, sites) {
                setTimeout(function () {
                    var marker = new google.maps.Marker({
                        position: siteLatLng,
                        map: map,
                        title: sites[1],
                        animation: google.maps.Animation.DROP
                    });

                    var contentString = "Some content";
                    google.maps.event.addListener(marker, "click", function () {
                        infowindow.setContent(this.html);
                        infowindow.open(map, this);
                    });
                }, i * 100, 100);
            } (i, siteLatLng, sites));
        }
    }

  

你可能感兴趣的:(GoogleMaps api for javascript demo 动态按顺序加载marker)