将图标作为参数传递不会;t工作-谷歌地图

Passing an icon as an argument doesn't work - google maps

本文关键字:工作 谷歌地图 图标 参数传递      更新时间:2023-09-26

:)我试图将一个图标作为参数传递给一个简单的标记删除函数,但我似乎无法正确传递它,尽管我已经尝试过单引号和双引号。所以我有下面的函数和使用它的代码

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

从window.setTimeout 中删除_image

function addMarkerWithTimeout(position, the_image, timeout) {  //Marker 
    window.setTimeout(function() {