Reputation: 760
I am trying to redraw image after every 10 seconds. by using
$(document).ready(function() {
setInterval("marker()",10000);
});
but marker() function inside initialize() function how can i access only marker to work it for above 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
});
}
}
Upvotes: 0
Views: 58
Reputation: 664599
Just change it to
setInterval(marker, 10000);
and move that into a scope where the marker
function is available, i.e. into initialize
.
Upvotes: 1