亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在谷歌地圖上一一加載標記動畫

如何在谷歌地圖上一一加載標記動畫

PHP
開心每一天1111 2021-09-18 10:58:45
我有一些帶有ajax的代碼,用于地圖上的谷歌標記。它的工作正?!,F在我想要一個一個地放置標記而不是一次加載所有。請幫助我$.ajax({            type: 'get',            url: APP_URL + '/yestoday',            data: {_token:"{{csrf_token()}}"},            success: function (data) {              debugger;               // console.log(data);                var locations  = Array();                var map = new google.maps.Map(document.getElementById('map'), {                center: new google.maps.LatLng(20.593683,78.962883),                zoom: 7,                });                jQuery.each(data , function (index, value){                var points = Array();                var point = new google.maps.LatLng(parseFloat(value.latitude),parseFloat(value.longitude));                points.push(parseFloat(value.latitude));                points.push(parseFloat(value.longitude));                points.push(value.store_name);                points.push(value.store_address);                  locations.push(points);                var marker = new google.maps.Marker({                    position: point,                    map: map,                    animation: google.maps.Animation.DROP,                });                var infowindow = new google.maps.InfoWindow();                google.maps.event.addListener(marker, 'mouseover', function() {                  infowindow.setContent('<div><strong>'+points[2]+'</strong><br><strong>'+points[3]+'</strong></div>');                  infowindow.open(map, this);                });                google.maps.event.addListener(marker, 'mouseout', function() {                  infowindow.close();                });            });        },    });
查看完整描述

2 回答

?
繁華開滿天機

TA貢獻1816條經驗 獲得超4個贊

你可以通過使用setTimeout函數來實現


set delayMarker = 200; // 你可以在這里設置你的延遲時間


$.ajax({

    type: 'get',

    url: APP_URL + '/yestoday',

    data: {_token:"{{csrf_token()}}"},

    success: function (data) {

        var locations  = Array();

        var map = new google.maps.Map(document.getElementById('map'), {

            center: new google.maps.LatLng(20.593683,78.962883),

            zoom: 7,

        });


        var delayMarker = 200;

        jQuery.each(data , function (index, value){


            setTimeout(function() {


                var points = Array();

                var point = new google.maps.LatLng(parseFloat(value.latitude),parseFloat(value.longitude));


                points.push(parseFloat(value.latitude));

                points.push(parseFloat(value.longitude));

                points.push(value.store_name);

                points.push(value.store_address);

                locations.push(points);


                var marker = new google.maps.Marker({

                    position: point,

                    map: map,

                    animation: google.maps.Animation.DROP,

                });


                var infowindow = new google.maps.InfoWindow();

                google.maps.event.addListener(marker, 'mouseover', function() {

                    infowindow.setContent('<div><strong>'+points[2]+'</strong><br><strong>'+points[3]+'</strong></div>');

                    infowindow.open(map, this);

                });


                google.maps.event.addListener(marker, 'mouseout', function() {

                    infowindow.close();

                });


            },index * delayMarker);


        });

    },

});



查看完整回答
反對 回復 2021-09-18
  • 2 回答
  • 0 關注
  • 166 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號