首页 / 浏览问题 / 云GIS / 问题详情
地图无法加载
4EXP 2018年03月10日
浏览器报错

Uncaught TypeError: Cannot read property 'wrapDateLine' of null    at initialize.moveByPx (eval at <anonymous> (SuperMap-8.1.1-14426.js:3), <anonymous>:1:49115)    at initialize.pan (eval at <anonymous> (SuperMap-8.1.1-14426.js:3), <anonymous>:1:47936)    at e.panMap (eval at <anonymous> (SuperMap-8.1.1-14426.js:3), <anonymous>:1:231787)    at initialize.callback (eval at <anonymous> (SuperMap-8.1.1-14426.js:3), <anonymous>:1:186366)    at initialize.dragmove (eval at <anonymous> (SuperMap-8.1.1-14426.js:3), <anonymous>:1:210131)    at initialize.mousemove (eval at <anonymous> (SuperMap-8.1.1-14426.js:3), <anonymous>:1:211093)    at initialize.removeTimeout (eval at <anonymous> (SuperMap-8.1.1-14426.js:3), <anonymous>:1:211221)    at eval (eval at <anonymous> (SuperMap-8.1.1-14426.js:3), <anonymous>:1:1792)

1个回答

您好,您的问题我已在http://ask.supermap.com/20537中回复,会有工程师专门为您解答,请您耐心等待不要重复提问。另:社区值班时间为周一至周五8:30至17:30,值班时间外无法及时回复问题,请您谅解。

4,524EXP 2018年03月10日

这是代码您看一下谢谢 

这个是运行的结果

<!DOCTYPE html>
<head>
    <meta charset="UTF-8"  >
    <title>Document</title>
</head>
<script src="libs/SuperMap.Include.js"></script>
<script type="text/javascript">
    var map,layer;
    var url = "http://localhost:8090/iserver/services/map-World5/rest/maps/World";
    //显示地图
    function onPageLoad(){
        //创建地图对象
        map = new SuperMap.Map("map");
        //创建图层对象
        layer = new SuperMap.Layer.TiledDynamicRESTLayer("World",url,{transparent:true,cacheEnabled:true},{maxResolution:"auto"});
        layer.events.on({"layerlnitialized":addLayer});

    }
    //加载图层
    function addLayer(){
        //向map添加图层
        map.addLayer(layer);
        map.setCenter(new SuperMap.Lonlat(0,0),0);
    }
    //放大
    function ZoomIn(){
        map.zoomIn();
    }
    //缩小
    function ZoomOut(){
        map.zoomOut();
    }

</script>
<body onload=onPageLoad()>
    <div id="map" style="position: relative; left: 0px; right:0px; width: 800px; height: 500px;">    
    </div>
    <input type="button" value="放大" onclick="ZoomIn()">
    <input type="button" value="缩小" onclick="ZoomOut()">

    
</body>
</html>

检查一下你的libs/SuperMap.Include.js引用到了吗

你好,确定是引用到了,之前我有把include的I小写,他有报not found的错误。

我刚又试了,还是刚刚的代码,不会报错,但是也不会显示地图。

如果url换成同一目录下其他的代码就会出现如题的错误,还是不显示
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>缩放与平移</title>
<style type="text/css">
body{
margin: 0;
overflow: hidden;
background: #fff;
}
#map{
position: relative;
height: 510px;
border:1px solid #3473b7;
}

#toolbar {
position: relative;
padding-top: 5px;
padding-bottom: 10px;
}
</style>
<script src = '../libs/SuperMap.Include.js'></script>
<script type="text/javascript">
var map,layer,
host = document.location.toString().match(/file:\/\//)?"http://localhost:8090":'http://' + document.location.host,
url=host+"/iserver/services/map-world/rest/maps/World";
function init()
{
map = new SuperMap.Map("map",{controls:[]});
layer = new SuperMap.Layer.TiledDynamicRESTLayer("World", url, {transparent: true, cacheEnabled: true},{maxResolution:"auto"});
layer.events.on({"layerInitialized":addLayer});
}
function addLayer()
{
map.addLayer(layer);
map.setCenter(new SuperMap.LonLat(0,0), 0);
}
//放大 ,在当前缩放级别的基础上放大一级。
function mapenlarge()
{
map.zoomIn();
}
//缩小,在当前缩放级别的基础上缩小一级。
function mapreduce()
{
map.zoomOut();
}
//平移 ,根据指定的屏幕像素(-20,-8)值平移地图

</script>
</head>
<body onload="init()">
<div id="toolbar">
<input type="button" class="btn" value="放大" onclick="mapenlarge()" />
<input type="button" class="btn" value="缩小" onclick=" mapreduce()" />
</div>
<div id="map"></div>
</body>
</html>
...