|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671 |
- ---
- sidebar: auto
- ---
-
- # Layers 🌎
-
- Categorize overlay elements with the same business logic or attributes for the same management
-
- ## Layer
-
- > 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
-
- :::warning
- This basic class cannot be instantiated
- :::
-
- ### properties
-
- - `{String} id` **_`readonly`_**
- - `{Boolean} show`
- - `{Object} attr`:Business Properties
- - `{String} state` **_`readonly`_**
- - `{String} type` **_`readonly`_**
-
- ### methods
-
- - **_addOverlay(overlay)_**
-
- - parameters
- - `{Overlay} overlay`
- - returns `this`
-
- - **_addOverlays(overlays)_**
-
- - parameters
- - `{Array<Overlay>} overlays`
- - returns `this`
-
- - **_removeOverlay(overlay)_**
-
- - parameters
- - `{Overlay} overlay`
- - returns `this`
-
- - **_getOverlay(overlayId)_**
-
- - parameters
- - `{String} overlayId`
- - returns `overlay`
-
- - **_getOverlayById(Id)_**
-
- - parameters
- - `{String} Id`
- - returns `overlay`
-
- - **_getOverlaysByAttr(attrName, attrVal)_**
-
- - parameters
- - `{String} attrName`
- - `{Object} attrVal`
- - returns `array`
-
- ```js
- overlay.attr.name = 'test'
- let arr = layer.getOverlaysByAttr('name', 'test')
- ```
-
- - **_getOverlays()_**
-
- - returns `array`
-
- - **_eachOverlay(method, context)_**
-
- - parameters
- - `{Function} method`:Callback function with parameters for overlay
- - `{Object} context`
- - returns `this`
-
- ```js
- layer.eachOverlay((item) => {})
- ```
-
- - **_clear()_**
-
- - returns `this`
-
- - **_remove()_**
-
- - returns `this`
-
- - **_addTo(viewer)_**
-
- - parameters
- - `{Viewer|World} viewer`:场景
- - returns `this`
-
- - **_on(type, callback, context)_**
-
- Event Subscription
-
- - parameters
- - `{Object} type`
- - `{Function} callback`
- - `{Object} context`
- - returns `this`
-
- - **_off(type, callback, context)_**
-
- Event Unsubscribe
-
- - parameters
- - `{Object} type`
- - `{Function} callback`
- - `{Object} context`
- - returns `this`
-
- - **_fire(type,params)_**
-
- - parameters
- - `{Object} type`
- - `{Object} params`
- - returns `this`
-
- ### static methods
-
- - **_registerType(type)_**
-
- - parameters
- - `{String} type`
-
- - **_getLayerType()_**
-
- - returns `string`
-
- ## DC.LayerGroup
-
- > Layer groups, grouping layers according to a certain logic to facilitate unified management
-
- ### example
-
- ```js
- let layerGroup = new DC.LayerGroup('id')
- viewer.addLayerGroup(layerGroup)
- let layer = new DC.VectorLayer('layer')
- layerGroup.addLayer(layer)
- ```
-
- ### creation
-
- - **_constructor(id)_**
-
- - parameters
- - `{String} id`
- - returns `layerGroup`
-
- ### properties
-
- - `{String} id` **_`readonly`_**
- - `{Boolean} show`
- - `{String} type` **_`readonly`_**
-
- ### methods
-
- - **_addLayer(layer)_**
-
- - parameters
- - `{Layer} layer`
- - returns `this`
-
- - **_removeLayer(layer)_**
-
- - parameters
- - `{Layer} layer`
- - returns `this`
-
- - **_getLayer(id)_**
-
- - parameters
- - `{String} id`
- - returns `layer`
-
- - **_getLayers()_**
-
- - returns `layer`
-
- - **_remove()_**
-
- - returns `this`
-
- - **_addTo(viewer)_**
-
- - parameters
- - `{Viewer|World} viewer`:场景
- - returns `this`
-
- ## DC.VectorLayer
-
- > 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)
-
- ### example
-
- ```js
- let layer = new DC.VectorLayer('id')
- viewer.addLayer(layer)
- ```
-
- ### creation
-
- - **_constructor(id)_**
-
- - parameters
- - `{String} id`
- - returns `vectorLayer`
-
- ## DC.DynamicLayer
-
- > 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)
-
- ### example
-
- ```js
- let layer = new DC.DynamicLayer('id')
- viewer.addLayer(layer)
- ```
-
- ### creation
-
- - **_constructor(id)_**
-
- - parameters
- - `{String} id`
- - returns `vectorLayer`
-
- ## DC.PrimitiveLayer
-
- > 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)
-
- ### example
-
- ```js
- let layer = new DC.PrimitiveLayer('id')
- viewer.addLayer(layer)
- ```
-
- ### creation
-
- - **_constructor(id)_**
-
- - parameters
- - `{String} id`
- - returns `primitiveLayer`
-
- ## DC.GroundPrimitiveLayer
-
- > 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)
-
- ### example
-
- ```js
- let layer = new DC.GroundPrimitiveLayer('id')
- viewer.addLayer(layer)
- ```
-
- ### creation
-
- - **_constructor(id)_**
-
- - parameters
- - `{String} id`
- - returns `groundPrimitiveLayer`
-
- ## DC.TilesetLayer
-
- > 3dTiles layer, used to add 3dTiles model data, inherits from[Layer](#layer)
-
- ### example
-
- ```js
- let layer = new DC.TilesetLayer('id')
- viewer.addLayer(layer)
- ```
-
- ### creation
-
- - **_constructor(id)_**
-
- - parameters
- - `{String} id`
- - returns `tilesetLayer`
-
- ## DC.GeoJsonLayer
-
- > GeoJson layer, used to load GeoJson data, inherited from [Layer](#layer),
-
- ### example
-
- ```js
- let layer = new DC.GeoJsonLayer('id', '**/**.geojson')
- layer.eachOverlay((item) => {
- // item is an entity,
- if (item.polyline) {
- //todo
- let polyline = DC.Polyline.fromEntity(item)
- }
- if (item.polygon) {
- //todo
- let polygon = DC.Polygon.fromEntity(item)
- }
- if (item.billboard) {
- //todo
- let point = DC.Point.fromEntity(item)
- let divIcon = DC.DivIcon.fromEntity(item)
- let billboard = DC.Billboard.fromEntity(item)
- }
- })
- ```
-
- ### creation
-
- - **_constructor(id,url,[options])_**
-
- - parameters
- - `{String} id`
- - `{String} url`
- - `{Object} options` [GeoJsonDataSource](http://resource.dvgis.cn/cesium-docs/GeoJsonDataSource.html)
- - returns `geoJsonLayer`
-
- ### methods
-
- - **_toVectorLayer()_**
-
- - returns `vectorLayer`
-
- - **_toModelLayer(modelUrl)_**
-
- - parameters
- - `{String} modelUrl`
- - returns `vectorLayer`
-
- ## DC.TopoJsonLayer
-
- > TopoJson layer, used to load TopoJson data, inherited from [Layer](#layer),
-
- ### example
-
- ```js
- let layer = new DC.GeoJsonLayer('id', '**/**.geojson')
- layer.eachOverlay((item) => {
- // item is an entity,
- if (item.polyline) {
- //todo
- let polyline = DC.Polyline.fromEntity(item)
- }
- if (item.polygon) {
- //todo
- let polygon = DC.Polygon.fromEntity(item)
- }
- if (item.billboard) {
- //todo
- let point = DC.Point.fromEntity(item)
- let divIcon = DC.DivIcon.fromEntity(item)
- let billboard = DC.Billboard.fromEntity(item)
- }
- })
- ```
-
- ### creation
-
- - **_constructor(id,url,[options])_**
-
- - parameters
- - `{String} id`
- - `{String} url`
- - `{Object} options` [GeoJsonDataSource](http://resource.dvgis.cn/cesium-docs/GeoJsonDataSource.html)
- - returns `topoJsonLayer`
-
- ### methods
-
- - **_toVectorLayer()_**
-
- - returns `vectorLayer`
-
- - **_toModelLayer(modelUrl)_**
-
- - parameters
- - `{String} modelUrl`
- - returns `vectorLayer`
-
- ## DC.HtmlLayer
-
- > Html layer for loading DivIcon nodes, inherited from [Layer](#layer),
-
- ### example
-
- ```js
- let layer = new DC.HtmlLayer('dom')
- viewer.addLayer(layer)
- ```
-
- ### creation
-
- - **_constructor(id)_**
-
- DC.HtmlLayer 构造函数
-
- - parameters
- - `{String} id`:图层唯一标识
- - returns `htmlLayer`
-
- ## DC.CzmlLayer
-
- > Czml layer for loading Czml data, inherited from [Layer](#layer)
-
- ### example
-
- ```js
- let layer = new DC.CzmlLayer('id', '**/**.czml')
- layer.eachOverlay((item) => {
- if (item.polyline) {
- //todo
- }
- if (item.polygon) {
- //todo
- }
- if (item.billboard) {
- //todo
- }
- })
- ```
-
- ### creation
-
- - **_constructor(id,url,[options])_**
-
- - parameters
- - `{String} id`
- - `{String} url`
- - `{Object} options` [CzmlDataSource](http://resource.dvgis.cn/cesium-docs/CzmlDataSource.html)
- - returns `czmlLayer`
-
- ## DC.KmlLayer
-
- > Kml layer for loading Kml data, inherited from [Layer](#layer)
-
- ### example
-
- ```js
- let layer = new DC.KmlLayer('id', '**/**.kml')
- layer.eachOverlay((item) => {
- if (item.polyline) {
- //todo
- }
- if (item.polygon) {
- //todo
- }
- if (item.billboard) {
- //todo
- }
- })
- ```
-
- ### creation
-
- - **_constructor(id,url,[options])_**
-
- - parameters
- - `{String} id`
- - `{String} url`
- - `{Object} options` [KmlDataSource](http://resource.dvgis.cn/cesium-docs/KmlDataSource.html)
- - returns `kmlLayer`
-
- ## DC.GpxLayer
-
- > Gpx layer for loading gpx data, inherited from [Layer](#layer)
-
- ### example
-
- ```js
- let layer = new DC.GpxLayer('id', '**/**.gpx')
- ```
-
- ### creation
-
- - **_constructor(id,url,[options])_**
-
- - parameters
- - `{String} id`
- - `{String} url`
- - `{Object} options` [GpxDataSource](http://resource.dvgis.cn/cesium-docs/GpxDataSource.html)
- - returns `gpxLayer`
-
- ## DC.ClusterLayer
-
- > Inherited from [Layer](#layer)
-
- ### example
-
- ```js
- let layer = new DC.ClusterLayer('id')
- viewer.addLayer(layer)
- ```
-
- ### creation
-
- - **_constructor(id,[options])_**
-
- - parameters
- - `{String} id`
- - `{Object} options`
- - returns `clusterLayer`
-
- ```json
- {
- "size": 48,
- "pixelRange": 40,
- "gradient": {
- "0.0001": DC.Color.DEEPSKYBLUE,
- "0.001": DC.Color.GREEN,
- "0.01": DC.Color.ORANGE,
- "0.1": DC.Color.RED
- },
- "style": "circle", // circle or clustering
- "fontSize": 12,
- "fontColor": DC.Color.BLACK
- }
- ```
-
- ## DC.HeatLayer
-
- > Inherited from [Layer](#layer)
-
- ### example
-
- ```js
- let layer = new DC.HeatLayer('id')
- viewer.addLayer(layer)
- ```
-
- ### creation
-
- - **_constructor(id,[options])_**
-
- - parameters
- - `{String} id`
- - `{Object} options`
- - returns `heatLayer`
-
- ```json
- //options(optional)
- {
- "gradient": {
- "0.5": "green",
- "0.6": "orange",
- "0.95": "red"
- },
- "height": 0,
- "radius": 30,
- "useGround": false,
- "classificationType": 2 // only use for "useGround" is true
- }
- ```
-
- ### methods
-
- - **_setPositions(positions)_**
-
- - parameters
- - `{Array<Object>} positions`
- - returns `heatLayer`
-
- ```json
- {
- "lng": "",
- "lat": "",
- "value": 1
- }
- ```
-
- - **_addPosition(position)_**
-
- - parameters
- - `{Object} position`
- - returns `heatLayer`
-
- ```json
- {
- "lng": "",
- "lat": "",
- "value": 1
- }
- ```
-
- ## DC.WindLayer
-
- > Inherited from [Layer](#layer)
-
- ### example
-
- ```js
- let layer = new DC.WindLayer('id')
- viewer.addLayer(layer)
- ```
-
- ### creation
-
- - **_constructor(id,[options])_**
-
- - parameters
- - `{String} id`
- - `{Object} options`
- - returns `windLayer`
-
- ```json
- //options(optional)
- {
- "globalAlpha": 0.9,
- "lineWidth": 1,
- "colorScale": "#fff",
- "velocityScale": 1 / 25,
- "maxAge": 90,
- "paths": 800,
- "frameRate": 20,
- "useCoordsDraw": true,
- "gpet": true
- }
- ```
-
- ### methods
-
- - **_setData(data,[options])_**
-
- - parameters
- - `{Object} data`
- - `{Object} options`
- - returns `windLayer`
-
- - **_setOptions(options)_**
-
- - parameters
- - `{Object} options`
- - returns `windLayer`
-
- ## DC.S3MLayer
-
- > SInherited from [Layer](#layer)
-
- ### example
-
- ```js
- let layer = new DC.S3MLayer('id','**.scp')
- viewer.addLayer(layer)
- ```
-
- ### creation
-
- - **_constructor(id,url,[options])_**
-
- - parameters
- - `{String} id`
- - `{String} url`
- - `{Object} options`
- - returns `windLayer`
-
- ```json
- //options(optional)
- {
- "maxVisibleDistance":Number.MAX_VALUE,
- "minVisibleDistance":0,
- }
- ```
|