如何延迟谷歌地图调整大小

时间:2014-07-08 13:44:33

标签: javascript jquery google-maps google-maps-api-3

我正在使用Google Maps API在地图上放置多个地点 - 但似乎网页加载速度很快,因此不会加载所有javascript函数,也不会将地点放在地图上。

如果我可以在页面加载后的某个时间使用google.maps.event.trigger(map, 'resize');函数,据我所知,应该按照我的需要工作。

例如,请使用隐身功能访问http://dev.ateo.dk/sogning/。如果地图正在显示地点,请尝试使用新的隐身功能。大多数情况下问题都会发生,但有时它似乎正在发挥作用。

JS文件:http://dev.ateo.dk/wp-content/themes/ateo/js/default.js并搜索“zoom:14” - 这是应该加载地图并确定地点的函数

此致 帕特里克

1 个答案:

答案 0 :(得分:0)

试试这个

function drawMap()
{

   //draw map here
   timer();

} 

var timer=10;

function timers()
{

    timer--;
    if(timer<=0)
    {

        clearTimeout(t);

        drawMarker();

    }

    setTimeout(timers,100);
    //after 1sec the marker will load

}



function drawMarker()
{

     //your code here`

}


<body onload="drawMap()">