:)我试图将一个图标作为一个参数传递给一个简单的标记丢弃函数,但我似乎无法正确传递它,即使我已尝试使用单引号和双引号。所以我有以下功能和使用它的代码。
function addMarkerWithTimeout(position, the_image, timeout) { //Marker dropping function
window.setTimeout(function(the_image) {
markers.push(new google.maps.Marker({
position: position,
map: map,
draggable: false,
icon: the_image, //Hard-typing the url here works perfectly
scale: 3,
animation: google.maps.Animation.DROP }));
}, timeout);
}
var start_image = '../icons/favicon.ico'; //The icon local url
addMarkerWithTimeout(routeCoordinates[0], start_image, 200); //Calling the function
答案 0 :(得分:1)
从window.setTimeout
中删除the_imagefunction addMarkerWithTimeout(position, the_image, timeout) { //Marker
window.setTimeout(function() {