脚本宝典收集整理的这篇文章主要介绍了初遇Citymaker (四),脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
这个系列最重要的来了 cw5这个类主要是构建地图加载
针对citymaker初始化
cw5主类```javascript
/**
cw5.__g = null;cw5.isInit= false;cw5.licenseLoad = false;cw5.rootId = '11111111-1111-1111-1111-111111111111';cw5.version=null;cw5.fullButton=null;cw5.callback={};
/**
初始化地图场景
@param id id是html中承载三维场景的object标签的id
@returns {string}*/cw5.init = function (id = "__g") {this.__g = document.getElementById(id);if( this.__g.type=="application/x-cm-3d"){cw5.version=7;}else if( this.__g.type=="application/x-cm-3d8"){cw5.version=8;}else{cw5.version= map3dConfig.version;
}
isSupport3d.init();//初始化地图let ps = this.__g.new_PropertySet;// 检测浏览器是否支持三维或是否安装三维引擎
ps.setProperty("RenderSystem", "OpenGL");ps.setProperty("QuadBufferStereo", false);//是否支持多点触控if(map3dConfig.multiTouch){ps.setProperty("MultiTouch", true);}let bInit = this.__g.initialize(true, ps);if (!bInit) {if (confirm("未检测到插件,是否下载?")) {console.log("请安装CityMaker系列软件!");
}return}this.__g.camera.flyTime = 2;skyBox.setSkybox();cw5.confirmLicense();cw5.fullScreenButton();cw5.isInit=true;};/**
验证三维证书是否可用*/cw5.confirmLicense = function () {var license = __g.new_LicenseServer;let _this = this;if (!this.licenseLoad) {let licUrl = map3dConfig.license.protocal + "://" + map3dConfig.license.host + ":" + map3dConfig.license.port;try {if (map3dConfig.license.path != "") {console.log(map3dConfig.license.path)license.setHost(map3dConfig.license.path, 0, "");if(cw5.version==7){if(!license.internalGetData().pVal2){console.log("授权失败",license.internalGetData().pVal1)}else{console.log("授权成功",license.internalGetData().pVal1);}}else if(cw5.version==8){if(!license.hasRuntimeLicense){console.log("授权失败")}else{console.log("授权成功");}}
}} catch (e) {console.error("设置授权异常:" + e.message);}}};
/**
/**
/**
异常处理
@param e
@param mapInfo*/cw5.exceptionHandler = function(e,mapInfo) {let msg = (typeof e == "object") ? e.message : e;console.error("图层加载错误:"+mapInfo.handle);console.error("出错信息:"+msg);
//如果需要自定义异常描述信息//如果是IE浏览器,可以直接用e中取出错误码:var code = e.number;let code = parseInt(msg.substring(msg.indexOf("[") + 1, msg.length - 1));if (code == -2147220504) {console.error("此类型的数据源不支持此操作!");}};
/**
cw5.loadMap = function (map3dGroup) {if(cw5.isInit!=true){console.log("cw未初始化")return}map3dGroup = map3dGroup || map3dLayers;
以上是脚本宝典为你收集整理的初遇Citymaker (四)全部内容,希望文章能够帮你解决初遇Citymaker (四)所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。