選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

base.md 27KB

1ヶ月前
1ヶ月前
1ヶ月前
1ヶ月前
1ヶ月前
1ヶ月前
1ヶ月前
1ヶ月前
1ヶ月前
1ヶ月前
1ヶ月前
1ヶ月前
1ヶ月前
1ヶ月前
1ヶ月前
1ヶ月前
1ヶ月前
1ヶ月前
1ヶ月前
1ヶ月前
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358
  1. # 基础 API 🌎
  2. ## DC.Viewer
  3. > 3D 场景主要接口,在给定的 DivId 中构建三维场景
  4. ### example
  5. ```html
  6. <div id="viewer-container"></div>
  7. ```
  8. ```js
  9. let viewer = DC.Viewer('viewer-container')
  10. global.viewer = viewer // 添加到全局变量
  11. ```
  12. :::warning
  13. 如果开发使用的是 Vue 这样的 MVVM 框架,不要将 viewer、layer、overlay 添加到数据模型中。由于 3D
  14. 场景中会不停的刷新每一帧,如果将数据添加到数据模型中,长时间的话会导致浏览器的压力增大而奔溃。
  15. :::
  16. ### creation
  17. - **_constructor(container,[options])_**
  18. 构造函数
  19. - 参数
  20. - `{String | Cesium.Viewer } container`:容器
  21. - `{Object} options`:属性
  22. - 返回值 `viewer`
  23. ```js
  24. //属性参数(可选)
  25. const config = {
  26. "contextOptions": {
  27. "webgl": {
  28. "alpha": false, //背景
  29. "depth": true,
  30. "stencil": false,
  31. "antialias": true,
  32. "powerPreference": "high-performance",
  33. "premultipliedAlpha": true,
  34. "preserveDrawingBuffer": false,
  35. "failIfMajorPerformanceCaveat": false
  36. },
  37. "allowTextureFilterAnisotropic": true
  38. },
  39. "sceneMode": 3,
  40. //1: 2.5D,2: 2D,3: 3D
  41. "enableEventPropagation": false,
  42. //是否开启鼠标事件冒泡
  43. "enableMouseMovePick": false,
  44. // 是否开启鼠标移动拾取功能,开启后当覆盖物较多的情况下,帧率会下降
  45. "enableMouseOver": false
  46. //是否开启鼠标移入事件,需要开启鼠标移动拾取功能
  47. }
  48. ```
  49. ### properties
  50. - `{Element} container`:场景容器 **_`readonly`_**
  51. - `{Element} widgetContainer`:场景组件容器 **_`readonly`_**
  52. - `{Element} layerContainer`:场景图层容器 **_`readonly`_**
  53. - `{Object} scene`:场景 **_`readonly`_**,详情参考:[Scene](http://resource.dvgis.cn/cesium-docs/Scene.html)
  54. - `{Object} camera`:相机 **_`readonly`_**,详情参考:[Camera](http://resource.dvgis.cn/cesium-docs/Scene.html)
  55. - `{Element} canvas`:canvas 节点 **_`readonly`_**
  56. - `{Object} clock`:时钟,详情参考:[Clock](http://resource.dvgis.cn/cesium-docs/Clock.html)
  57. - `{Object} dataSources`
  58. :数据资源集合,详情参考:[DataSourceCollection](http://resource.dvgis.cn/cesium-docs/DataSourceCollection.html)
  59. - `{Object} imageryLayers`
  60. :瓦片集合,详情参考:[ImageryLayerCollection](http://resource.dvgis.cn/cesium-docs/ImageryLayerCollection.html)
  61. - `{Object} entities`:实体集合,详情参考:[EntityCollection](http://resource.dvgis.cn/cesium-docs/EntityCollection.html)
  62. - [`{Popup} popup`](#popup):气泡窗口 **_`readonly`_**
  63. - [`{ContextMenu} contextMenu`](#contextmenu):右击弹框 **_`readonly`_**
  64. - [`{Tooltip} tooltip`](#tooltip):提示框 **_`readonly`_**
  65. - [`{MapSplit} mapSplit`](#mapsplit):地图分割 **_`readonly`_**
  66. - [`{TilesetSplit} tilesetSplit`](#tilesetsplit):模型分割 **_`readonly`_**
  67. - [`{SceneSplit} sceneSplit`](#scenesplit):场景分割 **_`readonly`_**
  68. - [`{Compass} compass`](#compass):罗盘 **_`readonly`_**
  69. - [`{ZoomController} zoomController`](#zoomcontroller):罗盘 **_`readonly`_**
  70. - [`{LocationBar} locationBar`](#locationbar):坐标信息 **_`readonly`_**
  71. - [`{DistanceLegend} distanceLegend`](#distancelegend):比例尺 **_`readonly`_**
  72. - [`{LoadingMask} loadingMask`](#loadingmask):加载蒙层 **_`readonly`_**
  73. - `{Position} cameraPosition`:相机位置 **_`readonly`_**
  74. - `{Number} resolution`:分辨率 **_`readonly`_**
  75. - `{Number} zoom`: 当前层级 **_`readonly`_**
  76. - `{Rect} viewBounds`:视野范围 **_`readonly`_**
  77. - `{Boolean} enableEventPropagation`: 是否开启鼠标事件冒泡
  78. - `{Boolean} enableMouseMovePick`: 是否开启鼠标移动拾取功能,开启后当覆盖物较多的情况下,帧率会下降
  79. - `{Boolean} enableMouseOver`: 是否开启鼠标移入事件,需要开启鼠标移动拾取功能
  80. ### methods
  81. - **_setOptions(options)_**
  82. 设置属性
  83. - 参数
  84. - `{Object} options`:属性对象
  85. - 返回值 `this`
  86. ```js
  87. // 属性参数(可选)
  88. const config = {
  89. "shadows": false,// 是否开启阴影
  90. "resolutionScale": 1,// 设置渲染分辨率的缩放比例
  91. "showAtmosphere": true,//是否显示大气层
  92. "showSun": true,//是否显示太阳
  93. "showMoon": true, //是否显示月亮
  94. "enableFxaa": true,//是否开启抗锯齿
  95. "msaaSamples": 1,//msaa抗拒出取样度
  96. "cameraController": { // 相机控制
  97. "enableRotate": true,// 是否可以旋转
  98. "enableTilt": true,// 是否可以翻转
  99. "enableTranslate": true,// 是否可以平移
  100. "enableZoom": true,// 是否可以缩放
  101. "enableCollisionDetection": true,// 是否支持碰撞检测
  102. "minimumZoomDistance": 1.0,// 最小缩放距离
  103. "maximumZoomDistance": 40489014.0// 最大缩放距离
  104. },
  105. "globe": {
  106. "show": true,// 是否显示地球
  107. "showGroundAtmosphere": true,// 显示地面大气
  108. "enableLighting": false,//是否开启灯光,开启后地球会根据当前时间启用灯光
  109. "depthTestAgainstTerrain": false, //是否开启深度测试
  110. "tileCacheSize": 100, // 默认瓦片缓存大小
  111. "preloadSiblings": false,//是否应预加载渲染同级图块
  112. "terrainExaggeration": 1,//地形夸张系数
  113. "terrainExaggerationRelativeHeight": 1,//地形相对高度夸张系数
  114. "baseColor": new DC.Color(0, 0, 0.5, 1), //地球默认底色
  115. "filterColor": newDC.Color(0, 0, 0, 0),//瓦片过滤色,设置后不可逆
  116. "translucency": { //地表透明
  117. "enabled": false, // 是否开启地表透明
  118. "backFaceAlpha": 1, // 地球背面透明度
  119. "backFaceAlphaByDistance": null, //根据距离设置地球背面透明度: {near:400,nearValue:0.2,far:800,farValue:1}
  120. "frontFaceAlpha": 1, // 地球正面透明度
  121. "frontFaceAlphaByDistance": null //根据距离设置地球正面透明度: {near:400,nearValue:0.2,far:800,farValue:1}
  122. }
  123. },
  124. "skyBox": {
  125. "sources": {}, // 六个面的贴图
  126. "show": true, //是否显示
  127. "offsetAngle": 0 //旋转角度
  128. }
  129. }
  130. ```
  131. - **_setPitchRange(min,max)_**
  132. 设置翻转角度
  133. - 参数
  134. - `{Number} min`:最小角度
  135. - `{Number} max`:最大角度
  136. - 返回值 `this`
  137. - **_changeSceneMode(sceneMode, duration)_**
  138. 改变场景模式
  139. - 参数
  140. - `{Number} sceneMode`:场景模式 ,2:2D,3:3D,2.5:2.5D
  141. - `{Number} duration`:间隔时间
  142. - 返回值 `this`
  143. - **_changeMouseMode(mouseMode)_**
  144. 改变鼠标使用模式
  145. - 参数
  146. - `{Number} mouseMode`:鼠标模式,详情参考:`DC.MouseMode`
  147. - 返回值 `this`
  148. - **_addBaseLayer(baseLayers,options)_**
  149. 添加地图
  150. - 参数
  151. - `{baseLayer|Array<baseLayer>} baseLayers`:地图
  152. - `{Object} options`:属性
  153. - 返回值 `this`
  154. ```js
  155. //属性参数 (可选)
  156. const options = {
  157. "name": "电子地图",//名称
  158. "iconUrl": "../preview.png",//缩略图
  159. "alpha": 1.0,
  160. "nightAlpha": 1.0,
  161. "dayAlpha": 1.0,
  162. "brightness": 1.0,
  163. "contrast": 1.0,
  164. "hue": 1.0,
  165. "saturation": 1.0,
  166. "gamma": 1.0
  167. }
  168. ```
  169. - **_changeBaseLayer(index)_**
  170. 更改地图
  171. - 参数
  172. - `{Number} index`:地图索引
  173. - 返回值 `this`
  174. - **_getImageryLayerInfo(windowPosition)_**
  175. 获取瓦片信息
  176. - 参数
  177. - `{Object} windowPosition`:窗口坐标
  178. - 返回值 `promise`
  179. - **_setTerrain(terrain)_**
  180. 设置地形
  181. - 参数
  182. - `{Terrain} terrain`:地形
  183. - 返回值 `this`
  184. - **_addLayerGroup(layerGroup)_**
  185. 添加图层组
  186. - 参数
  187. - `{LayerGroup} layerGroup`:图层组
  188. - 返回值 `this`
  189. - **_removeLayerGroup(layerGroup)_**
  190. 移除图层组
  191. - 参数
  192. - `{LayerGroup} layerGroup`:图层组
  193. - 返回值 `this`
  194. - **_getLayerGroup(id)_**
  195. 获取图层组
  196. - 参数
  197. - `{String} id`:图层组 ID
  198. - 返回值 `layerGroup`
  199. - **_addLayer(layer)_**
  200. 添加图层
  201. - 参数
  202. - `{Layer} layer`:图层
  203. - 返回值 `this`
  204. - **_removeLayer(layer)_**
  205. 删除图层
  206. - 参数
  207. - `{Layer} layer`:图层
  208. - 返回值 `this`
  209. - **_getLayer(id)_**
  210. 获取图层
  211. - 参数
  212. - `{String} id`:图层 ID
  213. - 返回值 `layer`
  214. - **_getLayers()_**
  215. 获取所有图层,不包括地图
  216. - 返回值 `layer`
  217. - **_eachLayer(method, context)_**
  218. 遍历所有图层
  219. - 参数
  220. - `{Function} method`:回调函数
  221. - `{Object} context`:上下文,默认为 this
  222. - 返回值 `this`
  223. ```js
  224. viewer.eachLayer((layer) => {})
  225. ```
  226. - **_flyTo(target,duration)_**
  227. 飞向目标
  228. - 参数
  229. - `{VectorLayer|Overlay} target` :目标
  230. - `{Number} duration`:飞到位置时间,单位:秒
  231. - 返回值 `this`
  232. - **_zoomTo(target)_**
  233. 缩放到目标
  234. - 参数
  235. - `{VectorLayer|Overlay} target` :目标
  236. - 返回值 `this`
  237. - **_flyToPosition(position, completeCallback, duration)_**
  238. 飞到具体位置
  239. - 参数
  240. - `{Position} position`:位置
  241. - `{Function} completeCallback`:飞完之后触发的回调
  242. - `{Number} duration`:飞到位置时间,单位:秒
  243. - 返回值 `this`
  244. - **_zoomToPosition(position, completeCallback)_**
  245. 缩放到具体位置
  246. - 参数
  247. - `{DC.Position} position`:位置
  248. - `{Function} completeCallback`:缩放完成后触发的回调
  249. - 返回值 `this`
  250. - **_flyToBounds(bounds,{heading,pitch,roll}, completeCallback, duration)_**
  251. 飞到指定的范围
  252. - 参数
  253. - `{String|Array} bounds`:范围,格式:[minX,minY,maxX,maxY]
  254. - `{Object} hpr`:方位角
  255. - `{Function} completeCallback`:飞完之后触发的回调
  256. - `{Number} duration`:飞到位置时间,单位:秒
  257. - 返回值 `this`
  258. - **_zoomToBounds(bounds,{heading,pitch,roll}, completeCallback)_**
  259. 缩放到指定的范围
  260. - 参数
  261. - `{String|Array} bounds`:范围,格式:[minX,minY,maxX,maxY]
  262. - `{Object} hpr`:方位角
  263. - `{Function} completeCallback`:缩放完之后触发的回调
  264. - 返回值 `this`
  265. - **_on(type, callback, context)_**
  266. 事件订阅
  267. - 参数
  268. - `{Object} type` :订阅类型
  269. - `{Function} callback` :订阅回调
  270. - `{Object} context` :上下文
  271. - 返回值 `this`
  272. - **_once(type, callback, context)_**
  273. 事件订阅(一次)
  274. - 参数
  275. - `{Object} type` :订阅类型
  276. - `{Function} callback` :订阅回调
  277. - `{Object} context` :上下文
  278. - 返回值 `this`
  279. - **_off(type, callback, context)_**
  280. 取消事件订阅
  281. - 参数
  282. - `{Object} type` :订阅类型
  283. - `{Function} callback` :订阅回调
  284. - `{Object} context` :上下文
  285. - 返回值 `this`
  286. - **_destroy()_**
  287. 销毁三维场景
  288. - 返回值 `this`
  289. - **_exportScene(name)_**
  290. 导出场景
  291. - 参数
  292. - `{String} name` :名称,默认为 scene
  293. - 返回值 `this`
  294. ## Popup
  295. > 气泡窗口
  296. ### example
  297. ```js
  298. let popup = viewer.popup
  299. popup.setContent('<div></div>')
  300. ```
  301. ### properties
  302. - `{String} state`:状态 **_`readonly`_**
  303. - `{Object} config`:配置 **_`writeOnly`_**
  304. ```js
  305. // 配置(可选),配置后会影响全局的popup的显示样式,请慎重。
  306. const config = {
  307. "position": "center",// popup的位于鼠标的点击位置的方向,有:center,left ,right
  308. "customClass": "custom"// 添加自定义的Css 类名到popup中,多个用空格隔开
  309. }
  310. ```
  311. ### methods
  312. - **_setPosition(position)_**
  313. 设置位置
  314. - 参数
  315. - `{Cartesian3} position`:世界坐标
  316. - 返回值 `this`
  317. - **_setContent(content)_**
  318. 设置内容
  319. - 参数
  320. - `{String|Element} content`:内容
  321. - 返回值 `this`
  322. - **_setWrapper(wrapper)_**
  323. 设置容器
  324. - 参数
  325. - `{Element} wrapper`:容器 **_`(一般用于 MVVM 框架的模板)`_**
  326. - 返回值 `this`
  327. - **_showAt(position, content)_**
  328. 设置内容
  329. - 参数
  330. - `{Cartesian3} position`:世界坐标
  331. - `{String|Element} content`:内容
  332. - 返回值 `this`
  333. - **_hide()_**
  334. 隐藏气泡窗口
  335. - 返回值 `this`
  336. ## ContextMenu
  337. > 右击菜单
  338. ### example
  339. ```js
  340. let contextMenu = viewer.contextMenu
  341. contextMenu.enable = true
  342. contextMenu.DEFAULT_MENU = [
  343. {
  344. label: '测试',
  345. callback: (e) => {
  346. }, // e是一个对象主要包括 windowPosition,position,surfacePosition,overlay
  347. context: this,
  348. },
  349. ] // 设置默认的右击菜单,会影响全局右击菜单(慎用)。
  350. ```
  351. ### properties
  352. - `{Boolean} enable`:是否启用
  353. - `{String} state`:状态 **_`readonly`_**
  354. - `{Array} DEFAULT_MENU`:默认菜单,菜单的回调函数参数为一个对象 **_`writeOnly`_**
  355. ## Tooltip
  356. > 提示框
  357. ### example
  358. ```js
  359. let tooltip = viewer.tooltip
  360. tooltip.enable = true
  361. tooltip.showAt({ x: 100, y: 100 }, '测试')
  362. ```
  363. ### properties
  364. - `{Boolean} enable`:是否启用
  365. - `{String} state`:状态 **_`readonly`_**
  366. ### methods
  367. - **_showAt(position,content)_**
  368. 设置位置
  369. - 参数
  370. - `{Cartesian2} position`:屏幕坐标
  371. - `{String|Element} content`:内容
  372. - 返回值 `this`
  373. ## MapSplit
  374. > 地图分割
  375. ### examples
  376. ```js
  377. let baseLayer_elc = DC.ImageryLayerFactory.createGoogleImageryLayer()
  378. viewer.mapSplit.enable = true
  379. viewer.mapSplit.addBaseLayer(baseLayer_elc, -1)
  380. ```
  381. ### properties
  382. - `{Boolean} enable`:是否启用
  383. - `{String} state`:状态 **_`readonly`_**
  384. ### methods
  385. - **_addBaseLayer(baseLayer,[splitDirection])_**
  386. 添加地图
  387. - 参数
  388. - `{BaseLayer} baseLayer`:地图
  389. - `{Number} splitDirection`:分割方向,-1:左,0:无,1:右
  390. - 返回值 `this`
  391. ## TilesetSplit
  392. > 模型分割
  393. ### examples
  394. ```js
  395. let tileset = new DC.Tileset('**/tileset.json')
  396. tileset.setSplitDirection(1)
  397. viewer.tilesetSplit.enable = true
  398. viewer.tilesetSplit.addTileset(tileset)
  399. ```
  400. ### properties
  401. - `{Boolean} enable`:是否启用
  402. - `{String} state`:状态 **_`readonly`_**
  403. ### methods
  404. - **_addTileset(tileset)_**
  405. 添加地图
  406. - 参数
  407. - `{Tileset} tileset`:模型
  408. - 返回值 `this`
  409. ## SceneSplit
  410. > 场景分割
  411. ### examples
  412. ```js
  413. let tileset = new DC.Tileset('**/tileset.json')
  414. tileset.setSplitDirection(1)
  415. viewer.sceneSplit.enable = true
  416. viewer.sceneSplit.addTileset(tileset)
  417. ```
  418. ### properties
  419. - `{Boolean} enable`:是否启用
  420. - `{String} state`:状态 **_`readonly`_**
  421. ### methods
  422. - **_addBaseLayer(baseLayer)_**
  423. 添加地图
  424. - 参数
  425. - `{BaseLayer} baseLayer`:地图
  426. - 返回值 `this`
  427. - **_addTileset(tileset)_**
  428. 添加地图
  429. - 参数
  430. - `{Tileset} tileset`:模型
  431. - 返回值 `this`
  432. ## Compass
  433. > 罗盘
  434. ### examples
  435. ```js
  436. viewer.compass.enable = true
  437. ```
  438. ### properties
  439. - `{Boolean} enable`:是否启用
  440. - `{String} state`:状态 **_`readonly`_**
  441. ## ZoomController
  442. > 缩放控制
  443. ### examples
  444. ```js
  445. viewer.zoomController.enable = true
  446. ```
  447. ### properties
  448. - `{Boolean} enable`:是否启用
  449. - `{String} state`:状态 **_`readonly`_**
  450. ## LocationBar
  451. > 坐标信息
  452. ### examples
  453. ```js
  454. viewer.locationBar.enable = true
  455. ```
  456. ### properties
  457. - `{Boolean} enable`:是否启用
  458. - `{String} state`:状态 **_`readonly`_**
  459. ## DistanceLegend
  460. > 比例尺
  461. ### examples
  462. ```js
  463. viewer.distanceLegend.enable = true
  464. ```
  465. ### properties
  466. - `{Boolean} enable`:是否启用
  467. - `{String} state`:状态 **_`readonly`_**
  468. ## LoadingMask
  469. > 加载蒙层
  470. ### examples
  471. ```js
  472. viewer.loadingMask.enable = true
  473. ```
  474. ### properties
  475. - `{Boolean} enable`:是否启用
  476. - `{String} state`:状态 **_`readonly`_**
  477. ## DC.SkyBox
  478. > 天空盒,[详情参考](http://resource.dvgis.cn/cesium-docs/SkyBox.html)
  479. ### example
  480. ```js
  481. scene.skyBox = new DC.SkyBox({
  482. sources: {
  483. positiveX: 'skybox_px.png',
  484. negativeX: 'skybox_nx.png',
  485. positiveY: 'skybox_py.png',
  486. negativeY: 'skybox_ny.png',
  487. positiveZ: 'skybox_pz.png',
  488. negativeZ: 'skybox_nz.png',
  489. },
  490. })
  491. ```
  492. ### creation
  493. - **_constructor(id)_**
  494. 构造函数
  495. - 参数
  496. - `{Object} options`:配置
  497. - 返回值 `skyBox`
  498. ```js
  499. //options(可选)
  500. const options = {
  501. "sources": {},// 六个面的贴图
  502. "show": true//显示
  503. }
  504. ```
  505. ### properties
  506. - `{Object} sources`:六个面的贴图
  507. - `{Boolean} show`:显示
  508. ## DC.GroundSkyBox
  509. > 近地天空盒,[详情参考](http://resource.dvgis.cn/cesium-docs/SkyBox.html)
  510. ### example
  511. ```js
  512. scene.skyBox = new DC.GroundSkyBox({
  513. sources: {
  514. positiveX: 'skybox_px.png',
  515. negativeX: 'skybox_nx.png',
  516. positiveY: 'skybox_py.png',
  517. negativeY: 'skybox_ny.png',
  518. positiveZ: 'skybox_pz.png',
  519. negativeZ: 'skybox_nz.png',
  520. },
  521. })
  522. ```
  523. ### creation
  524. - **_constructor(id)_**
  525. 构造函数
  526. - 参数
  527. - `{Object} options`:配置
  528. - 返回值 `skyBox`
  529. ```json
  530. //options(可选)
  531. {
  532. "sources": {},
  533. // 六个面的贴图
  534. "show": true,
  535. //显示
  536. "offsetAngle": 0
  537. //旋转角度
  538. }
  539. ```
  540. ### properties
  541. - `{Object} sources`:六个面的贴图
  542. - `{Boolean} show`:显示
  543. - `{Number} offsetAngle`:旋转角度
  544. ## DC.Position
  545. > 坐标类,用于描述物体在场景中的具体位置,采用右手标准
  546. ### example
  547. ```js
  548. let position = new DC.Position(120, 22, 102)
  549. let position1 = DC.Position.fromString('120,22,102')
  550. let position2 = DC.Position.fromArray([120, 22, 102])
  551. let position3 = DC.Position.fromObject({ lng: 120, lat: 22, height: 102 })
  552. ```
  553. ### creation
  554. - **_constructor(lng,lat,alt,heading,pitch,roll)_**
  555. 构造函数
  556. - 参数
  557. - `{Number} lng`:经度
  558. - `{Number} lat`:纬度
  559. - `{Number} alt`:高度,单位:米,默认:0
  560. - `{Number} heading`:偏航角度,可能其他框架作 yaw,表示绕 Z 轴旋转。默认:0
  561. - `{Number} pitch`:俯仰角度,表示绕 Y 轴旋转。默认:0
  562. - `{Number} roll`:翻转角度,表示绕 X 轴旋转。默认:0
  563. - 返回值 `position`
  564. ### properties
  565. - `{Number} lng`:经度
  566. - `{Number} lat`:纬度
  567. - `{Number} alt`:高度,单位:米,默认:0
  568. - `{Number} heading`:偏航角度,可能其他框架作 yaw,表示绕 Z 轴旋转。默认:0
  569. - `{Number} pitch`:俯仰角度,表示绕 Y 轴旋转。默认:0
  570. - `{Number} roll`:翻转角度,表示绕 X 轴旋转。默认:0
  571. ### methods
  572. - **_serialize()_**
  573. 序列化
  574. - 返回值 `string`
  575. - **_copy()_**
  576. 复制一个新的位置
  577. - 返回值 `position`
  578. - **_toString()_**
  579. 将坐标字符化
  580. - 返回值 `string`
  581. - **_toArray()_**
  582. 将坐标数组化
  583. - 返回值 `array`
  584. - **_toObject()_**
  585. 将坐标对象化
  586. - 返回值 `Object`
  587. ### static methods
  588. - **_fromString(str)_**
  589. 将字符化坐标转换为坐标对象
  590. - 参数
  591. - `{String} str`:字符化坐标
  592. - 返回值 `position`
  593. - **_fromArray(array)_**
  594. 将数组化坐标转换为坐标对象
  595. - 参数
  596. - `{Array} array`:数组化坐标
  597. - 返回值 `position`
  598. - **_fromObject(obj)_**
  599. 将 Json 对象坐标转换为坐标对象
  600. - 参数
  601. - `{Object} obj`:Json 对象坐标
  602. - 返回值 `position`
  603. - **_fromCoordString(str)_** `deprecated`
  604. 字符坐标串转换为坐标对象
  605. - 参数
  606. - `{String} str`:字符坐标串
  607. - 返回值 `position`
  608. - **_fromCoordArray(array)_** `deprecated`
  609. 坐标数组转换为坐标对象
  610. - 参数
  611. - `{Array<String|Number>} array`:坐标数组
  612. - 返回值 `position`
  613. - **_deserialize(valStr)_**
  614. 反序列化
  615. - 参数
  616. - `{String} valStr`:序列化的对象
  617. - 返回值 `position`
  618. ## DC.Color
  619. > 颜色类
  620. ### example
  621. ```js
  622. let red = DC.Color.RED
  623. ```
  624. ### properties
  625. - `{Color} RED`:红色
  626. - `{Color} YELLOW`:黄色
  627. - `{Color} WHITE`:白色
  628. - `{Color} GREEN`:绿色
  629. [其他颜色](http://resource.dvgis.cn/cesium-docs/Color.html)
  630. ## DC.TilesetStyle
  631. > tileset 样式,用于设置 3dtiles 的颜色设置
  632. ### example
  633. ```js
  634. let style = new DC.TilesetStyle()
  635. style.color = {
  636. conditions: [
  637. ['${floor} >= 5', 'rgb(198, 106, 11)'],
  638. ['true', 'rgb(127, 59, 8)'],
  639. ],
  640. }
  641. ```
  642. [详情参考](http://resource.dvgis.cn/cesium-docs/Cesium3DTileStyle.html)
  643. ## DC.JulianDate
  644. > 朱莉安日历
  645. ```js
  646. let date = DC.JulianDate.now()
  647. ```
  648. ### static methods
  649. - **_now()_**
  650. 当前朱莉安时间
  651. - 返回值 `date`
  652. - **_fromDate(date)_**
  653. 通过 Js 时间创建朱莉安时间
  654. - 参数
  655. - `{Date} date`:Js 时间
  656. - 返回值 `date`
  657. [JulianDate](http://resource.dvgis.cn/cesium-docs/JulianDate.html)
  658. ## DC.Rectangle
  659. > 矩形相关函数
  660. ### example
  661. ```js
  662. let r = DC.Rectangle.fromDegrees(10, 20, 12, 31)
  663. ```
  664. [详情参考](http://resource.dvgis.cn/cesium-docs/Rectangle.html)
  665. ## DC.CallbackProperty
  666. > 回调属性,用户通过自定义回调函数来返回需要的值。回调函数中,用户可以使用 time 给定 value,也可以自定设置。
  667. ```js
  668. let position = new DC.Position(120, 20)
  669. let point = new DC.Point(position)
  670. let size = 0
  671. point.setStyle({
  672. pixelSize: new DC.CallbackProperty((time) => {
  673. size += 1
  674. if (size == 10) {
  675. size = 0
  676. }
  677. return size
  678. }),
  679. })
  680. ```
  681. ## DC.Parse
  682. > 坐标解析工具类,可简写为 DC.P
  683. ```js
  684. let position = DC.P.parsePosition('123,32,0')
  685. ```
  686. ### static methods
  687. - **_parsePosition(position)_**
  688. 解析坐标为 DC.Position
  689. - 参数
  690. - `{String|Array|Position} position`:坐标
  691. - 返回值 `position`
  692. - **_parsePositions(positions)_**
  693. 解析坐标为 Array<DC.Position>
  694. - 参数
  695. - `{String|Array} positions`: 坐标
  696. - 返回值 `array`
  697. - **_parsePointCoordToArray(position)_**
  698. 解析点位坐标为数组
  699. - 参数
  700. - `{String|Position} position`:点位坐标
  701. - 返回值 `array`
  702. - **_parsePolylineCoordToArray(positions)_**
  703. 解析线坐标为二维数组
  704. - 参数
  705. - `{String|Array} positions`:线坐标
  706. - 返回值 `array`
  707. - **_parsePolygonCoordToArray(positions,loop)_**
  708. 解析面坐标为三维数组
  709. - 参数
  710. - `{String|Array} positions`:面坐标
  711. - `{Boolean} loop`:闭合
  712. - 返回值 `array`
  713. ## DC.Transform
  714. > 坐标转换工具类 ,可简写为 DC.T
  715. ```js
  716. let cartesian3 = DC.T.transformWGS84ToCartesian(new DC.Position(120, 20))
  717. ```
  718. ### static methods
  719. - **_transformCartesianToWGS84(cartesian)_**
  720. 世界坐标转换为 84 坐标
  721. - 参数
  722. - `{Cartesian3} cartesian`:世界坐标
  723. - 返回值 `position`
  724. - **_transformWGS84ToCartesian(position)_**
  725. 84 坐标转换为世界坐标
  726. - 参数
  727. - `{Position} position`:84 坐标
  728. - 返回值 `cartesian`
  729. - **_transformWGS84ToCartographic(position)_**
  730. 84 坐标转换为制图坐标
  731. - 参数
  732. - `{Position} position`:84 坐标
  733. - 返回值 `cartographic`
  734. - **_transformCartesianArrayToWGS84Array(cartesianArr)_**
  735. 世界坐标数组转 84 坐标数组
  736. - 参数
  737. - `{Array<cartesian3>} cartesianArr`:世界坐标数组
  738. - 返回值 `array`
  739. - **_transformWGS84ArrayToCartesianArray(WGS84Arr)_**
  740. 84 坐标数组转世界坐标数组
  741. - 参数
  742. - `{Array<cartesian3>} WGS84Arr`:84 坐标数组
  743. - 返回值 `array`
  744. - **_transformWGS84ToMercator(position)_**
  745. 84 坐标转 Mercator
  746. - 参数
  747. - `{Position} position`:84 坐标
  748. - 返回值 `position`
  749. - **_transformMercatorToWGS84(position)_**
  750. Mercator 坐标转 84
  751. - 参数
  752. - `{Position} position`:Mercator 坐标
  753. - 返回值 `position`
  754. - **_transformWindowToWGS84(position,viewer)_**
  755. 屏幕坐标转 84
  756. - 参数
  757. - `{Object} position`: 屏幕坐标,格式`{x:1,y:1}`
  758. - `{Viewer} viewer`:3D 场景
  759. - 返回值 `position`
  760. - **_transformWGS84ToWindow(position,viewer)_**
  761. 84 转屏幕坐标
  762. - 参数
  763. - `{Position} position`: 84 坐标
  764. - `{Viewer} viewer`:3D 场景
  765. - 返回值 `Object`
  766. ## DC.CoordTransform
  767. > 国内坐标转换工具
  768. ```js
  769. let point = DC.CoordTransform.BD09ToGCJ02(120, 20)
  770. ```
  771. ### static methods
  772. - **_BD09ToGCJ02(lng, lat)_**
  773. 百度坐标系 (BD-09) 的转换 火星坐标系 (GCJ-02)
  774. - 参数
  775. - `{Number} lng`:经度
  776. - `{Number} lat`:纬度
  777. - 返回值 `[]`
  778. - **_GCJ02ToBD09(lng, lat)_**
  779. 火星坐标系 (GCJ-02) 转换为 百度坐标系 (BD-09)
  780. - 参数
  781. - `{Number} lng`:经度
  782. - `{Number} lat`:纬度
  783. - 返回值 `[]`
  784. - **_WGS84ToGCJ02(lng, lat)_**
  785. WGS-84 转换为 火星坐标系 (GCJ-02)
  786. - 参数
  787. - `{Number} lng`:经度
  788. - `{Number} lat`:纬度
  789. - 返回值 `[]`
  790. - **_GCJ02ToWGS84(lng, lat)_**
  791. 火星坐标系 (GCJ-02) 转换为 WGS-84
  792. - 参数
  793. - `{Number} lng`:经度
  794. - `{Number} lat`:纬度
  795. - 返回值 `[]`
  796. ## DC.Math
  797. > 基本函数类
  798. ### static methods
  799. - **_area(positions)_**
  800. 面积,单位:平方米
  801. - 参数
  802. - `{Array<Position>} positions`: 点位数据
  803. - 返回值 `number`
  804. - **_bounds(positions , expand)_**
  805. 边界
  806. - 参数
  807. - `{Array<Position>} positions`: 点位数据
  808. - `{Number}} expand`: 扩展比例:0~1
  809. - 返回值 `object`
  810. - **_mid(start , end)_**
  811. 两点之间的中心点
  812. - 参数
  813. - `start`: 开始位置
  814. - `end`: 结束位置
  815. - 返回值 `position`
  816. - **_center(positions)_**
  817. 中心点
  818. - 参数
  819. - `{Array<Position>} positions`: 点位数据
  820. - 返回值 `position`
  821. - **_distance(positions)_**
  822. 距离,单位:米
  823. - 参数
  824. - `{Array<Position>} positions`: 点位数据
  825. - 返回值 `number`
  826. - **_heading(start,end)_**
  827. 偏转角度,单位:度
  828. - 参数
  829. - `start`: 开始位置
  830. - `end`: 结束位置
  831. - 返回值 `number`
  832. - **_parabola(start, end,height,count)_**
  833. 抛物线
  834. - 参数
  835. - `start`: 开始位置
  836. - `end`: 结束位置
  837. - `{Number} height`: 最高点高度
  838. - `{Number} count`: 点位数量
  839. - 返回值 `Array`
  840. > [more](http://resource.dvgis.cn/cesium-docs/Math.html)
  841. ## DC.Util
  842. > 工具类
  843. ### static methods
  844. - **_uuid(prefix)_**
  845. 生成 uuid
  846. - 参数
  847. - `{String} prefix`:前缀,默认为 D
  848. - 返回值 `string`
  849. - **_merge(dest, ...sources)_**
  850. 属性合并
  851. - 参数
  852. - `{Object} dest`:目标对象
  853. - `{Object|Array} sources`:需要合并的属性
  854. - 返回值 `object`
  855. - **_emptyImageUrl()_**
  856. 空图片
  857. - **_debounce(fn,delay)_**
  858. 防抖
  859. - **_throttle(fn,delay)_**
  860. 节流
  861. ## DC.DomUtil
  862. > Dom 工具类
  863. ### static methods
  864. - **_get(id)_**
  865. 创建 dom
  866. - 参数
  867. - `{String} id`: 要素 ID
  868. - 返回值 `Element`
  869. - **_create(tagName, className, [container])_**
  870. 创建 dom
  871. - 参数
  872. - `{String} tagName`: 标签名
  873. - `{String} className`: 样式名,多个用空格隔开
  874. - `{Element} [container]`: 父容器
  875. - 返回值 `Element`
  876. - **_addClass(el, name)_**
  877. 添加类名
  878. - 参数
  879. - `{Element} el`: 要素
  880. - `{String} className`: 样式名,多个用空格隔开
  881. - **_removeClass(el, name)_**
  882. 删除类名
  883. - 参数
  884. - `{Element} el`: 要素
  885. - `{String} className`: 样式名,多个用空格隔开
  886. - **_addClass(el, name)_**
  887. 添加类名
  888. - 参数
  889. - `{Element} el`: 要素
  890. - `{String} className`: 样式名,多个用空格隔开
  891. - **_createSvg(width, height, path, [container])_**
  892. 添加类名
  893. - 参数
  894. - `{Number} width`: 宽度
  895. - `{Number} height`: 高度
  896. - `{String} path`: 路径
  897. - `{Element} [container]`: 父容器
  898. - 返回值 `svg`
  899. - **_parseDom(domStr, [withWrapper], [className])_**
  900. 字符串转 Dom
  901. - 参数
  902. - `{String} domStr`: dom 字符串
  903. - `{Boolean} withWrapper`:返回是否含有父容器
  904. - `{String} className`: 类样式名称
  905. - 返回值 `Element | Nodes`
  906. - **_enterFullscreen(el)_**
  907. 进入全屏
  908. - 参数
  909. - `{Element} el`: 要素
  910. - **_exitFullscreen()_**
  911. 退出全屏
  912. - **_createVideo(url, className, [container])_**
  913. 创建视频节点
  914. - 参数
  915. - `{String} url`: 视频地址
  916. - `{String} className`: 样式名,多个用空格隔开
  917. - `{Element} [container]`: 父容器
  918. - 返回值 `Element | Nodes`