0
我試圖每10秒後重新繪製一次圖像。通過使用 調用嵌套函數
$(document).ready(function() {
setInterval("marker()",10000);
});
但標記()函數中初始化()函數我怎麼只能訪問標記工作,它上面的setInterval
function initialize(x,y) {
var myLatlng = new google.maps.LatLng(x,y);
var mapOptions = {
zoom: 4,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
marker(x,y);
function marker(){
var image = 'myimage.png';
var myLatLng = new google.maps.LatLng(x, y);
var beachMarker = new google.maps.Marker({
position: myLatLng,
map: map,
icon: image
});
}
}
不要將字符串傳遞給['setInterval'](https://developer.mozilla.org/en-US/docs/DOM/window.setInterval),但函數本身! – Bergi 2013-03-07 20:11:11
你可以調用setInterval(marker,10000); – QuentinUK 2013-03-07 20:11:47