How can I set a callback function on a single specified panTo
call? Here is my code.
var loc = data.split(',');
map.panTo(new google.maps.LatLng(loc[0], loc[1]), function(){
console.log('this never logs...');
});
How can I set a callback function on a single specified panTo
call? Here is my code.
var loc = data.split(',');
map.panTo(new google.maps.LatLng(loc[0], loc[1]), function(){
console.log('this never logs...');
});
Share
Improve this question
edited Jun 21, 2020 at 11:18
Brian Tompsett - 汤莱恩
5,88372 gold badges61 silver badges133 bronze badges
asked Jun 10, 2011 at 9:03
JacobJacob
1391 silver badge3 bronze badges
1 Answer
Reset to default 23It's not clear to me what you are trying to achieve. Are you hoping the callback will run when the panning finishes? If so, you can try this:
map.panTo(new google.maps.LatLng(loc[0], loc[1]));
google.maps.event.addListenerOnce(map, 'idle', function(){
console.log('this logs after the panTo finishes.');
});