Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

2 роки тому
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397
  1. ---
  2. sidebar: auto
  3. ---
  4. # Base 🌎
  5. ## Namespace
  6. **`DC`**
  7. DC is the default namespace for the framework.When developing with this framework, you need to start with `DC.`
  8. :::danger
  9. Try not to use DC as variable names or namespaces when developing to avoid the framework not working properly.
  10. :::
  11. **`Cesium`**
  12. [Cesium](https://cesium.com/cesiumjs/) is a world-class ES6 open source product for 3D GIS. The product is convenient for individuals or teams to quickly build a plug-in-free 3D GIS web application, in terms of performance, accuracy, rendering quality, cross-platform are very good guarantee. If you need Cesium's internal interface during development, you can get Cesium through **`const { Cesium } = DC.Namespace`**.
  13. **`mapv`**
  14. [Mapv](https://mapv.baidu.com/) is a geographic information visualization open source library , can be used to display a large amount of geographic information data , point , line , surface data , each data also has different types of display , such as direct hit points , heat map , grid , aggregation and other ways to display data . If you need Mapv's internal interface during development, you can get Mapv through **`const { mapv } = DC.Namespace`**.
  15. **`turf`**
  16. [Turf](https://mapv.baidu.com/) is a JavaScript library for spatial analysis. It includes traditional spatial operations, helper functions for creating GeoJSON data, and data classification and statistics tools. Turf can be added to your website as a client-side plugin, or you can run Turf server-side with Node.js . If you need Turf's internal interface during development, you can get Turf through **`const { turf } = DC.Namespace`**.
  17. ## Global Properties
  18. ### version
  19. > Framework version number
  20. ### accessToken
  21. > Used to remove logo and console output information. `does not affect the use of the framework`
  22. ```js
  23. DC.accessToken = '<your access token>'
  24. ```
  25. :::tip
  26. Token requests can be made via [http://dvgis.cn/#/price](http://dvgis.cn/#/price)
  27. :::
  28. ### baseUrl
  29. > Path to set the static resource files associated with `Cesium`: `Assets`, `Workers`, `ThirdParty`, `Widgets`
  30. ```js
  31. DC.baseUrl = '. /libs/dc-sdk/resources/'
  32. DC.ready(() => {})
  33. ```
  34. :::warning
  35. The `baseUrl` setting needs to be set before the `ready` function, otherwise the default setting of `. /libs/dc-sdk/resources/`
  36. :::
  37. ### Namespace
  38. > Namespace collection for third-party libraries
  39. ## Global Methods
  40. ### use
  41. > Using third-party modules or frameworks in DC frameworks
  42. ```js
  43. let plugin = {
  44. install: (DC) => {},
  45. }
  46. DC.use(plugin)
  47. ```
  48. ### mixin
  49. > Adding additional properties or functions to the DC
  50. ```js
  51. let comp = {
  52. a: 'b',
  53. }
  54. DC.mixin(comp)
  55. DC.a // b
  56. ```
  57. ### init
  58. > This function is used to initialize Cesium, the default Cesium is the latest version, if you use a custom version of Cesium, you can modify the reference to Cesium before the DC loads other modules, thus replacing Cesium in the entire DC system **_`(use with caution)`_**
  59. ```js
  60. DC.init(() => {
  61. DC.Namespace['Cesium'] = '<自定义Cesium>'
  62. DC.use(DcCore)
  63. })
  64. ```
  65. ### ready
  66. > The main entrance to the framework, you must start with this when using the framework, otherwise you cannot build 3D scenes
  67. ```js
  68. global.DC = DC
  69. DC.use(DcCore)
  70. DC.ready(() => {
  71. let viewer = new DC.Viewer(divId)
  72. })
  73. ```
  74. ## Constants
  75. > Framework internal default constants
  76. ::: warning
  77. Please use the default constants for development
  78. :::
  79. ### MouseEventType
  80. **_`DC.MouseEventType.LEFT_DOWN`_**
  81. **_`DC.MouseEventType.LEFT_UP`_**
  82. **_`DC.MouseEventType.CLICK`_**
  83. **_`DC.MouseEventType.RIGHT_DOWN`_**
  84. **_`DC.MouseEventType.RIGHT_UP`_**
  85. **_`DC.MouseEventType.RIGHT_CLICK`_**
  86. **_`DC.MouseEventType.DB_CLICK`_**
  87. **_`DC.MouseEventType.MOUSE_MOVE`_**
  88. **_`DC.MouseEventType.WHEEL`_**
  89. **_`DC.MouseEventType.MOUSE_OVER`_**
  90. **_`DC.MouseEventType.MOUSE_OUT`_**
  91. ### SceneEventType
  92. **_`DC.SceneEventType.CAMERA_MOVE_END`_**
  93. **_`DC.SceneEventType.CAMERA_CHANGED`_**
  94. **_`DC.SceneEventType.PRE_UPDATE`_**
  95. **_`DC.SceneEventType.POST_UPDATE`_**
  96. **_`DC.SceneEventType.PRE_RENDER`_**
  97. **_`DC.SceneEventType.POST_RENDER`_**
  98. **_`DC.SceneEventType.MORPH_COMPLETE`_**
  99. **_`DC.SceneEventType.CLOCK_TICK`_**
  100. **_`DC.SceneEventType.RENDER_ERROR`_**
  101. ### AnalysisType
  102. **_`DC.AnalysisType.CONTOUR_LINE`_**
  103. **_`DC.AnalysisType.SHADOWS`_**
  104. **_`DC.AnalysisType.SIGHT_CIRCLE`_**
  105. **_`DC.AnalysisType.SIGHT_LINE`_**
  106. **_`DC.AnalysisType.VIEWSHED`_**
  107. ### MouseMode
  108. **_`DC.MouseMode.LEFT_MIDDLE`_**
  109. **_`DC.MouseMode.LEFT_RIGHT`_**
  110. ### ImageryType
  111. **_`DC.ImageryType.ARCGIS`_**
  112. **_`DC.ImageryType.SINGLE_TILE`_**
  113. **_`DC.ImageryType.WMS`_**
  114. **_`DC.ImageryType.WMTS`_**
  115. **_`DC.ImageryType.XYZ`_**
  116. **_`DC.ImageryType.COORD`_**
  117. **_`DC.ImageryType.GRID`_**
  118. **_`DC.ImageryType.MAPBOX`_**
  119. **_`DC.ImageryType.MAPBOX_STYLE`_**
  120. **_`DC.ImageryType.TMS`_**
  121. **_`DC.ImageryType.AMAP`_**
  122. **_`DC.ImageryType.BAIDU`_**
  123. **_`DC.ImageryType.GOOGLE`_**
  124. **_`DC.ImageryType.TDT`_**
  125. **_`DC.ImageryType.TENCENT`_**
  126. ### TerrainType
  127. **_`DC.TerrainType.NONE`_**
  128. **_`DC.TerrainType.XYZ`_**
  129. **_`DC.TerrainType.GOOGLE`_**
  130. **_`DC.TerrainType.ARCGIS`_**
  131. **_`DC.TerrainType.VR`_**
  132. ### LayerType
  133. **_`DC.LayerType.VECTOR`_**
  134. **_`DC.LayerType.PRIMITIVE`_**
  135. **_`DC.LayerType.TILESET`_**
  136. **_`DC.LayerType.HTML`_**
  137. **_`DC.LayerType.GEOJSON`_**
  138. **_`DC.LayerType.CLUSTER`_**
  139. **_`DC.LayerType.CAMERA_VIDEO`_**
  140. **_`DC.LayerType.PLANE_VIDEO`_**
  141. **_`DC.LayerType.KML`_**
  142. **_`DC.LayerType.CZML`_**
  143. **_`DC.LayerType.HEAT`_**
  144. **_`DC.LayerType.MAPV`_**
  145. **_`DC.LayerType.CHART`_**
  146. ### OverlayType
  147. **_`DC.OverlayType.POINT`_**
  148. **_`DC.OverlayType.POLYLINE`_**
  149. **_`DC.OverlayType.POLYGON`_**
  150. **_`DC.OverlayType.MODEL`_**
  151. **_`DC.OverlayType.BILLBOARD`_**
  152. **_`DC.OverlayType.RECTANGLE`_**
  153. **_`DC.OverlayType.CIRCLE`_**
  154. **_`DC.OverlayType.LABEL`_**
  155. **_`DC.OverlayType.TILESET`_**
  156. **_`DC.OverlayType.BOX`_**
  157. **_`DC.OverlayType.CORRIDOR`_**
  158. **_`DC.OverlayType.CYLINDER`_**
  159. **_`DC.OverlayType.ELLIPSE`_**
  160. **_`DC.OverlayType.ELLIPSOID`_**
  161. **_`DC.OverlayType.PLANE`_**
  162. **_`DC.OverlayType.POLYLINE_VOLUME`_**
  163. **_`DC.OverlayType.WALL`_**
  164. **_`DC.OverlayType.DYNAMIC_BILLBOARD`_**
  165. **_`DC.OverlayType.DYNAMIC_MODEL`_**
  166. **_`DC.OverlayType.CUSTOM_BILLBOARD`_**
  167. **_`DC.OverlayType.CUSTOM_LABEL`_**
  168. **_`DC.OverlayType.ATTACK_ARROW`_**
  169. **_`DC.OverlayType.DOUBLE_ARROW`_**
  170. **_`DC.OverlayType.FINE_ARROW`_**
  171. **_`DC.OverlayType.GATHERING_PLACE`_**
  172. **_`DC.OverlayType.TAILED_ATTACK_ARROW`_**
  173. **_`DC.OverlayType.BILLBOARD_PRIMITIVE`_**
  174. **_`DC.OverlayType.DIFFUSE_WALL_PRIMITIVE`_**
  175. **_`DC.OverlayType.ELEC_ELLIPSOID_PRIMITIVE`_**
  176. **_`DC.OverlayType.FLOW_LINE_PRIMITIVE`_**
  177. **_`DC.OverlayType.LABEL_PRIMITIVE`_**
  178. **_`DC.OverlayType.MODEL_PRIMITIVE`_**
  179. **_`DC.OverlayType.POINT_PRIMITIVE`_**
  180. **_`DC.OverlayType.POLYLINE_PRIMITIVE`_**
  181. **_`DC.OverlayType.SCAN_CIRCLE_PRIMITIVE`_**
  182. **_`DC.OverlayType.TRAIL_LINE_PRIMITIVE`_**
  183. **_`DC.OverlayType.WATER_PRIMITIVE`_**
  184. **_`DC.OverlayType.VIDEO_PRIMITIVE`_**
  185. **_`DC.OverlayType.CAMERA_VIDEO`_**
  186. **_`DC.OverlayType.PLAN_VIDEO`_**
  187. ### TrackViewMode
  188. **_`DC.TrackViewMode.FP`_**
  189. **_`DC.TrackViewMode.TP`_**
  190. **_`DC.TrackViewMode.TRACKED`_**
  191. **_`DC.TrackViewMode.FREE`_**
  192. ## DC.Viewer
  193. > 3D scene primary interface to build 3D scenes in a given DivId, also available as DC.World
  194. ### example
  195. ```html
  196. <div id="viewer-container"></div>
  197. ```
  198. ```js
  199. let viewer = DC.Viewer('viewer-container')
  200. global.viewer = viewer
  201. ```
  202. :::warning
  203. If you are using a MVVM framework like Vue, do not add viewer, layer, or overlay to the data model. Since the 3D scene will keep refreshing each frame, adding data to the data model will cause the browser to crash if it takes a long time.
  204. :::
  205. ### creation
  206. - **_constructor(id,[options])_**
  207. - parameters
  208. - `{String} id`:divId
  209. - `{Object} options`
  210. - returns `viewer`
  211. ```json
  212. //options(optional)
  213. {
  214. "contextOptions": {
  215. "webgl": {
  216. "alpha": false,
  217. "depth": true,
  218. "stencil": false,
  219. "antialias": true,
  220. "powerPreference": "high-performance",
  221. "premultipliedAlpha": true,
  222. "preserveDrawingBuffer": false,
  223. "failIfMajorPerformanceCaveat": false
  224. },
  225. "allowTextureFilterAnisotropic": true
  226. },
  227. "sceneMode": 3 //1: 2.5D,2: 2D,3: 3D
  228. }
  229. ```
  230. ### properties
  231. - `{Element} dcContainer`:custom container **_`readonly`_**
  232. - `{Object} scene` **_`readonly`_**[Scene](http://resource.dvgis.cn/cesium-docs/Scene.html)
  233. - `{Object} camera`**_`readonly`_**[Camera](http://resource.dvgis.cn/cesium-docs/Scene.html)
  234. - `{Element} canvas`**_`readonly`_**
  235. - `{Object} clock`[Clock](http://resource.dvgis.cn/cesium-docs/Clock.html)
  236. - `{Object} dataSources`[DataSourceCollection](http://resource.dvgis.cn/cesium-docs/DataSourceCollection.html)
  237. - `{Object} imageryLayers`[ImageryLayerCollection](http://resource.dvgis.cn/cesium-docs/ImageryLayerCollection.html)
  238. - `{Object} entities`[EntityCollection](http://resource.dvgis.cn/cesium-docs/EntityCollection.html)
  239. - [`{Popup} popup`](#popup)**_`readonly`_**
  240. - [`{ContextMenu} contextMenu`](#contextmenu)**_`readonly`_**
  241. - [`{Tooltip} tooltip`](#tooltip)**_`readonly`_**
  242. - [`{MapSplit} mapSplit`](#mapsplit)**_`readonly`_**
  243. - [`{Compass} compass`](#compass)**_`readonly`_**
  244. - [`{ZoomController} zoomController`](#zoomcontroller)**_`readonly`_**
  245. - [`{LocationBar} locationBar`](#locationbar)**_`readonly`_**
  246. - [`{DistanceLegend} distanceLegend`](#distancelegend)**_`readonly`_**
  247. - [`{LoadingMask} loadingMask`](#loadingmask)**_`readonly`_**
  248. - `{Position} cameraPosition`**_`readonly`_**
  249. - `{Number} resolution`**_`readonly`_**
  250. - `{Number} level`**_`readonly`_**
  251. - `{Rect} viewBounds`**_`readonly`_**
  252. ### methods
  253. - **_setOptions(options)_**
  254. - parameters
  255. - `{Object} options`:属性对象
  256. - returns `this`
  257. ```json
  258. // options(optional)
  259. {
  260. "shadows": false,
  261. "resolutionScale": 1,
  262. "showAtmosphere": true,
  263. "showSun": true,
  264. "showMoon": true,
  265. "enableFxaa": true,
  266. "msaaSamples": 1,
  267. "cameraController": {
  268. "enableRotate": true,
  269. "enableTilt": true,
  270. "enableTranslate": true,
  271. "enableZoom": true,
  272. "enableCollisionDetection": true,
  273. "minimumZoomDistance": 1.0,
  274. "maximumZoomDistance": 40489014.0
  275. },
  276. "globe": {
  277. "show": true,
  278. "showGroundAtmosphere": true,
  279. "enableLighting": false,
  280. "depthTestAgainstTerrain": false,
  281. "tileCacheSize": 100,
  282. "preloadSiblings": false,
  283. "terrainExaggeration": 1,
  284. "terrainExaggerationRelativeHeight": 1,
  285. "baseColor": new DC.Color(0, 0, 0.5, 1),
  286. "filterColor": new DC.Color(0, 0, 0, 0),
  287. "translucency": {
  288. "enabled": false,
  289. "backFaceAlpha": 1,
  290. "backFaceAlphaByDistance": null,
  291. "frontFaceAlpha": 1,
  292. "frontFaceAlphaByDistance": null
  293. }
  294. },
  295. "skyBox": {
  296. "sources": {},
  297. "show": true,
  298. "offsetAngle": 0
  299. }
  300. }
  301. ```
  302. - **_setPitchRange(min,max)_**
  303. - parameters
  304. - `{Number} min`:min angel
  305. - `{Number} max`:max angel
  306. - returns `this`
  307. - **_changeSceneMode(sceneMode, [duration])_**
  308. - parameters
  309. - `{Number} sceneMode`: 2:2D,3:3D,2.5:2.5D
  310. - `{Number} duration`
  311. - returns `this`
  312. - **_changeMouseMode(mouseMode)_**
  313. - parameters
  314. - `{Number} mouseMode`, Refer to:`DC.MouseMode`
  315. - returns `this`
  316. - **_addBaseLayer(baseLayers,[options])_**
  317. - parameters
  318. - `{baseLayer|Array<baseLayer>} baseLayers`
  319. - `{Object} options`
  320. - returns `this`
  321. ```json
  322. //options
  323. {
  324. "name": "map",
  325. "iconUrl": "../preview.png"
  326. }
  327. ```
  328. - **_changeBaseLayer(index)_**
  329. - parameters
  330. - `{Number} index`
  331. - returns `this`
  332. - **_getImageryLayerInfo(windowPosition)_**
  333. - parameters
  334. - `{Object} windowPosition`
  335. - returns `promise`
  336. - **_addTerrain(terrain)_**
  337. - parameters
  338. - `{Terrain} terrain`
  339. - returns `this`
  340. - **_changeTerrain(index)_**
  341. - parameters
  342. - `{Number} index`
  343. - returns `this`
  344. - **_removeTerrain()_**
  345. - returns `this`
  346. - **_addLayerGroup(layerGroup)_**
  347. - parameters
  348. - `{LayerGroup} layerGroup`
  349. - returns `this`
  350. - **_removeLayerGroup(layerGroup)_**
  351. - parameters
  352. - `{LayerGroup} layerGroup`
  353. - returns `this`
  354. - **_getLayerGroup(id)_**
  355. - parameters
  356. - `{String} id`
  357. - returns `layerGroup`
  358. - **_addLayer(layer)_**
  359. - parameters
  360. - `{Layer} layer`
  361. - returns `this`
  362. - **_removeLayer(layer)_**
  363. - parameters
  364. - `{Layer} layer`
  365. - returns `this`
  366. - **_getLayer(id)_**
  367. - parameters
  368. - `{String} id`:layer id
  369. - returns `layer`
  370. - **_getLayers()_**
  371. - returns `layer`
  372. - **_eachLayer(callback, context)_**
  373. - parameters
  374. - `{Function} callback`
  375. - `{Object} context`
  376. - returns `this`
  377. ```js
  378. viewer.eachLayer((layer) => {})
  379. ```
  380. - **_flyTo(target,[duration])_**
  381. - parameters
  382. - `{VectorLayer|Overlay} target`
  383. - `{Number} duration`
  384. - returns `this`
  385. - **_zoomTo(target)_**
  386. - parameters
  387. - `{VectorLayer|Overlay} target`
  388. - returns `this`
  389. - **_flyToPosition(position, [completeCallback], [duration])_**
  390. - parameters
  391. - `{Position} position`
  392. - `{Function} completeCallback`
  393. - `{Number} duration`
  394. - returns `this`
  395. - **_zoomToPosition(position, [completeCallback])_**
  396. - parameters
  397. - `{DC.Position} position`
  398. - `{Function} completeCallback`
  399. - returns `this`
  400. - **_flyToBounds(bounds,{heading,pitch,roll}, completeCallback, duration)_**
  401. - parameters
  402. - `{String|Array} bounds` format:[minX,minY,maxX,maxY]
  403. - `{Object} hpr`
  404. - `{Function} completeCallback`
  405. - `{Number} duration`
  406. - returns `this`
  407. - **_zoomToBounds(bounds,{heading,pitch,roll}, completeCallback)_**
  408. - parameters
  409. - `{String|Array} bounds` format:[minX,minY,maxX,maxY]
  410. - `{Object} hpr`
  411. - `{Function} completeCallback`
  412. - returns `this`
  413. - **_on(type, callback, [context])_**
  414. - parameters
  415. - `{Object} type`
  416. - `{Function} callback`
  417. - `{Object} context`
  418. - returns `this`
  419. - **_once(type, callback, [context])_**
  420. - parameters
  421. - `{Object} type`
  422. - `{Function} callback`
  423. - `{Object} context`
  424. - returns `this`
  425. - **_off(type, callback, [context])_**
  426. - parameters
  427. - `{Object} type`
  428. - `{Function} callback`
  429. - `{Object} context`
  430. - returns `this`
  431. - **_destroy()_**
  432. - returns `this`
  433. - **_exportScene([name])_**
  434. - parameters
  435. - `{String} name`
  436. - returns `this`
  437. - **_use(plugin)_**
  438. - parameters
  439. - `{Object} plugin`
  440. - returns `this`
  441. ```js
  442. let plugin = {
  443. install: (viewer) => {},
  444. }
  445. viewer.use(plugin)
  446. ```
  447. ## Popup
  448. ### example
  449. ```js
  450. let popup = viewer.popup
  451. popup.setContent('<div></div>')
  452. ```
  453. ### properties
  454. - `{String} state`**_`readonly`_**
  455. - `{Object} config`**_`writeOnly`_**
  456. ```json
  457. {
  458. "position": "center", // center,left ,right
  459. "customClass": "custom" // Add a custom Css class name to the popup, separating multiple names with spaces
  460. }
  461. ```
  462. ### methods
  463. - **_setPosition(position)_**
  464. - parameters
  465. - `{Cartesian3} position`: World Coordinates
  466. - returns `this`
  467. - **_setContent(content)_**
  468. - parameters
  469. - `{String|Element} content`
  470. - returns `this`
  471. - **_setWrapper(wrapper)_**
  472. - parameters
  473. - `{Element} wrapper`**_`(Templates for MVVM frameworks in general)`_**
  474. - returns `this`
  475. - **_showAt(position, content)_**
  476. - parameters
  477. - `{Cartesian3} position`
  478. - `{String|Element} content`
  479. - returns `this`
  480. - **_hide()_**
  481. - returns `this`
  482. ## ContextMenu
  483. ### example
  484. ```js
  485. let contextMenu = viewer.contextMenu
  486. contextMenu.enable = true
  487. contextMenu.DEFAULT_MENU = [
  488. {
  489. label: '测试',
  490. callback: (e) => {}, // e: windowPosition,position,surfacePosition,overlay
  491. context: this,
  492. },
  493. ] // Setting the default ContextMenu affects the global ContextMenu (use with caution).
  494. ```
  495. ### properties
  496. - `{Boolean} enable`
  497. - `{String} state`**_`readonly`_**
  498. - `{Array} DEFAULT_MENU`:**_`writeOnly`_**
  499. ## Tooltip
  500. ### example
  501. ```js
  502. let tooltip = viewer.tooltip
  503. tooltip.enable = true
  504. tooltip.showAt({ x: 100, y: 100 }, 'test')
  505. ```
  506. ### properties
  507. - `{Boolean} enable`
  508. - `{String} state` **_`readonly`_**
  509. ### methods
  510. - **_showAt(position,content)_**
  511. - parameters
  512. - `{Cartesian2} position`: Screen Coordinates
  513. - `{String|Element} content`
  514. - returns `this`
  515. ## MapSplit
  516. ### examples
  517. ```js
  518. let baseLayer_elc = DC.ImageryLayerFactory.createGoogleImageryLayer()
  519. viewer.mapSplit.enable = true
  520. viewer.mapSplit.addBaseLayer(baseLayer_elc, -1)
  521. ```
  522. ### properties
  523. - `{Boolean} enable`
  524. - `{String} state`**_`readonly`_**
  525. ### methods
  526. - **_addBaseLayer(baseLayer,splitDirection)_**
  527. - parameters
  528. - `{BaseLayer} baseLayer`
  529. - `{Number} splitDirection`,-1:left,0:none,1:right
  530. - returns `this`
  531. ## Compass
  532. ### examples
  533. ```js
  534. viewer.compass.enable = true
  535. ```
  536. ### properties
  537. - `{Boolean} enable`
  538. - `{String} state` **_`readonly`_**
  539. ## ZoomController
  540. ### examples
  541. ```js
  542. viewer.zoomController.enable = true
  543. ```
  544. ### properties
  545. - `{Boolean} enable`
  546. - `{String} state`**_`readonly`_**
  547. ## LocationBar
  548. ### examples
  549. ```js
  550. viewer.locationBar.enable = true
  551. ```
  552. ### properties
  553. - `{Boolean} enable`
  554. - `{String} state` **_`readonly`_**
  555. ## DistanceLegend
  556. ### examples
  557. ```js
  558. viewer.distanceLegend.enable = true
  559. ```
  560. ### properties
  561. - `{Boolean} enable`
  562. - `{String} state`,**_`readonly`_**
  563. ## LoadingMask
  564. ### examples
  565. ```js
  566. viewer.loadingMask.enable = true
  567. ```
  568. ### properties
  569. - `{Boolean} enable`
  570. - `{String} state`**_`readonly`_**
  571. ## DC.SkyBox
  572. ### example
  573. ```js
  574. scene.skyBox = new DC.SkyBox({
  575. sources: {
  576. positiveX: 'skybox_px.png',
  577. negativeX: 'skybox_nx.png',
  578. positiveY: 'skybox_py.png',
  579. negativeY: 'skybox_ny.png',
  580. positiveZ: 'skybox_pz.png',
  581. negativeZ: 'skybox_nz.png',
  582. },
  583. })
  584. ```
  585. ### creation
  586. - **_constructor(id)_**
  587. - parameters
  588. - `{Object} options`
  589. - returns `skyBox`
  590. ```json
  591. //options(optional)
  592. {
  593. "sources": {},
  594. "show": true
  595. }
  596. ```
  597. ### properties
  598. - `{Object} sources`
  599. - `{Boolean} show`
  600. ## DC.GroundSkyBox
  601. ### example
  602. ```js
  603. scene.skyBox = new DC.GroundSkyBox({
  604. sources: {
  605. positiveX: 'skybox_px.png',
  606. negativeX: 'skybox_nx.png',
  607. positiveY: 'skybox_py.png',
  608. negativeY: 'skybox_ny.png',
  609. positiveZ: 'skybox_pz.png',
  610. negativeZ: 'skybox_nz.png',
  611. },
  612. })
  613. ```
  614. ### creation
  615. - **_constructor(id)_**
  616. - parameters
  617. - `{Object} options`
  618. - returns `groundSkyBox`
  619. ```json
  620. //options(optional)
  621. {
  622. "sources": {},
  623. "show": true,
  624. "offsetAngle": 0
  625. }
  626. ```
  627. ### properties
  628. - `{Object} sources`
  629. - `{Boolean} show`
  630. - `{Number} offsetAngle`
  631. ## DC.Position
  632. ### example
  633. ```js
  634. let position = new DC.Position(120, 22, 102)
  635. let position1 = DC.Position.fromString('120,22,102')
  636. let position2 = DC.Position.fromArray([120, 22, 102])
  637. let position3 = DC.Position.fromObject({ lng: 120, lat: 22, height: 102 })
  638. ```
  639. ### creation
  640. - **_constructor(lng,lat,[alt],[heading],[pitch],[roll])_**
  641. - parameters
  642. - `{Number} lng`
  643. - `{Number} lat`
  644. - `{Number} alt`
  645. - `{Number} heading`
  646. - `{Number} pitch`
  647. - `{Number} roll`
  648. - returns `position`
  649. ### properties
  650. - `{Number} lng`
  651. - `{Number} lat`
  652. - `{Number} alt`
  653. - `{Number} heading`
  654. - `{Number} pitch`
  655. - `{Number} roll`
  656. ### methods
  657. - **_serialize()_**
  658. - returns `string`
  659. - **_copy()_**
  660. - returns `position`
  661. - **_toString()_**
  662. - returns `string`
  663. - **_toArray()_**
  664. - returns `array`
  665. - **_toObject()_**
  666. - returns `Object`
  667. ### static methods
  668. - **_fromString(str)_**
  669. - parameters
  670. - `{String} str`
  671. - returns `position`
  672. - **_fromArray(array)_**
  673. - parameters
  674. - `{Array} array`
  675. - returns `position`
  676. - **_fromObject(obj)_**
  677. - parameters
  678. - `{Object} obj`
  679. - returns `position`
  680. - **_deserialize(valStr)_**
  681. - parameters
  682. - `{String} valStr`
  683. - returns `position`
  684. ## DC.Color
  685. ### example
  686. ```js
  687. let red = DC.Color.RED
  688. ```
  689. ### properties
  690. - `{Color} RED`
  691. - `{Color} YELLOW`
  692. - `{Color} WHITE`
  693. - `{Color} GREEN`
  694. [others](http://resource.dvgis.cn/cesium-docs/Color.html)
  695. ## DC.TilesetStyle
  696. ### example
  697. ```js
  698. let style = new DC.TilesetStyle()
  699. style.color = {
  700. conditions: [
  701. ['${floor} >= 5', 'rgb(198, 106, 11)'],
  702. ['true', 'rgb(127, 59, 8)'],
  703. ],
  704. }
  705. ```
  706. [Cesium3DTileStyle](http://resource.dvgis.cn/cesium-docs/Cesium3DTileStyle.html)
  707. ## DC.JulianDate
  708. ```js
  709. let date = DC.JulianDate.now()
  710. ```
  711. ### static methods
  712. - **_now()_**
  713. - returns `date`
  714. - **_fromDate(date)_**
  715. - parameters
  716. - `{Date} date`
  717. - returns `date`
  718. [JulianDate](http://resource.dvgis.cn/cesium-docs/JulianDate.html)
  719. ## DC.Rect
  720. ### example
  721. ```js
  722. let r = DC.Rect.fromDegrees(10, 20, 12, 31)
  723. ```
  724. [Rectangle](http://resource.dvgis.cn/cesium-docs/Rectangle.html)
  725. ## DC.CallbackProperty
  726. ```js
  727. let position = new DC.Position(120, 20)
  728. let point = new DC.Point(position)
  729. let size = 0
  730. point.setStyle({
  731. pixelSize: new DC.CallbackProperty((time) => {
  732. size += 1
  733. if (size == 10) {
  734. size = 0
  735. }
  736. return size
  737. }),
  738. })
  739. ```
  740. [CallbackProperty](http://resource.dvgis.cn/cesium-docs/CallbackProperty.html)
  741. ## DC.Parse
  742. > Coordinate resolution tool class, can be abbreviated as DC.P
  743. ```js
  744. let position = DC.P.parsePosition('123,32,0')
  745. ```
  746. ### static methods
  747. - **_parsePosition(position)_**
  748. - parameters
  749. - `{String|Array|Position} position`
  750. - returns `position`
  751. - **_parsePositions(positions)_**
  752. - parameters
  753. - `{String|Array} positions`
  754. - returns `array`
  755. - **_parsePointCoordToArray(position)_**
  756. - parameters
  757. - `{String|Position} position`
  758. - returns `array`
  759. - **_parsePolylineCoordToArray(positions)_**
  760. - parameters
  761. - `{String|Array} positions`
  762. - returns `array`
  763. - **_parsePolygonCoordToArray(positions,loop)_**
  764. - parameters
  765. - `{String|Array} positions`
  766. - `{Boolean} loop`
  767. - returns `array`
  768. ## DC.Transform
  769. > Coordinate conversion tool class , can be abbreviated DC.T
  770. ```js
  771. let cartesian3 = DC.T.transformWGS84ToCartesian(new DC.Position(120, 20))
  772. ```
  773. ### static methods
  774. - **_transformCartesianToWGS84(cartesian)_**
  775. - parameters
  776. - `{Cartesian3} cartesian`
  777. - returns `position`
  778. - **_transformWGS84ToCartesian(position)_**
  779. - parameters
  780. - `{Position} position`
  781. - returns `cartesian`
  782. - **_transformWGS84ToCartographic(position)_**
  783. - parameters
  784. - `{Position} position`
  785. - returns `cartographic`
  786. - **_transformCartesianArrayToWGS84Array(cartesianArr)_**
  787. - parameters
  788. - `{Array<cartesian3>} cartesianArr`
  789. - returns `array`
  790. - **_transformWGS84ArrayToCartesianArray(WGS84Arr)_**
  791. - parameters
  792. - `{Array<cartesian3>} WGS84Arr`
  793. - returns `array`
  794. - **_transformWGS84ToMercator(position)_**
  795. - parameters
  796. - `{Position} position`
  797. - returns `position`
  798. - **_transformMercatorToWGS84(position)_**
  799. - parameters
  800. - `{Position} position`
  801. - returns `position`
  802. - **_transformWindowToWGS84(position,viewer)_**
  803. - parameters
  804. - `{Object} position`,format:`{x:1,y:1}`
  805. - `{Viewer} viewer`
  806. - returns `position`
  807. - **_transformWGS84ToWindow(position,viewer)_**
  808. - parameters
  809. - `{Position} position`
  810. - `{Viewer} viewer`
  811. - returns `Object`
  812. ## DC.CoordTransform
  813. > China Coordinate Conversion Tool
  814. ```js
  815. let point = DC.CoordTransform.BD09ToGCJ02(120, 20)
  816. ```
  817. ### static methods
  818. - **_BD09ToGCJ02(lng, lat)_**
  819. - parameters
  820. - `{Number} lng`
  821. - `{Number} lat`
  822. - returns `[]`
  823. - **_GCJ02ToBD09(lng, lat)_**
  824. - parameters
  825. - `{Number} lng`
  826. - `{Number} lat`
  827. - returns `[]`
  828. - **_WGS84ToGCJ02(lng, lat)_**
  829. - parameters
  830. - `{Number} lng`
  831. - `{Number} lat`
  832. - returns `[]`
  833. - **_GCJ02ToWGS84(lng, lat)_**
  834. - parameters
  835. - `{Number} lng`
  836. - `{Number} lat`
  837. - returns `[]`
  838. ## DC.Math
  839. ### static methods
  840. - **_area(positions)_**
  841. - parameters
  842. - `{Array<Position>} positions`
  843. - returns `number`
  844. - **_bounds(positions , expand)_**
  845. - parameters
  846. - `{Array<Position>} positions`
  847. - `{Number}} expand`:0~1
  848. - returns `object`
  849. - **_mid(startPosition , endPosition)_**
  850. - parameters
  851. - `{Position} startPosition`
  852. - `{Position} endPosition`
  853. - returns `position`
  854. - **_center(positions)_**
  855. - parameters
  856. - `{Array<Position>} positions`
  857. - returns `position`
  858. - **_distance(positions)_**
  859. - parameters
  860. - `{Array<Position>} positions`
  861. - returns `number`
  862. - **_heading(startPosition, endPosition)_**
  863. - parameters
  864. - `{Position} startPosition`
  865. - `{Position} endPosition`
  866. - returns `number`
  867. - **_parabola(startPosition, endPosition,height,count)_**
  868. - parameters
  869. - `{Position} startPosition`
  870. - `{Position} endPosition`
  871. - `{Number} height`
  872. - `{Number} count`
  873. - returns `Array`
  874. > [more](http://resource.dvgis.cn/cesium-docs/Math.html)
  875. ## DC.Util
  876. ### static methods
  877. - **_uuid([prefix])_**
  878. - parameters
  879. - `{String} prefix`
  880. - returns `string`
  881. - **_merge(dest, ...sources)_**
  882. - parameters
  883. - `{Object} dest`
  884. - `{Object|Array} sources`
  885. - returns `object`
  886. - **_emptyImageUrl()_**
  887. - **_debounce(fn,delay)_**
  888. - **_throttle(fn,delay)_**
  889. ## DC.DomUtil
  890. ### static methods
  891. - **_get(id)_**
  892. - parameters
  893. - `{String} id`
  894. - returns `Element`
  895. - **_create(tagName, className, [container])_**
  896. - parameters
  897. - `{String} tagName`
  898. - `{String} className`
  899. - `{Element} [container]`
  900. - returns `Element`
  901. - **_addClass(el, name)_**
  902. - parameters
  903. - `{Element} el`
  904. - `{String} className`
  905. - **_removeClass(el, name)_**
  906. - parameters
  907. - `{Element} el`
  908. - `{String} className`
  909. - **_addClass(el, name)_**
  910. - parameters
  911. - `{Element} el`
  912. - `{String} className`
  913. - **_createSvg(width, height, path, [container])_**
  914. - parameters
  915. - `{Number} width`
  916. - `{Number} height`
  917. - `{String} path`
  918. - `{Element} [container]`
  919. - returns `svg`
  920. - **_parseDom(domStr, [withWrapper], [className])_**
  921. - parameters
  922. - `{String} domStr`
  923. - `{Boolean} withWrapper`
  924. - `{String} className`
  925. - returns `Element | Nodes`
  926. - **_enterFullscreen(el)_**
  927. - parameters
  928. - `{Element} el`
  929. - **_exitFullscreen()_**
  930. - **_createVideo(url, className, [container])_**
  931. - parameters
  932. - `{String} url`
  933. - `{String} className`
  934. - `{Element} [container]`
  935. - returns `Element | Nodes`