common.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. "use script"; //开发环境建议开启严格模式
  2. //判断webgl支持
  3. if (!mars3d.Util.webglreport()) {
  4. mars3d.Util.webglerror();
  5. }
  6. //读取 config.json 配置文件
  7. let configUrl = "config/config.json";
  8. mars3d.Resource.fetchJson({ url: configUrl })
  9. .then(function (json) {
  10. //构建地图
  11. window.initMap(json.map3d);
  12. //移除遮罩
  13. setTimeout(removeMask, 3000);
  14. })
  15. .otherwise(function (error) {
  16. console.log("加载JSON出错", error);
  17. removeMask();
  18. haoutil.alert(error && error.message, "出错了");
  19. });
  20. // fetch(configUrl)
  21. // .then(function (response) {
  22. // if (!response.ok) {
  23. // var error = new Error(response.statusText)
  24. // error.response = response
  25. // throw error
  26. // } else {
  27. // return response.json()
  28. // }
  29. // })
  30. // .then((json) => {
  31. // //构建地图
  32. // window.initMap(json.map3d)
  33. // //移除遮罩
  34. // setTimeout(removeMask, 3000)
  35. // })
  36. // .catch(function (error) {
  37. // console.log('加载JSON出错', error)
  38. // removeMask()
  39. // haoutil.alert(error?.message, '出错了')
  40. // })
  41. //移除遮罩
  42. function removeMask() {
  43. $("#mask").remove();
  44. }
  45. function openTipView(content, title) {
  46. window.layer.open({
  47. type: 1,
  48. title: title || "功能 和 已知问题 提示",
  49. offset: "rt",
  50. shade: false,
  51. skin: "layer-mars-dialog animation-scale-up",
  52. content: content,
  53. });
  54. }
  55. if ($("#tipView").length > 0) {
  56. openTipView($("#tipView"));
  57. }