Appearance
TdtLayer (Tianditu Tile Layer)
Create and manage Tianditu tile layers for map display.
Constructor
ts
new ge3d.object.TdtLayer(options?: TdtLayerOptions): TdtLayerParameters (TdtLayerOptions)
| Parameter | Type | Default | Description |
|---|---|---|---|
| id | String | - | Layer unique identifier |
| name | String | - | Layer display name |
| type | String | "tdt" | Layer type (fixed as "tdt") |
| layer | String | "vec_d" | Tianditu layer type (see Layer Types below) |
| show | Boolean | true | Whether to show the layer |
| key | String | String[] | defaultTokenArr | Tianditu API key(s) |
| crs | String | "EPSG:3857" | Coordinate reference system |
| rectangle | Cesium.Rectangle | Object | - | Layer coverage area |
| bbox | Number[] | - | Bounding box [xmin, ymin, xmax, ymax] |
| opacity | Number | 1.0 | Layer opacity (0.0-1.0) |
| alpha | Number | 1.0 | Layer alpha (same as opacity) |
| brightness | Number | 1.0 | Layer brightness (0.0-1.0) |
| contrast | Number | 1.0 | Layer contrast (0.0-1.0) |
| hue | Number | 0.0 | Layer hue adjustment |
| saturation | Number | 1.0 | Layer saturation (0.0-1.0) |
| gamma | Number | 1.0 | Layer gamma correction |
| zIndex | Number | - | Layer z-index for ordering |
| theme | Object | - | Theme configuration (see Theme Options) |
| highlight | Object | - | Highlight configuration |
| flyTo | Boolean | false | Whether to fly to layer after loading |
| fitTileset | Boolean | false | Whether to fit to tileset |
| proxy | String | - | Proxy URL for requests |
| headers | Object | - | HTTP headers for requests |
| queryParameters | Object | - | Query parameters for requests |
Layer Types
| Value | Description | Max Level |
|---|---|---|
| "vec_d" | Vector map (day) | 18 |
| "vec_z" | Vector annotation (day) | 18 |
| "img_d" | Satellite imagery (day) | 18 |
| "img_z" | Satellite annotation (day) | 18 |
| "ter_d" | Terrain (day) | 14 |
| "ter_z" | Terrain annotation (day) | 14 |
Theme Options
| Parameter | Type | Default | Description |
|---|---|---|---|
| bgColor | String | - | Background color |
| alpha | Number | 1.0 | Theme transparency |
| invert | Boolean | false | Whether to invert colors |
Properties
| Property | Type | Description |
|---|---|---|
| layer | Cesium.ImageryLayer | Internal Cesium ImageryLayer object |
| imageryProvider | Cesium.ImageryProvider | Internal Cesium ImageryProvider object |
| rectangle | Cesium.Rectangle | Layer coverage area |
| alpha | Number | Layer opacity (0.0-1.0) |
| brightness | Number | Layer brightness |
| contrast | Number | Layer contrast |
| hue | Number | Layer hue |
| saturation | Number | Layer saturation |
| gamma | Number | Layer gamma |
| zIndex | Number | Layer z-index |
| hasZIndex | Boolean | Whether layer supports z-index ordering |
Methods
| Method | Parameters | Return Value | Description |
|---|---|---|---|
| reload | () | void | Reload the layer |
| setOpacity | (value: number) | void | Set layer opacity |
| flyTo | (options?: object) | void | Fly to layer extent |
| bindHighlight | (options: object) | void | Bind highlight functionality |
| unbindHighlight | () | void | Unbind highlight functionality |
| openHighlight | (highlightStyle?: object) | void | Open highlight |
| closeHighlight | () | void | Close highlight |
Usage Examples
Basic Usage
javascript
// Create basic Tianditu imagery layer
const imageryLayer = new ge3d.object.TdtLayer({
id: 'tdtImagery',
name: 'Tianditu Imagery',
layer: 'img_d',
show: true
});
// Add to map
core.addObject(imageryLayer);Vector Layer with Theme
javascript
// Create vector layer with theme
const vectorLayer = new ge3d.object.TdtLayer({
id: 'tdtVector',
name: 'Tianditu Vector',
layer: 'vec_d',
show: true,
theme: {
bgColor: '#009ACD',
alpha: 0.3,
invert: true
},
contrast: 3,
brightness: 1.0
});
core.addObject(vectorLayer);Annotation Layer
javascript
// Create annotation layer
const annotationLayer = new ge3d.object.TdtLayer({
id: 'tdtAnnotation',
name: 'Tianditu Annotation',
layer: 'img_z',
show: true,
opacity: 0.8
});
core.addObject(annotationLayer);Terrain Layer
javascript
// Create terrain layer
const terrainLayer = new ge3d.object.TdtLayer({
id: 'tdtTerrain',
name: 'Tianditu Terrain',
layer: 'ter_d',
show: true,
flyTo: true
});
core.addObject(terrainLayer);Layer with Custom Configuration
javascript
// Create layer with custom settings
const customLayer = new ge3d.object.TdtLayer({
id: 'tdtCustom',
name: 'Custom Tianditu Layer',
layer: 'vec_d',
show: true,
key: 'your-api-key',
crs: 'EPSG:4326',
rectangle: {
xmin: 116.0,
ymin: 39.0,
xmax: 117.0,
ymax: 40.0
},
opacity: 0.7,
brightness: 1.2,
contrast: 1.1,
zIndex: 10,
proxy: 'https://your-proxy.com/',
headers: {
'Authorization': 'Bearer your-token'
}
});
core.addObject(customLayer);Layer with Highlight
javascript
// Create layer with highlight functionality
const highlightLayer = new ge3d.object.TdtLayer({
id: 'tdtHighlight',
name: 'Tianditu with Highlight',
layer: 'vec_d',
show: true,
highlight: {
color: '#ff0000',
width: 2
}
});
core.addObject(highlightLayer);
// Listen to click events
highlightLayer.addEventListener(ge3d.EventType.click, (event) => {
console.log('Layer clicked:', event);
});Layer Management
javascript
// Control layer visibility
imageryLayer.show = false; // Hide layer
imageryLayer.show = true; // Show layer
// Adjust layer properties
imageryLayer.opacity = 0.5;
imageryLayer.brightness = 1.2;
imageryLayer.contrast = 1.1;
// Layer ordering
imageryLayer.zIndex = 5;
vectorLayer.zIndex = 10; // This will be on top
// Fly to layer
imageryLayer.flyTo({
duration: 2.0,
maximumHeight: 10000
});Notes
- TdtLayer extends BaseTileLayer and inherits all its properties and methods
- Requires valid Tianditu API key(s) for proper functionality
- Supports both Web Mercator (EPSG:3857) and WGS84 (EPSG:4326) coordinate systems
- Layer types determine the visual style and maximum zoom level
- Theme configuration allows for custom visual effects
- Highlight functionality enables interactive features
- All layer properties can be modified after creation
- Layer events provide detailed information about tile loading status
- Supports proxy configuration for cross-origin requests
- Z-index ordering only works within the same layer type