Viewer is the core class for the 3D map viewer, providing map display, camera control, layer management, scene rendering, and other capabilities.
Parameters:
containerId (string): ID of the container DOM elementoptions (ViewerOptions, optional): Initialization configuration optionsExample:
| Property Name | Type | Description |
|---|---|---|
app |
ViewerApp |
ViewerApp instance |
container |
HTMLDivElement |
Scene container DOM element |
renderer |
object |
Renderer object, containing domElement (HTMLCanvasElement) |
| Property Name | Type | Description |
|---|---|---|
viewMode |
"2D" | "3D" |
View mode |
viewInfo |
object |
Current view info (heading, pitch, position) |
projectedViewRange |
object |
Projected view range, containing coordinate array |
fov |
number |
Field of View |
proj4 |
string |
Proj4 projection string |
userDefinedProj4 |
string? |
User-defined Proj4 string |
| Property Name | Type | Description |
|---|---|---|
camera |
object |
Camera object, containing position, rotation, fov, aspect, type |
controlMode |
number |
Control mode |
viewCollision |
boolean |
Scroll zoom collision prevention |
| Property Name | Type | Description |
|---|---|---|
sunLight |
boolean |
Whether sun light is enabled |
isSunShadow |
boolean? |
Whether sun shadows are enabled |
sunFlare |
boolean |
Sun flare effect |
sunIntensity |
number |
Sun light intensity |
envLightIntensity |
number |
Environment light intensity |
useAdditionalEnvLight |
boolean |
Whether to use additional environment light |
sceneDate |
Date |
Scene date and time |
useSceneDate |
boolean |
Whether to use scene date |
| Property Name | Type | Description |
|---|---|---|
postProcessingManager |
object |
Post-processing manager, see below for details |
lut |
string? |
Deprecated, replaced by postProcessingManager |
postProcessingManager Object:
| Property Name | Type | Description |
|---|---|---|
lut |
string? |
LUT color lookup table |
lutIntensity |
number |
LUT intensity |
brightness |
number |
Brightness |
contrast |
number |
Contrast |
saturation |
number |
Saturation |
hue |
number |
Hue |
ACESFilmicToneMapping |
boolean |
ACES tone mapping |
blooming |
boolean |
Bloom effect |
bloomingStrength |
number |
Bloom strength |
bloomingThreshold |
number |
Bloom threshold |
colorTemperature |
number |
Color temperature adjustment |
ao |
boolean |
Ambient Occlusion |
on |
function |
Event listener, e.g., on('LUTLoad', callback) |
| Property Name | Type | Description |
|---|---|---|
terrainTransparency |
number |
Terrain transparency (0-1) |
| Property Name | Type | Description |
|---|---|---|
contourSetting |
object |
Contour configuration object |
contourSetting.enabled |
boolean |
Whether contours are enabled |
contourSetting.color |
number |
Contour color |
contourSetting.lineWidth |
number |
Line width |
contourSetting.contourInterval |
number |
Contour interval |
contourSetting.minHeight |
number |
Minimum height |
contourSetting.maxHeight |
number |
Maximum height |
| Property Name | Type | Description |
|---|---|---|
identifyDrawing |
boolean |
Whether to identify drawing objects |
identifyFeature |
boolean |
Whether to identify features |
rotationBoxControl |
boolean |
Whether to show rotation control box |
rotationBoxLocale |
LocaleName |
Rotation control box language |
| Property Name | Type | Description |
|---|---|---|
enableMapDisplayArea |
boolean |
Whether to enable map display area restriction |
mapDisplayArea |
object |
Map display area configuration |
mapDisplayArea.coords |
[number, number] |
Top-left and bottom-right coordinates |
mapDisplayArea.fromEPSG |
number | string |
Coordinate system EPSG code |
| Property Name | Type | Description |
|---|---|---|
cloudBox |
CloudBoxSetting? |
Cloud box settings (getter/setter) |
cloud |
SceneCloudSetting? |
Scene cloud settings (getter/setter) |
volumetricLighting |
VolumetricLightingSetting? |
Volumetric lighting settings (getter/setter) |
| Property Name | Type | Description |
|---|---|---|
baseMapUrls |
BaseMapUrl | BaseMapUrl[] |
Basemap URL configuration (setter) |
baseMapUrls |
Array<{uuid, wrapper}> |
Basemap list (getter) |
terrainUrl |
string | string[]? |
Terrain URL (setter) |
terrainUrl |
string? |
Terrain URL (getter) |
basemapScreenSpaceError |
number |
Basemap screen space error (LOD control) |
| Property Name | Type | Description |
|---|---|---|
animations |
Record<string, any> |
Animation collection |
locale |
LocaleName |
Language settings |
zoomTo(options: CameraPose): voidInstantly jumps to specified camera position (no animation).
Parameters:
options (CameraPose): Camera pose configurationflyTo(options: CameraPose): voidFlies to specified camera position (with animation).
Parameters:
options (CameraPose): Camera pose configurationflyToLookAt(options): voidFlies to and looks at a specified position.
Parameters:
addPointcloudLayer(options: PointCloudLayerOptions): Promise<{id, layer}>Adds a point cloud layer.
Returns: Promise containing layer ID and layer object
flyToPointcloudById(id: number | string): voidFlies to specified point cloud layer.
setPointcloudOpacityById(id: number | string, opacity: number): voidSets point cloud opacity.
Parameters:
opacity: Decimal between 0-1setPointcloudPointSizeById(id: number | string, size: number): voidSets point cloud point size.
setPointCloudColorScheme(id: number | string, scheme: PointCloudColorScheme): voidSets point cloud color scheme.
setPointCloudHeightRange(id: number | string, minHeight: number, maxHeight: number): voidSets point cloud height range filter.
setPointCloudIntensityRange(id: number | string, minIntensity: number, maxIntensity: number): voidSets point cloud intensity range filter.
add3DTilesLayer(options: Tiles3DLayerOptions): Promise<{id, layer}>Adds a 3D Tiles layer.
Returns: Promise containing layer ID and layer object
flyTo3DTilesById(id: number | string, options?): voidFlies to specified 3D Tiles layer.
Parameters:
set3DTilesOpacityById(id: number | string, opacity: number): voidSets 3D Tiles opacity (0-1).
set3DTilesVisibleById(id: number | string, visible: boolean): voidSets 3D Tiles visibility.
set3DTilesFeatureVisibleById(layerId: number | string, features: number[]): voidSets visibility of specified features in 3D Tiles.
set3DTilesNoFlattening(layerIds: (number | string)[], isNoFlatten: boolean): voidSets whether 3D Tiles should not be flattened.
getIs3DTilesNoFlatteningById(layerId: number | string): booleanGets whether a specified layer has no-flattening enabled.
getNoFlatteningList(): (number | string)[]Gets list of all no-flattening layer IDs.
get3DTilesFeatureTree(layerId: number | string): anyGets 3D Tiles feature tree structure.
setIs3DTilesRawFeatureTypesVisible(layerId, featureKeys, boolean): voidSets visibility of 3D Tiles raw feature types.
flyTo3DTilesBBox(layerId: number | string, bbox: any): voidFlies to 3D Tiles bounding box.
clear3DTilesFeatureColorById(layerId: number): voidClears 3D Tiles feature colors.
set3DTilesDefaultColorById(layerId: number, color: number, alpha: number): voidSets 3D Tiles default color.
set3DTilesFeatureColorById(layerId: number, featureIds: number[], color: number, alpha: number): voidSets color for specified features in 3D Tiles.
getIs3DTilesWireframeById(layerId: number | string): booleanGets whether wireframe mode is enabled.
setIs3DTilesWireframeById(layerId: number | string, isWireframe: boolean): voidSets 3D Tiles wireframe mode.
setIs3DTilesUseEnvMap(layerId: number | string, isUseEnvMap: boolean): voidSets whether 3D Tiles use environment map.
set3DTilesLoadStartEvent(layerId: number | string, callback: () => void): voidSets 3D Tiles load start event callback.
set3DTilesLoadEvent(layerId: number | string, callback: () => void): voidSets 3D Tiles load complete event callback.
set3DTilesErrorTarget(layerId: number | string, val: number): voidSets 3D Tiles error target value (LOD control).
addBaseMapLayer(value: BaseMapUrl, index: number): voidAdds a basemap layer at specified index position.
removeBaseMapLayer(index: number): voidRemoves basemap layer at specified index.
moveUp(index: number): voidMoves tile map order up.
moveDown(index: number): voidMoves tile map order down.
getTileMap(): object | undefinedGets tile map object.
Returns:
updateTile(id, originalGeoJSON, modifiedGeoJSON, originalProj4, currentProj4): voidUpdates tile data.
getScreenCaptureRaw(): Promise<Blob>Gets raw screenshot data.
Returns: Promise
getScreenCapture(pictureName: string): voidSaves screenshot to file.
startVideoRecord(): voidStarts video recording.
stopVideoRecord(videoName: string): voidStops video recording and saves.
playOrbitAnimation(config?: Partial<OrbitAnimationConfig>): voidPlays orbit animation.
Parameters:
stopOrbitAnimation(): voidStops orbit animation.
setSplatting(path, positionInfo, cb?): voidSets Gaussian splatting model.
Parameters:
flyToSplatting(): voidFlies to Gaussian splatting model.
setWeather(weather: Weather): voidSets weather effect.
Parameters:
weather: "SUNNY" | "RAINY" | "FOGGY" | "SNOWY"getScale(): numberGets current scale.
getPositionLocal(): {x, y, z}Gets current local coordinate position.
getCartographic(): [longitude, latitude]Gets current longitude and latitude coordinates.
setRotationBoxTopRight(config: {top?, right?}): voidSets rotation control box position.
Use the on method to listen for events:
identifyFeature identification event.
Callback Parameter: IdentifyData
bimFeatureTypeLoadBIM feature type load complete event.
Callback Parameters:
json: Record<string, number[]> - Feature type mappingid: number - Layer IDcameramoveCamera move event (normal precision).
Callback Parameters:
cameramovepreciseCamera move event (high precision).
Callback Parameters: CameraPose
clickMouse click event.
Callback Parameters:
moveMouse move event.
Callback Parameters:
Configuration options for the Viewer constructor.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
far |
number |
No | - | Camera far clipping plane distance |
proj4 |
string |
No | - | Proj4 projection string |
sunLight |
boolean |
No | - | Whether sun light is enabled |
baseMapUrls |
BaseMapUrl | BaseMapUrl[] |
No | - | Basemap configuration |
terrainUrl |
string |
No | - | Terrain service URL |
isWebGL2 |
boolean |
No | - | Whether to use WebGL2 |
mapMaximumLevel |
number |
No | - | Map maximum level |
licensingServiceUrl |
string |
No | - | Licensing service URL |
basemapScreenSpaceError |
number |
No | - | Basemap screen space error (LOD) |
viewCollision |
boolean |
No | - | Scroll zoom collision prevention |
useSceneDate |
boolean |
No | - | Whether to use scene date |
Basemap supports multiple service types, can be a string URL or configuration object.
Use tile URL template directly:
Type: TEMPLATEOptions
| Field | Type | Required | Description |
|---|---|---|---|
type |
"TEMPLATE" |
Yes | Service type |
url |
string |
Yes | Tile URL template |
opacity |
number |
No | Opacity (0-1) |
Type: WMSOptions
WMS (Web Map Service) standard service configuration.
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
type |
"WMS" |
Yes | - | Service type |
url |
string |
Yes | - | WMS service base URL |
version |
string |
Yes | "1.3.0" |
WMS version number |
layers |
string |
Yes | "0" |
Layer names (comma-separated) |
format |
string |
Yes | "image/png" |
Image format |
styles |
string |
Yes | "" |
Layer styles |
key |
string |
Yes | "" |
API key/token |
opacity |
number |
No | - | Opacity (0-1) |
Example:
Type: ArcGisMapServerOptions
ArcGIS map service configuration.
| Field | Type | Required | Description |
|---|---|---|---|
type |
"ArcGIS_MapService" |
Yes | Service type |
url |
string |
Yes | ArcGIS MapServer URL |
format |
string |
Yes | Image format (default "png8") |
epsg |
string |
Yes | Coordinate system EPSG code |
key |
string |
Yes | API key |
Example:
Type: ArcGisFeatureServerOptions
ArcGIS feature service configuration (supports vector rendering).
Inherits from: TileMapStyle
| Field | Type | Required | Description |
|---|---|---|---|
type |
"ArcGIS_FeatureService" |
Yes | Service type |
url |
string |
Yes | ArcGIS FeatureServer URL |
epsg |
string |
No | Coordinate system EPSG code |
pointColor |
string |
No | Point color |
pointSize |
number |
No | Point size (pixels) |
lineColor |
string |
No | Line color |
lineWidth |
number |
No | Line width (pixels) |
fillColor |
string |
No | Fill color |
Example:
Type: WFSOptions
WFS (Web Feature Service) standard service configuration.
Inherits from: TileMapStyle
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
type |
"WFS" |
Yes | - | Service type |
uuid |
string |
No | - | Unique identifier |
url |
string |
Yes | - | WFS service URL |
version |
string |
Yes | - | WFS version number |
typeName |
string |
Yes | - | Layer type name |
outputFormat |
string |
Yes | "GeoJSON" |
Output format |
key |
string |
No | - | API key |
rule |
any |
No | - | Style rules |
SLD |
SldObj |
No | - | SLD style object |
fields |
string[] |
No | - | Field list |
text |
object |
No | - | Text style configuration |
opacity |
number |
No | - | Opacity (0-1) |
Text Style:
Example:
Type: GeoTwinFeatureTileServiceOptions
GeoTwin's proprietary vector tile service supporting high-performance rendering and complex styling.
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
type |
"GeoTwin_FeatureTileService" |
Yes | - | Service type |
uuid |
string |
No | - | Unique identifier |
url |
string |
Yes | - | Service URL (without /{z}/{x}/{y}) |
token |
string |
No | - | Access token |
format |
string | boolean |
No | true |
Response format (true=binary, recommended) |
count |
number |
No | - | Max features per request |
fields |
string[] |
Yes | - | Field list (recommended to specify explicitly) |
rule |
GtFeatureTileStyleRule |
No | - | Style rules (migrating to SLD) |
SLD |
SldObj |
No | - | SLD style object |
params |
Record<string, string|boolean> |
No | - | Custom request parameters |
TEXTLAYER_OPTIONS |
object |
No | - | Text label configuration |
clampToModel |
boolean |
No | - | Whether to clamp to model |
highlight |
Highlight |
No | - | Highlight configuration |
opacity |
number |
No | - | Opacity (0-1) |
TEXTLAYER_OPTIONS:
Highlight Configuration:
Example:
Basic style configuration for vector layers.
| Field | Type | Description |
|---|---|---|
pointColor |
string |
Point color (6-digit hex or rgba string) |
pointSize |
number |
Point size (pixels) |
lineColor |
string |
Line color |
lineWidth |
number |
Line width (pixels) |
fillColor |
string |
Fill color |
graphicFill |
any |
Graphic fill |
dashArray |
number[] |
Dash pattern |
Advanced style rules for GeoTwin FeatureTileService.
classification: Classification rule, sets styles based on different values of a fieldrange: Range rule, sets styles based on field value rangesgradient: Gradient rule, sets gradient colors based on field valueshistogram3D: 3D bar chart| Field | Type | Description |
|---|---|---|
type |
GtFeatureTileStyleRuleType |
Rule type |
property |
string |
Property field name |
material |
string |
Material |
baseHeight |
string | number |
Base height |
topHeight |
string | number |
Top height |
styles |
GtFeatureTileStyleRuleStyle[] |
Style array |
sideTexture |
SideTexture |
Side texture |
style |
object |
Style configuration (for gradients, etc.) |
Supports very rich style options, including:
Point Styles:
pointColor: Point colorpointRadius: Point radiustext: Text styleIconMarker: Icon markerTextMarker: Text markerGLTFModelJson: 3D modelSectorScanJson: Sector scan effectLine Styles:
lineColor: Line colorlineWidth: Line widthlineJoin: Join style ("round" | "bevel" | "miter")lineCap: Cap style ("round" | "butt" | "square")dashArray: Dash arrayGlowLineJson: Glow lineTraceLineJson: Trace lineHorizontalDynamicFenceJson: Horizontal dynamic fencePolygon Styles:
fillColor: Fill colorgraphicFill: Graphic fill (supports line fill, etc.)GenericDrawPolygon: Generic polygon drawingExample: Classification Style
Example: Gradient Style
Example: 3D Bar Chart
Example: Icon Marker
Example: 3D Model Marker
Example: Glow Line
Contains:
x, y, z: Position coordinatesheading: Heading angle (degrees)pitch: Pitch angle (degrees)roll: Roll angle (degrees, optional)epsg: Coordinate system (optional)Data types returned by identification events, can be one of the following:
baseMapUrls array, basemaps earlier in the array are at lower levels (underneath)viewer.lut directly is deprecated, please use viewer.postProcessingManager.lutproj4)basemapScreenSpaceError and set3DTilesErrorTarget to control LOD, balancing performance and qualityformat: true) for best performancefields list to avoid missing or loading unnecessary datarule will gradually migrate to SLD object