首页 / 浏览问题 / 云GIS / 问题详情
地图加载之后不显示
20EXP 2017年04月10日

用js IClient 7c加载地图时地图不显示,需要resize页面或手动拖动地图才显示。调试看到地图和图层均已经加载,但是map的div里面有一个后缀为RootContainer的div的宽度不正确,初次加载时为100。但是页面代码已经设置地图宽度高度都为100%,高度没有问题。resize之后这个容器的宽高变为正常值,地图显示。

地图初次加载:

resize之后:

之前也遇到过这个问题,不知道这是什么原因,求解.

补充:地图容器中动态切片图层的宽高是0,其余图层的宽度都是100。显示效果就是切片底图不显示,其他图层在页面左边显示窄窄的一条。resize之后恢复正常。

问题关闭原因: 暂时没查出来原因,用resize地图规避这个问题

1个回答

你好,把初始化加载地图的代码贴一下吧。
1,600EXP 2017年04月10日
function addLayer(){
  //  map.addLayer(layer);
     map.addLayers([layer,diaodutaiLayer,labelLayer,vectorLayer,textlayer]);
    map.addControl(overviewmap);
    map.addControl(scaleline);
    $('.smControlScaleLineBottom').remove();
    //显示地图范围
    var pointsDc = new Array();
    pointsDc["01"] = new SuperMap.LonLat(14085815.218431087,5748737.1532149082);// ha'er'bin
    pointsDc["02"] = new SuperMap.LonLat(13740225.751694713,5131825.048466525);// shenyang
    pointsDc["03"] = new SuperMap.LonLat(12958399.468188491,4852082.4397516353);// beijing
    pointsDc["04"] = new SuperMap.LonLat(12439816.84109159,4989133.2760516237);// huhehaote
    pointsDc["05"] = new SuperMap.LonLat(12648711.539108366,4129580.4299638253);// zhengzhou
    pointsDc["06"] = new SuperMap.LonLat(13023822.823483624,4392550.3511899831);// jinan
    pointsDc["07"] = new SuperMap.LonLat(13522421.598232297,3662664.9470039792);// shanghai
    pointsDc["08"] = new SuperMap.LonLat(12897325.921996106,3335442.6737730796);// nanchang
    pointsDc["09"] = new SuperMap.LonLat(12608585.426776512,2647632.0467386306);// guangzhou
    pointsDc["10"] = new SuperMap.LonLat(12063305.714119606,2609831.4596475591);// nanning
    pointsDc["11"] = new SuperMap.LonLat(11584427.29848445,3588485.9858257659);// chengdu
    pointsDc["12"] = new SuperMap.LonLat(11434983.553762261,2880412.4221699946);// kunming
    pointsDc["13"] = new SuperMap.LonLat(11558788.638642909,4309054.6188384835);// lanzhou
    pointsDc["14"] = new SuperMap.LonLat(9753529.6959661245,5438664.0468437485);// wulumuqi
    pointsDc["15"] = new SuperMap.LonLat(11329846.190890191,4385881.9050050164);// qingzang
    pointsDc["16"] = new SuperMap.LonLat(12528976.294811118,4561155.5381937828);// taiyuan
    pointsDc["17"] = new SuperMap.LonLat(12724416.807851126,3579983.92343357);// wuhan
    pointsDc["18"] = new SuperMap.LonLat(12127622.331037272,4064410.4913610248);// xi'an
    
    if($.cookie("supermap_lon")&&$.cookie("supermap_lat")){
         map.setCenter(new SuperMap.LonLat($.cookie("supermap_lon"), $.cookie("supermap_lat")), 5);
         return;
    }else{
        if(currUser.DEPID!=null&&currUser.DEPID.substr(0,2)!="00"&&currUser.DEPID.substr(0,2)!="99"){
            var s = currUser.DEPID.substr(0,2);
            map.setCenter(pointsDc[s],5,true,true);
            return;
        }
    }
    map.setCenter(new SuperMap.LonLat(12009634.286396, 4258716.5813769),1);
   
}

我用map.updatesize()暂时解决了地图不显示问题。现在就想了解一下为什么初始化时地图容器会这样。
你是添加了多个rest图层吗?都是异步加载的吗?
一个rest图层,异步,其余为前端feature图层。
你可以打断点调试一下,看一下是不是其他的代码更改了map的div的size
你说的是个思路。只是地图容器本身的宽高都是100%,图层容器也是,这些是没问题的,只有图层容器中的container的宽高不正常。说起来js操作地图组件的时候并没有提供这些container的操作接口,且问题是在地图加载初始化时就表现出来的,所以应该不会是其他代码更改了map的div尺寸或者container的尺寸。
您好,请问您这个问题解决了吗?我也遇到了这个问题,想请教一下您是怎么解决的
可以用其他方法规避一下,比如updatesize。
...