@cyclomedia/streetsmart-api

中文文档
26.4.0发布于 2026/11/04UNLICENSEDTypeScriptESM + CJS近 30 天下载 3308

The Streetsmart API wrapped as an npm package

原始使用文档
文档目录8 节
  1. Setup
  2. Release channels
  3. API
  4. Init
  5. Open viewer
  6. Events
  7. Destroy
  8. FAQ

Street Smart API

This Street Smart api package provides programmatic access to most of the UI components of the Street Smart Web application here.


Setup

First install the package using npm or yarn.

npm i @cyclomedia/streetsmart-api

Release channels

The package is published on separate npm dist-tags, so support lines can be installed independently of the main line.

dist-tagVersion formatContents
latestX.Y.Zmain line, released version of the API
rcX.Y.Z-rc.Nrelease candidate of an upcoming version
react19X.Y.Z-react19.NReact 19 compatible build of version X.Y.Z
npm i @cyclomedia/streetsmart-api           # latest
npm i @cyclomedia/streetsmart-api@rc        # release candidate
npm i @cyclomedia/streetsmart-api@react19   # React 19 support line

Then import the package

import { StreetSmartApi } from "@cyclomedia/streetsmart-api";

The package exposes also named exports of Typescript types and constants.

import { ApiOptions, ViewerType, AuthOptions } from "@cyclomedia/streetsmart-api"

API

Note the item below will just list some examples of the most frequently used methods.

[!TIP] For all the available methods on the StreetSmartApi object and the individual viewer objects, please refer to the docs.

Init

Please see the official docs or the ApiOptions type for more information about the options.

import { StreetSmartApi } from "@cyclomedia/streetsmart-api";

await StreetSmartApi.init({
    targetElement: document.getElementById('panorama-window'),
    srs: "EPSG:28992",
    locale: 'en-GB',
    apiKey: 'some-secret-xxx',
    addressSettings: {
        locale: 'nl',
        database: 'CMDatabase'
    },
    loginOauth: true,
    clientId: 'CLIENT_ID-XX-YY-ZZ',
    loginRedirectUri: 'localhost:3000/login',
    logoutRedirectUri: 'localhost:3000/logoutt'
})

Open viewer

After the call to init has successfully resolved, one or more viewers can be opened using the open function. Please check out the official docs.

import { StreetSmartApi, ViewerType } from "@cyclomedia/streetsmart-api";

const viewerInstance = await StreetSmartApi.open("5D4KX5SM", {
    viewerType: [ViewerType.PANORAMA, ViewerType.OBLIQUE],
    srs: "EPSG:28992",
    panoramaViewer: {
        closable: true,
        maximizable: false,
        timeTravelVisible: true,
        recordingsVisible: true,
        navbarVisible: true,
        replace: true,
    },
    obliqueViewer: {
        closable: true,
        maximizable: false,
    }
})

Events

You can listen for events both on the global StreetSmartApi object and on a specific viewer object, returned by the open function.

Please check the documentation or the typescript declarations for all available events.

Example: global events

import { GlobalViewerEvents, MeasurementEvents, StreetSmartApi } from "@cyclomedia/streetsmart-api";

StreetSmartApi
    .on(MeasurementEvents.MEASUREMENT_SAVED, (evt) => {
        const { activeMeasurement } = evt.detail
        console.log(activeMeasurement.geometry)
    })
    .on(GlobalViewerEvents.VIEWER_ADDED, (evt) => {
        const viewerId = evt.detail.viewer.getId()
        console.log("Viewer added: ", viewerId)
    })

Example: viewer specific event

import { PanoramaViewer, PanoramaViewerEvents, StreetSmartApi, ViewerType } from "@cyclomedia/streetsmart-api";

try {
    const viewers = await StreetSmartApi.open({
        coordinate: [121692.34, 487812.37, 5.60],
        dateRange: { from: '2022-01-01', to: '2024-01-01' }
    }, {
        viewerType: ViewerType.PANORAMA,
        srs: 'EPSG:28992',
    })

    const panoramaViewer = viewers[0] as PanoramaViewer
    panoramaViewer.on(PanoramaViewerEvents.RECORDING_CLICK, (evt) => {
        const recording = evt.detail.recording
        console.log("Clicked recording ", recording.id)
    })
} catch (e) {
    // handle error e
}

Destroy

For more information please refer to the official docs

import {StreetSmartApi} from "@cyclomedia/streetsmart-api";

await StreetSmartApi.destroy({
    targetElement: document.getElementById('panorama-window'),
    loginOauth: true,
})

FAQ

What API functions are available?

Please see the docs for all available functions and methods.

版本与发布记录

@cyclomedia/streetsmart-api 共发布 116 个版本,首次发布于 2023/11/08;过去 12 个月发布了 12 个版本。

版本发布日期距今
26.4.0latest2026/11/046 天前
26.4.0-rc.2rc2026/11/037 天前
26.4.12026/11/037 天前
26.4.0-rc.12026/11/038 天前
26.4.0-rc.02026/11/038 天前
26.3.2-rc.02026/09/092 个月前

其他发布通道:react19 → 26.3.0-react19.0,rc → 26.4.0-rc.2。

关于 @cyclomedia/streetsmart-api 的常见问题

@cyclomedia/streetsmart-api 是什么?

The Streetsmart API wrapped as an npm package

如何安装 @cyclomedia/streetsmart-api?

在项目目录运行 npm install @cyclomedia/streetsmart-api,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(18.3.1)、react-dom(18.3.1)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@cyclomedia/streetsmart-api 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@cyclomedia/streetsmart-api 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@cyclomedia/streetsmart-api 可以商用吗?

@cyclomedia/streetsmart-api 使用 UNLICENSED 许可。作者声明为 UNLICENSED,即不授予公开使用许可(与公共领域的 Unlicense 不同)。使用前需获得作者授权。以上为概括,不构成法律意见,请以许可原文为准。

@cyclomedia/streetsmart-api 的下载量有多少?

根据 npm 官方下载统计,@cyclomedia/streetsmart-api 在 2026/10/11 – 2026/11/09 这 30 天内被下载 3,308 次,日均约 110 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@cyclomedia/streetsmart-api 还在维护吗?

最新版本 26.4.0 发布于 2026/11/04(6 天前);至今共发布 116 个版本,其中过去 12 个月发布了 12 个;首次发布于 2023/11/08。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。