This commit is contained in:
@@ -3,7 +3,7 @@ export type GuideContentDataSourceMode = 'static' | 'remote' | 'mock'
|
||||
|
||||
const allowedModes = new Set<DataSourceMode>(['static', 'api', 'sdk'])
|
||||
const allowedGuideContentModes = new Set<GuideContentDataSourceMode>(['static', 'remote', 'mock'])
|
||||
const defaultSdkScriptUrl = '/static/sgs-map-sdk/index.global.js'
|
||||
const defaultSdkScriptUrl = '/static/sgs-map-sdk/index.global.js?v=2.4.1'
|
||||
const defaultSgsEngineUrl = '/h5-sdk'
|
||||
const defaultSdkTimeoutMs = 5000
|
||||
const defaultApiBaseUrl = '/app-api'
|
||||
|
||||
@@ -3,6 +3,7 @@ import type {
|
||||
SgsMapSDKInstance,
|
||||
SgsMarkerConfig,
|
||||
SgsMapNode,
|
||||
SgsRouteOptions,
|
||||
SgsRouteResult
|
||||
} from '@/types/sgs-map-sdk'
|
||||
import {
|
||||
@@ -116,9 +117,9 @@ export class SgsMapService {
|
||||
return this.sdk
|
||||
}
|
||||
|
||||
async changeFloor(floorId: string | number) {
|
||||
async changeFloor(floorId: string | number, options?: { forceReload?: boolean }) {
|
||||
const sdk = await this.getReadySdk()
|
||||
return sdk.changeFloor(floorId, this.options.timeout)
|
||||
return sdk.changeFloor(floorId, this.options.timeout, options)
|
||||
}
|
||||
|
||||
async focusTo(node: SgsMapNode | string) {
|
||||
@@ -138,15 +139,15 @@ export class SgsMapService {
|
||||
|
||||
async resetView() {
|
||||
const sdk = await this.getReadySdk()
|
||||
sdk.resetView()
|
||||
return sdk.resetView(this.options.timeout)
|
||||
}
|
||||
|
||||
async setViewMode(mode: '2d' | '3d') {
|
||||
const sdk = await this.getReadySdk()
|
||||
sdk.setViewMode(mode)
|
||||
return sdk.setViewMode(mode, this.options.timeout)
|
||||
}
|
||||
|
||||
async planRoute(from: SgsMapNode | string, to: SgsMapNode | string, options?: unknown): Promise<SgsRouteResult> {
|
||||
async planRoute(from: SgsMapNode | string, to: SgsMapNode | string, options?: SgsRouteOptions): Promise<SgsRouteResult> {
|
||||
const sdk = await this.getReadySdk()
|
||||
return sdk.planRoute(from, to, options, this.options.timeout)
|
||||
}
|
||||
|
||||
@@ -24,6 +24,20 @@ export interface SgsRouteResult {
|
||||
segments?: SgsRouteSegment[]
|
||||
}
|
||||
|
||||
export interface SgsRouteOptions {
|
||||
mode?: 'walk' | 'accessible'
|
||||
wheelchair?: boolean
|
||||
preferElevator?: boolean
|
||||
}
|
||||
|
||||
export interface SgsSdkRoutePoint {
|
||||
poiId?: string | number
|
||||
floorId?: string | number
|
||||
x?: number
|
||||
y?: number
|
||||
z?: number
|
||||
}
|
||||
|
||||
export interface SgsMapSDKOptions {
|
||||
container: string | HTMLElement
|
||||
sdkUrl?: string
|
||||
@@ -37,6 +51,13 @@ export interface SgsMapSDKOptions {
|
||||
export interface SgsMapEvents {
|
||||
ready: { engineVersion: string; protocolVersion: number }
|
||||
poiClick: { id: string | number; poiId?: string | number; name: string; type: string; floorId?: string | number; description?: string }
|
||||
poiDetail: SgsPoi & Record<string, unknown>
|
||||
poiNavigate: SgsPoi & Record<string, unknown>
|
||||
poiClose: Record<string, unknown>
|
||||
spaceClick: SgsSpaceArea & Record<string, unknown>
|
||||
spaceDetail: SgsSpaceArea & Record<string, unknown>
|
||||
spaceNavigate: SgsSpaceArea & Record<string, unknown>
|
||||
spaceClose: Record<string, unknown>
|
||||
floorChanged: { floorId: string | number }
|
||||
error: { code: string; message: string }
|
||||
loadError: { type: string; detail: string }
|
||||
@@ -57,6 +78,8 @@ export interface SgsMapEvents {
|
||||
modelError: { floorId: string | number; error: string; fallbackUsed: boolean }
|
||||
floorBundleReady: { floorId: string | number; dataVersion: string }
|
||||
routeReady: { routeId: string; distance: number; duration: number; segmentCount?: number; hasTransfer?: boolean }
|
||||
roamingProgress: { progress: number }
|
||||
roamingDone: { success: boolean }
|
||||
}
|
||||
|
||||
export type SgsRouteTransferType = 'ELEVATOR' | 'STAIRS' | 'ESCALATOR'
|
||||
@@ -95,14 +118,20 @@ export interface SgsMapSDKInstance {
|
||||
whenReady(): Promise<unknown>
|
||||
ready(): Promise<unknown>
|
||||
focusTo(node: SgsMapNode | string): void
|
||||
changeFloor(floorId: string | number, timeout?: number): Promise<{ success: boolean; floorId: string | number }>
|
||||
changeFloor(floorId: string | number, timeout?: number, options?: { forceReload?: boolean }): Promise<{ success: boolean; floorId: string | number }>
|
||||
addMarker(config: SgsMarkerConfig): void
|
||||
removeMarker(markerId: string): void
|
||||
clearMarkers(): void
|
||||
highlightPolygon(payload: string | object): void
|
||||
planRoute(from: SgsMapNode | string, to: SgsMapNode | string, options?: unknown, timeout?: number): Promise<SgsRouteResult>
|
||||
planRouteV2(from: SgsMapNode, to: SgsMapNode, options?: unknown, timeout?: number): Promise<SgsRouteResult>
|
||||
planRoute(from: SgsMapNode | string, to: SgsMapNode | string, options?: SgsRouteOptions, timeout?: number): Promise<SgsRouteResult>
|
||||
planRouteV2(from: SgsMapNode, to: SgsMapNode, options?: SgsRouteOptions, timeout?: number): Promise<SgsRouteResult>
|
||||
clearRoute(): void
|
||||
renderRoutePoints(pathPoints: Array<{ x: number; y: number; z: number }>, options?: unknown, timeout?: number): Promise<SgsRouteResult>
|
||||
startRoaming(pathPoints?: Array<{ x: number; y: number; z: number }>, options?: SgsRouteRoamingOptions, timeout?: number): Promise<{ success: boolean; mode?: string }>
|
||||
stopRoaming(timeout?: number): Promise<{ success: boolean }>
|
||||
toggleRoamingPause(timeout?: number): Promise<{ success: boolean; paused?: boolean }>
|
||||
planRouteToPoi(from: string | number | SgsSdkRoutePoint, toPoiId: string | number, options?: SgsRouteOptions, timeout?: number): Promise<SgsRouteResult>
|
||||
planRouteBetweenPois(fromPoiId: string | number, toPoiId: string | number, options?: SgsRouteOptions, timeout?: number): Promise<SgsRouteResult>
|
||||
getState(): Promise<unknown>
|
||||
resetView(timeout?: number): Promise<{ success: boolean }>
|
||||
setViewMode(mode: '2d' | '3d', timeout?: number): Promise<{ success: boolean; mode: string }>
|
||||
@@ -126,6 +155,7 @@ export interface SgsMapSDKInstance {
|
||||
queryPois(params: SgsPoiQueryParams, timeout?: number): Promise<SgsPoi[]>
|
||||
getFeaturedRoutes(mapId?: string | number, options?: { limit?: number }, timeout?: number): Promise<SgsFeaturedRouteSummary[]>
|
||||
getFeaturedRoute(routeId: string | number, timeout?: number): Promise<SgsFeaturedRouteDetail>
|
||||
planFeaturedRoutePreview(payload: SgsFeaturedRoutePreviewPayload, timeout?: number): Promise<SgsRouteResult>
|
||||
showFlowline(routeId: string | number, options?: SgsFlowlineOptions, timeout?: number): Promise<{ success: boolean; routeId: string | number }>
|
||||
clearFlowline(): void
|
||||
destroy(): void
|
||||
@@ -162,10 +192,15 @@ export interface SgsPoi {
|
||||
status: 'ACTIVE' | 'INACTIVE'
|
||||
anchorNodeName?: string | null
|
||||
description?: string
|
||||
descriptionEn?: string
|
||||
extParams?: string | Record<string, unknown>
|
||||
iconUrl?: string
|
||||
poiGroup?: SgsPoiGroup
|
||||
businessType?: SgsBusinessPoiType
|
||||
coverImageUrl?: string | null
|
||||
images?: string | string[] | null
|
||||
externalUrl?: string | null
|
||||
videoUrl?: string | null
|
||||
phone?: string | null
|
||||
businessHours?: string | null
|
||||
sortOrder?: number | null
|
||||
@@ -182,7 +217,22 @@ export interface SgsSdkManifest {
|
||||
updatedAt: string
|
||||
coordinateSystem: string
|
||||
floors: SgsSdkFloorSummary[]
|
||||
capabilities: Record<string, boolean | undefined>
|
||||
routeAssets?: SgsRouteAsset[]
|
||||
capabilities: Record<string, boolean | undefined> & { sameGroundCompositeRoute?: boolean }
|
||||
}
|
||||
|
||||
export interface SgsRouteAsset {
|
||||
id: string | number
|
||||
mapId?: string | number
|
||||
floorId?: string | number | null
|
||||
floorCode?: string | null
|
||||
assetRole: string
|
||||
modelUrl: string
|
||||
sourceFileName?: string | null
|
||||
sourceNodeName?: string | null
|
||||
modelVersion?: string | null
|
||||
coverageFloorCodes?: string[]
|
||||
sortOrder?: number
|
||||
}
|
||||
|
||||
export interface SgsSdkFloorSummary {
|
||||
@@ -222,13 +272,26 @@ export interface SgsFloorBundle {
|
||||
export interface SgsSpaceArea {
|
||||
id: string | number
|
||||
name: string
|
||||
displayName?: string
|
||||
type: string
|
||||
typeName?: string
|
||||
floorId: string | number
|
||||
floorCode?: string
|
||||
boundaryWkt: string
|
||||
center: { x: number; y: number; z: number }
|
||||
center: { x: number; y?: number; z: number; radius?: number }
|
||||
sourceNodeName?: string
|
||||
status: 'ACTIVE' | 'INACTIVE'
|
||||
colorHex?: string
|
||||
description?: string | null
|
||||
descriptionEn?: string | null
|
||||
coverImageUrl?: string | null
|
||||
images?: string | string[] | null
|
||||
galleryUrls?: string | string[] | null
|
||||
videoUrl?: string | null
|
||||
externalUrl?: string | null
|
||||
openTime?: string | null
|
||||
exhibitCount?: number | null
|
||||
areaSqm?: number | null
|
||||
}
|
||||
|
||||
export interface SgsGuideStop {
|
||||
@@ -268,6 +331,11 @@ export interface SgsNavigablePlace {
|
||||
x: number
|
||||
z: number
|
||||
nodeId?: string | number
|
||||
routeNodeId?: string | number
|
||||
sourceType?: 'POI' | 'SPACE' | 'FLOOR' | 'CUSTOM' | string | null
|
||||
sourceId?: string | number | null
|
||||
anchorId?: string | number | null
|
||||
anchorType?: string | null
|
||||
ownerName?: string
|
||||
typeCode?: string
|
||||
typeName?: string
|
||||
@@ -305,6 +373,8 @@ export interface SgsPerformanceStats {
|
||||
routePlanMs?: number
|
||||
dracoUsed?: boolean
|
||||
fallbackUsed?: boolean
|
||||
bundleCacheHit?: boolean
|
||||
currentModelUrl?: string
|
||||
currentFloorId?: string | number
|
||||
}
|
||||
|
||||
@@ -394,6 +464,21 @@ export interface SgsFeaturedRouteDetail extends SgsFeaturedRouteSummary {
|
||||
waypoints: SgsFeaturedRouteWaypoint[]
|
||||
}
|
||||
|
||||
export interface SgsFeaturedRoutePreviewPayload {
|
||||
routeId?: string | number
|
||||
routeName?: string
|
||||
color?: string | null
|
||||
routeColor?: string | null
|
||||
startEntrance?: SgsRouteEndpoint | null
|
||||
endEntrance?: SgsRouteEndpoint | null
|
||||
waypoints?: SgsFeaturedRouteWaypoint[]
|
||||
}
|
||||
|
||||
export interface SgsRouteRoamingOptions {
|
||||
mode?: 'third-person' | 'top'
|
||||
speed?: number
|
||||
}
|
||||
|
||||
export interface SgsFlowlineOptions {
|
||||
autoFit?: boolean
|
||||
showLabels?: boolean
|
||||
|
||||
Reference in New Issue
Block a user