您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

2 年前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  1. ---
  2. sidebar: auto
  3. ---
  4. # Layers 🌎
  5. Categorize overlay elements with the same business logic or attributes for the same management
  6. ## Layer
  7. > The base class of the layer, its subclasses are instantiated and need to be added to the 3D scene in order to display all kinds of 3D data
  8. :::warning
  9. This basic class cannot be instantiated
  10. :::
  11. ### properties
  12. - `{String} id` **_`readonly`_**
  13. - `{Boolean} show`
  14. - `{Object} attr`:Business Properties
  15. - `{String} state` **_`readonly`_**
  16. - `{String} type` **_`readonly`_**
  17. ### methods
  18. - **_addOverlay(overlay)_**
  19. - parameters
  20. - `{Overlay} overlay`
  21. - returns `this`
  22. - **_addOverlays(overlays)_**
  23. - parameters
  24. - `{Array<Overlay>} overlays`
  25. - returns `this`
  26. - **_removeOverlay(overlay)_**
  27. - parameters
  28. - `{Overlay} overlay`
  29. - returns `this`
  30. - **_getOverlay(overlayId)_**
  31. - parameters
  32. - `{String} overlayId`
  33. - returns `overlay`
  34. - **_getOverlayById(Id)_**
  35. - parameters
  36. - `{String} Id`
  37. - returns `overlay`
  38. - **_getOverlaysByAttr(attrName, attrVal)_**
  39. - parameters
  40. - `{String} attrName`
  41. - `{Object} attrVal`
  42. - returns `array`
  43. ```js
  44. overlay.attr.name = 'test'
  45. let arr = layer.getOverlaysByAttr('name', 'test')
  46. ```
  47. - **_getOverlays()_**
  48. - returns `array`
  49. - **_eachOverlay(method, context)_**
  50. - parameters
  51. - `{Function} method`:Callback function with parameters for overlay
  52. - `{Object} context`
  53. - returns `this`
  54. ```js
  55. layer.eachOverlay((item) => {})
  56. ```
  57. - **_clear()_**
  58. - returns `this`
  59. - **_remove()_**
  60. - returns `this`
  61. - **_addTo(viewer)_**
  62. - parameters
  63. - `{Viewer|World} viewer`:场景
  64. - returns `this`
  65. - **_on(type, callback, context)_**
  66. Event Subscription
  67. - parameters
  68. - `{Object} type`
  69. - `{Function} callback`
  70. - `{Object} context`
  71. - returns `this`
  72. - **_off(type, callback, context)_**
  73. Event Unsubscribe
  74. - parameters
  75. - `{Object} type`
  76. - `{Function} callback`
  77. - `{Object} context`
  78. - returns `this`
  79. - **_fire(type,params)_**
  80. - parameters
  81. - `{Object} type`
  82. - `{Object} params`
  83. - returns `this`
  84. ### static methods
  85. - **_registerType(type)_**
  86. - parameters
  87. - `{String} type`
  88. - **_getLayerType()_**
  89. - returns `string`
  90. ## DC.LayerGroup
  91. > Layer groups, grouping layers according to a certain logic to facilitate unified management
  92. ### example
  93. ```js
  94. let layerGroup = new DC.LayerGroup('id')
  95. viewer.addLayerGroup(layerGroup)
  96. let layer = new DC.VectorLayer('layer')
  97. layerGroup.addLayer(layer)
  98. ```
  99. ### creation
  100. - **_constructor(id)_**
  101. - parameters
  102. - `{String} id`
  103. - returns `layerGroup`
  104. ### properties
  105. - `{String} id` **_`readonly`_**
  106. - `{Boolean} show`
  107. - `{String} type` **_`readonly`_**
  108. ### methods
  109. - **_addLayer(layer)_**
  110. - parameters
  111. - `{Layer} layer`
  112. - returns `this`
  113. - **_removeLayer(layer)_**
  114. - parameters
  115. - `{Layer} layer`
  116. - returns `this`
  117. - **_getLayer(id)_**
  118. - parameters
  119. - `{String} id`
  120. - returns `layer`
  121. - **_getLayers()_**
  122. - returns `layer`
  123. - **_remove()_**
  124. - returns `this`
  125. - **_addTo(viewer)_**
  126. - parameters
  127. - `{Viewer|World} viewer`:场景
  128. - returns `this`
  129. ## DC.VectorLayer
  130. > Vector layer, used to add all kinds of vector data (points, lines, surfaces, etc.), grouping vector data according to a certain logic to facilitate unified management, inherited from [Layer](#layer)
  131. ### example
  132. ```js
  133. let layer = new DC.VectorLayer('id')
  134. viewer.addLayer(layer)
  135. ```
  136. ### creation
  137. - **_constructor(id)_**
  138. - parameters
  139. - `{String} id`
  140. - returns `vectorLayer`
  141. ## DC.DynamicLayer
  142. > Dynamic layer, used to add all kinds of dynamic data (billboard、model etc.), grouping vector data according to a certain logic to facilitate unified management, inherited from [Layer](#layer)
  143. ### example
  144. ```js
  145. let layer = new DC.DynamicLayer('id')
  146. viewer.addLayer(layer)
  147. ```
  148. ### creation
  149. - **_constructor(id)_**
  150. - parameters
  151. - `{String} id`
  152. - returns `vectorLayer`
  153. ## DC.PrimitiveLayer
  154. > The primitive layer, which is used to add all kinds of primitive data, group the primitive data in a certain logic to facilitate unified management, inherited from [Layer](#layer)
  155. ### example
  156. ```js
  157. let layer = new DC.PrimitiveLayer('id')
  158. viewer.addLayer(layer)
  159. ```
  160. ### creation
  161. - **_constructor(id)_**
  162. - parameters
  163. - `{String} id`
  164. - returns `primitiveLayer`
  165. ## DC.GroundPrimitiveLayer
  166. > The ground primitive layer, which is used to add all kinds of ground primitive data, group the ground primitive data in a certain logic to facilitate unified management, inherited from [Layer](#layer)
  167. ### example
  168. ```js
  169. let layer = new DC.GroundPrimitiveLayer('id')
  170. viewer.addLayer(layer)
  171. ```
  172. ### creation
  173. - **_constructor(id)_**
  174. - parameters
  175. - `{String} id`
  176. - returns `groundPrimitiveLayer`
  177. ## DC.TilesetLayer
  178. > 3dTiles layer, used to add 3dTiles model data, inherits from[Layer](#layer)
  179. ### example
  180. ```js
  181. let layer = new DC.TilesetLayer('id')
  182. viewer.addLayer(layer)
  183. ```
  184. ### creation
  185. - **_constructor(id)_**
  186. - parameters
  187. - `{String} id`
  188. - returns `tilesetLayer`
  189. ## DC.GeoJsonLayer
  190. > GeoJson layer, used to load GeoJson data, inherited from [Layer](#layer),
  191. ### example
  192. ```js
  193. let layer = new DC.GeoJsonLayer('id', '**/**.geojson')
  194. layer.eachOverlay((item) => {
  195. // item is an entity,
  196. if (item.polyline) {
  197. //todo
  198. let polyline = DC.Polyline.fromEntity(item)
  199. }
  200. if (item.polygon) {
  201. //todo
  202. let polygon = DC.Polygon.fromEntity(item)
  203. }
  204. if (item.billboard) {
  205. //todo
  206. let point = DC.Point.fromEntity(item)
  207. let divIcon = DC.DivIcon.fromEntity(item)
  208. let billboard = DC.Billboard.fromEntity(item)
  209. }
  210. })
  211. ```
  212. ### creation
  213. - **_constructor(id,url,[options])_**
  214. - parameters
  215. - `{String} id`
  216. - `{String} url`
  217. - `{Object} options` [GeoJsonDataSource](http://resource.dvgis.cn/cesium-docs/GeoJsonDataSource.html)
  218. - returns `geoJsonLayer`
  219. ### methods
  220. - **_toVectorLayer()_**
  221. - returns `vectorLayer`
  222. - **_toModelLayer(modelUrl)_**
  223. - parameters
  224. - `{String} modelUrl`
  225. - returns `vectorLayer`
  226. ## DC.TopoJsonLayer
  227. > TopoJson layer, used to load TopoJson data, inherited from [Layer](#layer),
  228. ### example
  229. ```js
  230. let layer = new DC.GeoJsonLayer('id', '**/**.geojson')
  231. layer.eachOverlay((item) => {
  232. // item is an entity,
  233. if (item.polyline) {
  234. //todo
  235. let polyline = DC.Polyline.fromEntity(item)
  236. }
  237. if (item.polygon) {
  238. //todo
  239. let polygon = DC.Polygon.fromEntity(item)
  240. }
  241. if (item.billboard) {
  242. //todo
  243. let point = DC.Point.fromEntity(item)
  244. let divIcon = DC.DivIcon.fromEntity(item)
  245. let billboard = DC.Billboard.fromEntity(item)
  246. }
  247. })
  248. ```
  249. ### creation
  250. - **_constructor(id,url,[options])_**
  251. - parameters
  252. - `{String} id`
  253. - `{String} url`
  254. - `{Object} options` [GeoJsonDataSource](http://resource.dvgis.cn/cesium-docs/GeoJsonDataSource.html)
  255. - returns `topoJsonLayer`
  256. ### methods
  257. - **_toVectorLayer()_**
  258. - returns `vectorLayer`
  259. - **_toModelLayer(modelUrl)_**
  260. - parameters
  261. - `{String} modelUrl`
  262. - returns `vectorLayer`
  263. ## DC.HtmlLayer
  264. > Html layer for loading DivIcon nodes, inherited from [Layer](#layer),
  265. ### example
  266. ```js
  267. let layer = new DC.HtmlLayer('dom')
  268. viewer.addLayer(layer)
  269. ```
  270. ### creation
  271. - **_constructor(id)_**
  272. DC.HtmlLayer 构造函数
  273. - parameters
  274. - `{String} id`:图层唯一标识
  275. - returns `htmlLayer`
  276. ## DC.CzmlLayer
  277. > Czml layer for loading Czml data, inherited from [Layer](#layer)
  278. ### example
  279. ```js
  280. let layer = new DC.CzmlLayer('id', '**/**.czml')
  281. layer.eachOverlay((item) => {
  282. if (item.polyline) {
  283. //todo
  284. }
  285. if (item.polygon) {
  286. //todo
  287. }
  288. if (item.billboard) {
  289. //todo
  290. }
  291. })
  292. ```
  293. ### creation
  294. - **_constructor(id,url,[options])_**
  295. - parameters
  296. - `{String} id`
  297. - `{String} url`
  298. - `{Object} options` [CzmlDataSource](http://resource.dvgis.cn/cesium-docs/CzmlDataSource.html)
  299. - returns `czmlLayer`
  300. ## DC.KmlLayer
  301. > Kml layer for loading Kml data, inherited from [Layer](#layer)
  302. ### example
  303. ```js
  304. let layer = new DC.KmlLayer('id', '**/**.kml')
  305. layer.eachOverlay((item) => {
  306. if (item.polyline) {
  307. //todo
  308. }
  309. if (item.polygon) {
  310. //todo
  311. }
  312. if (item.billboard) {
  313. //todo
  314. }
  315. })
  316. ```
  317. ### creation
  318. - **_constructor(id,url,[options])_**
  319. - parameters
  320. - `{String} id`
  321. - `{String} url`
  322. - `{Object} options` [KmlDataSource](http://resource.dvgis.cn/cesium-docs/KmlDataSource.html)
  323. - returns `kmlLayer`
  324. ## DC.GpxLayer
  325. > Gpx layer for loading gpx data, inherited from [Layer](#layer)
  326. ### example
  327. ```js
  328. let layer = new DC.GpxLayer('id', '**/**.gpx')
  329. ```
  330. ### creation
  331. - **_constructor(id,url,[options])_**
  332. - parameters
  333. - `{String} id`
  334. - `{String} url`
  335. - `{Object} options` [GpxDataSource](http://resource.dvgis.cn/cesium-docs/GpxDataSource.html)
  336. - returns `gpxLayer`
  337. ## DC.ClusterLayer
  338. > Inherited from [Layer](#layer)
  339. ### example
  340. ```js
  341. let layer = new DC.ClusterLayer('id')
  342. viewer.addLayer(layer)
  343. ```
  344. ### creation
  345. - **_constructor(id,[options])_**
  346. - parameters
  347. - `{String} id`
  348. - `{Object} options`
  349. - returns `clusterLayer`
  350. ```json
  351. {
  352. "size": 48,
  353. "pixelRange": 40,
  354. "gradient": {
  355. "0.0001": DC.Color.DEEPSKYBLUE,
  356. "0.001": DC.Color.GREEN,
  357. "0.01": DC.Color.ORANGE,
  358. "0.1": DC.Color.RED
  359. },
  360. "style": "circle", // circle or clustering
  361. "fontSize": 12,
  362. "fontColor": DC.Color.BLACK
  363. }
  364. ```
  365. ## DC.HeatLayer
  366. > Inherited from [Layer](#layer)
  367. ### example
  368. ```js
  369. let layer = new DC.HeatLayer('id')
  370. viewer.addLayer(layer)
  371. ```
  372. ### creation
  373. - **_constructor(id,[options])_**
  374. - parameters
  375. - `{String} id`
  376. - `{Object} options`
  377. - returns `heatLayer`
  378. ```json
  379. //options(optional)
  380. {
  381. "gradient": {
  382. "0.5": "green",
  383. "0.6": "orange",
  384. "0.95": "red"
  385. },
  386. "height": 0,
  387. "radius": 30,
  388. "useGround": false,
  389. "classificationType": 2 // only use for "useGround" is true
  390. }
  391. ```
  392. ### methods
  393. - **_setPositions(positions)_**
  394. - parameters
  395. - `{Array<Object>} positions`
  396. - returns `heatLayer`
  397. ```json
  398. {
  399. "lng": "",
  400. "lat": "",
  401. "value": 1
  402. }
  403. ```
  404. - **_addPosition(position)_**
  405. - parameters
  406. - `{Object} position`
  407. - returns `heatLayer`
  408. ```json
  409. {
  410. "lng": "",
  411. "lat": "",
  412. "value": 1
  413. }
  414. ```
  415. ## DC.WindLayer
  416. > Inherited from [Layer](#layer)
  417. ### example
  418. ```js
  419. let layer = new DC.WindLayer('id')
  420. viewer.addLayer(layer)
  421. ```
  422. ### creation
  423. - **_constructor(id,[options])_**
  424. - parameters
  425. - `{String} id`
  426. - `{Object} options`
  427. - returns `windLayer`
  428. ```json
  429. //options(optional)
  430. {
  431. "globalAlpha": 0.9,
  432. "lineWidth": 1,
  433. "colorScale": "#fff",
  434. "velocityScale": 1 / 25,
  435. "maxAge": 90,
  436. "paths": 800,
  437. "frameRate": 20,
  438. "useCoordsDraw": true,
  439. "gpet": true
  440. }
  441. ```
  442. ### methods
  443. - **_setData(data,[options])_**
  444. - parameters
  445. - `{Object} data`
  446. - `{Object} options`
  447. - returns `windLayer`
  448. - **_setOptions(options)_**
  449. - parameters
  450. - `{Object} options`
  451. - returns `windLayer`
  452. ## DC.S3MLayer
  453. > SInherited from [Layer](#layer)
  454. ### example
  455. ```js
  456. let layer = new DC.S3MLayer('id','**.scp')
  457. viewer.addLayer(layer)
  458. ```
  459. ### creation
  460. - **_constructor(id,url,[options])_**
  461. - parameters
  462. - `{String} id`
  463. - `{String} url`
  464. - `{Object} options`
  465. - returns `windLayer`
  466. ```json
  467. //options(optional)
  468. {
  469. "maxVisibleDistance":Number.MAX_VALUE,
  470. "minVisibleDistance":0,
  471. }
  472. ```