<!DOCTYPE HTML>
<html>
<head>
<title>SuperMap iClient for JavaScript:TiledDynamicRESTLayer</title>
<!--引用需要的脚本-->
<script src="./libs/SuperMap.Include.js"></script>
<script src="./layer/Tianditu.js"></script>
<script type="text/javascript">
//声明变量map、layer、url
var map, layer,tiandituLayer ,
url = "http://loclhost:8100/iserver/services/map-PDV2WB/rest/maps/LXGGHD",
WMTSLayer, WMTSLayer2, tiandituLayer , tianMarkerLayer;
//创建地图控件
function init(){
//初始化地图
map = new SuperMap.Map('map', {controls:[
new SuperMap.Control.Navigation() ,
new SuperMap.Control.Zoom(),
new SuperMap.Control.LayerSwitcher()
], allOverlays: true});
name: "cva", //自定义图层名称
url: "http://t0.tianditu.gov.cn/cva_c/wmts?tk=8c8423722d0791e18dc8b9866b71a96f", //wmts服务地址
layer: "cva", //服务中的图层名称
style: "default", //风格描述
matrixSet: "c", //标识符矩阵集
format: "tiles", //瓦片格式
isBaseLayer: false, // 图层是否为基础图层,默认为true。
requestEncoding: "KVP",
opacity: 1,
//resolutions: resolutions,
matrixIds: [],
tileOrigin: new SuperMap.LonLat(-180, 90), //切图原点,天地图标准都是(-180,,90)
tileSize: new SuperMap.Size(256,256), //瓦片大小
});
tiandituLayer = new SuperMap.Layer.Tianditu();
tianMarkerLayer = new SuperMap.Layer.Tianditu();
tianMarkerLayer.layerType="cva";
tianMarkerLayer.isLabel=true;
map.addControl(new SuperMap.Control.MousePosition());
//初始化图层
var options = {
projection:"EPSG:4326",
maxExtent: new SuperMap.Bounds(121.467391159432,30.845632378681,121.963621370315,31.381153363854),
resolutions: [0.703125,0.35156249999999994, 0.17578124999999997, 0.08789062500000014, 0.04394531250000007,
0.021972656250000007, 0.01098632812500002, 0.00549316406250001, 0.0027465820312500017, 0.0013732910156250008,
0.000686645507812499, 0.0003433227539062495, 0.00017166137695312503, 0.00008583068847656251, 0.000042915344238281406, 0.000021457672119140645,
0.000010728836059570307, 0.00000536441802978516]
};
layer = new SuperMap.Layer.TiledDynamicRESTLayer("Mapssd沙发", url, {transparent: true}, options);
//layer = new SuperMap.Layer.Vector("LXGGHD", url, {}, {maxResolution:"auto"});
//layer = new SuperMap.Layer.TiledDynamicRESTLayer("LXGGHD", url, null, {maxResolution:"auto", overlapDisplayed: false});
layer.events.on({"layerInitialized":addLayer});
//map.addLayers([WMTSLayer2]); //添加图层到地图中 tk=8c8423722d0791e18dc8b9866b71a96f&
//map.setCenter(new SuperMap.LonLat(0,0), 20); //设置底图中心点和缩放级别
//addLayer()
}
function addLayer(){
//map.addLayers([WMTSLayer,WMTSLayer2, layer]); //添加图层到地图中
map.addLayers([tiandituLayer,tianMarkerLayer]);
map.addLayers([layer]);
//显示地图范围
map.setCenter(new SuperMap.LonLat(121.475830,31.210450), 11);
}
</script>
</head>
<body onload="init()">
<!--地图显示的div -->
<div id="map" style="position:absolute;left:0px;right:0px;width:98%;height:98%;" >
</div>
</body>
</html>
完整代码,已解决