3dEarth.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. define(['vendorDir/map23dlib/TileEntity',
  2. 'vendorDir/map23dlib/MemStream',
  3. 'vendorDir/map23dlib/VTPMarkerProvider',
  4. 'vendorDir/data/boundary'], function(){
  5. /**
  6. * 状态值
  7. * @type {Boolean}
  8. * @default false
  9. * @private
  10. */
  11. var status = {
  12. initialized:false,//是否初始化
  13. isOpenSetting:false,//是否打开设置框
  14. Sun3D:false,
  15. showLine3D:false
  16. };
  17. /**
  18. * 模块数据 用于数据存储和外部调用
  19. * @type {Object}
  20. * 数据存放
  21. */
  22. var modValue = {
  23. model3D:false,//3D建筑模型
  24. photography:false,//倾斜摄影模型
  25. };
  26. /**
  27. * 3维地球初始化
  28. */
  29. function init(){
  30. if(!status.initialized){
  31. map3DViewer.map.extend(Cesium.viewerCesiumNavigationMixin, {});
  32. //地图移动
  33. map3DViewer.map.scene.camera.moveEnd.addEventListener(function () {
  34. //var center = map3DViewer.getCurCameraInfos();
  35. var ellipsoid = map3DViewer.map.scene.globe.ellipsoid;
  36. var height = ellipsoid.cartesianToCartographic(map3DViewer.map.camera.position).height;
  37. if (map23DData.display.map2D) {
  38. ONEMAP.C.publisher.publish(map2DViewer.map.getZoom(), 'mapChange23D');
  39. } else if (map23DData.display.map3D) {
  40. ONEMAP.C.publisher.publish(height, 'mapChange23D');
  41. }
  42. })
  43. addBoundary(); //加载国境线
  44. //添加地名层
  45. // add3DName();
  46. }
  47. status.initialized = true;
  48. };
  49. function add3DName(){
  50. modValue.name_tile_zh = new Cesium.Entity({
  51. id: 'name_tile_zh',
  52. show: false
  53. })
  54. //温度
  55. var options = {
  56. url: map23DConfig.map23DAssetsUrl + '/scripts/vendor/Apps/SampleData/zc/marker.vtc',
  57. tileUrlTemplate: onemapUrlConfig.defaultGlobalSettingData.baseMap3D.map3DName,
  58. metadataUrl: map23DConfig.map23DAssetsUrl + '/scripts/vendor/Apps/SampleData/zc/marker.xml',
  59. fatherGroup: modValue.name_tile_zh,
  60. maxZoom: [11, 14],
  61. minZoom: [8, 4],
  62. };
  63. modValue.featureProvider = new VTPMarkerProvider(Cesium, options);
  64. modValue.featureProvider.viewer = map3DViewer.map;
  65. //modValue.name_tile_zh.show = true;
  66. }
  67. /**
  68. * 加载国境线
  69. */
  70. function addBoundary() {
  71. for (var wi = 0, wl = worldPolyline.length; wi < wl; wi++) {
  72. DrawworldPolyline('country', worldPolyline[wi], 'wline' + wi);
  73. }
  74. for (var pi = 0, pl = provincePolyline.length; pi < pl; pi++) {
  75. DrawworldPolyline('province', provincePolyline[pi], 'pline' + pi);
  76. }
  77. }
  78. function DrawworldPolyline(type, lineData, name) {
  79. var pnts = [];
  80. for (var i = 0, l = lineData.length; i < l; i++) {
  81. pnts.push(lineData[i][0], lineData[i][1]);
  82. }
  83. if (type == 'country') {
  84. // map3DViewer.map.
  85. map3DViewer.map.entities.add({
  86. name: name,
  87. polyline: {
  88. positions: Cesium.Cartesian3.fromDegreesArray(pnts),
  89. clampToGround: true,
  90. width: 2,
  91. material: new Cesium.PolylineGlowMaterialProperty({
  92. color: Cesium.Color.fromBytes(255, 255, 0, 130)
  93. }),
  94. distanceDisplayCondition: new Cesium.DistanceDisplayCondition(700000, 70000000000)
  95. }
  96. });
  97. } else if (type == 'province') {
  98. map3DViewer.map.entities.add({
  99. name: name,
  100. polyline: {
  101. positions: Cesium.Cartesian3.fromDegreesArray(pnts),
  102. clampToGround: true,
  103. width: 1,
  104. material: new Cesium.PolylineGlowMaterialProperty({
  105. color: Cesium.Color.fromBytes(255, 255, 0, 130)
  106. }),
  107. distanceDisplayCondition: new Cesium.DistanceDisplayCondition(700000, 70000000000)
  108. }
  109. });
  110. }
  111. }
  112. /**
  113. * 注册监听
  114. */
  115. function subscribe(){
  116. };
  117. function setLayout(){
  118. };
  119. function bindEvent(){
  120. };
  121. /**
  122. * 加载/移除3d模型
  123. * @return {[type]} [description]
  124. */
  125. function add3DCSMX(flag){
  126. };
  127. /**
  128. * 加载/移除倾斜摄影
  129. * @return {[type]} [description]
  130. */
  131. function add3DQXSY(flag){
  132. };
  133. /**
  134. * 清除标注
  135. *
  136. */
  137. function clear3DMap(){
  138. }
  139. return ONEMAP.M.tdEarth = {
  140. init:init,
  141. modValue:modValue
  142. }
  143. })