Google maps api 3 maps.event.trigger Resize()不工作

Google maps api 3 maps.event.trigger Resize()不工作,google-maps-api-3,resize,Google Maps Api 3,Resize,我在谷歌地图上工作了相当长的一段时间,我熟悉代码和它的工作原理,但无法正确放置导致我的地图在屏幕上呈现灰色瓷砖的调整大小事件。 请告诉我需要将调整大小活动放置在何处 这是我的密码: bank.atmDetailsSuccess = function(response) { bank.locate = response; bank.getAtmStatus(); }; bank.getAtmStatus = function(results, status) { v

我在谷歌地图上工作了相当长的一段时间,我熟悉代码和它的工作原理,但无法正确放置导致我的地图在屏幕上呈现灰色瓷砖的调整大小事件。 请告诉我需要将调整大小活动放置在何处 这是我的密码:

bank.atmDetailsSuccess = function(response) {

    bank.locate = response;
    bank.getAtmStatus();

};


bank.getAtmStatus = function(results, status) {
    var status = bank.locate.Status[0].Value0;
    locate = bank.locate;
    var map;
    if (status == bank.constants.STATUS_ERROR) {
            var message = locate.Error[0].Value0;
            WL.simpledialog.show(message);
        } else if (status == bank.constants.STATUS_SESSION_EXPIRED) {
            WL.simpledialog.show("Session Expired!!");
        } else if (status == bank.constants.STATUS_SUCCESS) {
            map = bank.initializeAtm();
            google.maps.event.addDomListener(window, 'load', initializeAtm);
            google.maps.event.addDomListener(window, "resize", function() { 
                alert("In");
              var center = map.getCenter();
              google.maps.event.trigger(map, "resize");
              map.setCenter(center); 
              map.setZoom(10);
              });

    }
};


bank.initializeAtm = function(){
    locate = bank.locate;
    var firstlat = locate.Stmt[0].Value5;
    var firstlong= locate.Stmt[0].Value6;
    // var latlng = new google.maps.LatLng(latitude,longitude);

    var image = {
            //url: bank.constants.MARKER_PATH,
           url: 'images/720x720/pin.png',
            // This marker is 20 pixels wide by 32 pixels tall.
            size: new google.maps.Size(32, 40),
            // The origin for this image is 0,0.
            origin: new google.maps.Point(0,0),
            // The anchor for this image is the base of the flagpole at 0,32.
            anchor: new google.maps.Point(0, 32)
          };
    var myOptions = {
            zoom: 10,
            center:new google.maps.LatLng(firstlat, firstlong),
            mapTypeId: google.maps.MapTypeId.ROADMAP

          };

    map = new google.maps.Map($('#map-canvas')[0], myOptions);

    geocoder = new google.maps.Geocoder();
    bank.currentposition();
    $('#mapbranch').hide();
    $('#map-canvas').show();
    $('#atm').html("ATM near your current location");
    $('#results').html("");
    var directionsService = new google.maps.DirectionsService();
    MVC.local.directService = directionsService;
    directionsRenderer = new google.maps.DirectionsRenderer({
          suppressMarkers: true} );
    MVC.local.renderer = directionsRenderer;
    var n;
    for(n=0; n<locate.Stmt.length; n++)
    {
        var value = locate.Stmt[n];
        name = value.Value0,value.Value1;
        lat = value.Value5;
        lon = value.Value6; 
        bank.getDistanceFromLatLonInKm(12.919336, 77.502291,lat,lon);
        var myLatLng = new google.maps.LatLng(lat,lon);
        var marker = new google.maps.Marker({
            position: myLatLng,
            icon:image,
            map: map,
            title: name,
            zIndex: 1
        });

        bank.buildInfoWindow(marker,map,value[n]);
    }
    return map;
};
bank.atmdetailssucess=功能(响应){
bank.locate=响应;
bank.getAtmStatus();
};
bank.getAtmStatus=函数(结果、状态){
var status=bank.locate.status[0].Value0;
locate=bank.locate;
var映射;
if(status==bank.constants.status\u错误){
var message=locate.Error[0].Value0;
WL.simpledialog.show(消息);
}else if(status==bank.constants.status\u SESSION\u EXPIRED){
WL.simpledialog.show(“会话已过期!!”);
}else if(status==bank.constants.status\u SUCCESS){
map=bank.initializeAtm();
google.maps.event.AddDomainListener(窗口'load',initializeAtm);
google.maps.event.addDomListener(窗口,“调整大小”,函数(){
警报(“In”);
var center=map.getCenter();
google.maps.event.trigger(map,“resize”);
地图设置中心(中心);
map.setZoom(10);
});
}
};
bank.initializeAtm=函数(){
locate=bank.locate;
var firstlat=locate.Stmt[0].Value5;
var firstlong=locate.Stmt[0].Value6;
//var latlng=新的google.maps.latlng(纬度、经度);
变量图像={
//url:bank.constants.MARKER\u路径,
url:'images/720x720/pin.png',
//此标记宽20像素,高32像素。
尺寸:新谷歌地图尺寸(32,40),
//此图像的原点为0,0。
来源:新google.maps.Point(0,0),
//此图像的锚定位于旗杆底部0,32处。
主播:新google.maps.Point(0,32)
};
变量myOptions={
缩放:10,
中心:新的google.maps.LatLng(firstlat,firstlong),
mapTypeId:google.maps.mapTypeId.ROADMAP
};
map=new google.maps.map($('#map canvas')[0],myOptions);
geocoder=新的google.maps.geocoder();
bank.currentposition();
$('#mapbranch').hide();
$(“#地图画布”).show();
$('#atm').html(“当前位置附近的atm”);
$('#results').html(“”);
var directionsService=new google.maps.directionsService();
MVC.local.directService=directionservice;
directionsRenderer=新建google.maps.directionsRenderer({
suppressMarkers:true});
MVC.local.renderer=方向渲染器;
var n;

对于(n=0;nAPI自动处理窗口对象上的
resize
事件。您不需要手动触发它。如果您需要他人帮助,您应该提供指向地图的链接。我提供了指向google maps API的链接。Onload有时地图渲染不正确。