本文主要是介绍AMD方式引入Classic,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
作者:lly
1.目录结构
├─common
│ └─js [存放所有外部js]
└─css
└─base.js [调用的主函数及相应配置]
└─index.html [入口页面]
2.base.js
require.config({paths:{jquery:'common/js/jquery.min',iClient8c:'common/js/SuperMap-8.1.1-17729',classic: 'common/js/iclient-classic'},shim: {'jquery': {exports: '$'},'classic':{exports: '',deps:['iClient8c']},'iClient8c':{exports: 'SuperMap'}},deps:["iClient8c"]
});
require(["iClient8c","classic"],function(SuperMap){console.log(SuperMap);map = new SuperMap.Map("map");layer = new SuperMap.Layer.TiledDynamicRESTLayer("World", "http://localhost:8090/iserver/services/map-world/rest/maps/World", null, {maxResolution: "auto"});layer.events.on({"layerInitialized": addLayer});
})function addLayer() {map.addLayer(layer);//显示地图范围map.setCenter(new SuperMap.LonLat(0, 0), 0);
}
3.入口页面
<!DOCTYPE html>
<html>
<head lang="en"><meta charset="UTF-8"><title>requireJsDome</title><script src="common/js/requireJs.js"></script>
</head>
<body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
<div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
</body><script src="base.js"></script>
</html>
这篇关于AMD方式引入Classic的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!