@cyclomedia/streetsmart-api 23.14.4 → 23.14.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Street Smart API
2
2
 
3
- This Street Smart api package provides programmatic access to most of the UI components of the Street Smart Web application [here](https://streetsmart.cyclomedia.com).
3
+ This Street Smart api package provides programmatic access to most of the UI components of the Street Smart Web
4
+ application [here](https://streetsmart.cyclomedia.com).
4
5
 
5
6
  ---
6
7
 
@@ -12,85 +13,139 @@ First install the package using npm or yarn.
12
13
  npm i @cyclomedia/streetsmart-api
13
14
  ```
14
15
 
15
- Then import the package like
16
+ Then import the package
16
17
 
17
18
  ```ts
18
- import StreetSmartApi from "@cyclomedia/streetsmart-api";
19
+ import { StreetSmartApi } from "@cyclomedia/streetsmart-api";
19
20
  ````
20
21
 
21
- Please note that the package only exposes one default export and no named exports.
22
+ The package exposes also named exports of Typescript types and constants.
22
23
 
23
- ❌ This will not work
24
24
  ```ts
25
- import { init } from "@cyclomedia/streetsmart-api"
26
- ```
27
-
28
- ✅ Named imports of TypeScript types is okay
29
- ```ts
30
- import { ApiOptions } from "@cyclomedia/streetsmart-api"
25
+ import { ApiOptions, ViewerType, AuthOptions } from "@cyclomedia/streetsmart-api"
31
26
  ```
32
27
 
33
28
  ## API
34
- #### Init
35
29
 
36
- Please see the [official docs](https://streetsmart.cyclomedia.com/api/v23.14/documentation/#init) or the `ApiOptions` type for more information about the options.
30
+ Note the item below will just list some examples of the most frequently used methods.
31
+ > [!TIP]
32
+ > For all the available methods on the `StreetSmartApi` object and the individual viewer objects, please refer to the docs.
33
+ ### Init
34
+
35
+ Please see the [official docs](https://streetsmart.cyclomedia.com/api/v23.14/documentation/#init) or the `ApiOptions`
36
+ type for more information about the options.
37
37
 
38
38
  ```ts
39
- import StreetSmartApi from "@cyclomedia/streetsmart-api";
40
-
41
- StreetSmartApi.init({
42
- targetElement: HTMLElement,
43
- srs: string,
44
- locale: string,
45
- apiKey: string,
46
- loginOauth: boolean,
47
- loginRedirectUri: string,
48
- logoutRedirectUri: string,
49
- clientId: string,
50
- ...
39
+ import { StreetSmartApi } from "@cyclomedia/streetsmart-api";
40
+
41
+ await StreetSmartApi.init({
42
+ targetElement: document.getElementById('panorama-window'),
43
+ srs: "EPSG:28992",
44
+ locale: 'en-GB',
45
+ apiKey: 'some-secret-xxx',
46
+ addressSettings: {
47
+ locale: 'nl',
48
+ database: 'CMDatabase'
49
+ },
50
+ loginOauth: true,
51
+ clientId: 'CLIENT_ID-XX-YY-ZZ',
52
+ loginRedirectUri: 'localhost:3000/login',
53
+ logoutRedirectUri: 'localhost:3000/logoutt'
51
54
  })
52
55
  ```
53
56
 
54
- #### Open Panorama viewer
57
+ ### Open viewer
55
58
 
59
+ After the call to `init` has successfully resolved, one or more viewers can be opened using the `open` function.
56
60
  Please check out the [official docs](https://streetsmart.cyclomedia.com/api/v23.14/documentation/#open).
57
61
 
58
62
  ```ts
59
- import StreetSmartApi, {OpenViewerQuery} from "@cyclomedia/streetsmart-api";
63
+ import { StreetSmartApi, ViewerType } from "@cyclomedia/streetsmart-api";
60
64
 
61
- StreetSmartApi.open("1681 broadway, New York NY", {
62
- viewerType: "PANORAMA" | "OBLIQUE" | "...",
63
- srs: string,
65
+ const viewerInstance = await StreetSmartApi.open("5D4KX5SM", {
66
+ viewerType: [ViewerType.PANORAMA, ViewerType.OBLIQUE],
67
+ srs: "EPSG:28992",
64
68
  panoramaViewer: {
65
- closable: boolean,
66
- maximizable: boolean,
67
- timeTravelVisible: boolean,
68
- recordingsVisible: boolean,
69
- navbarVisible: boolean,
70
- ...
69
+ closable: true,
70
+ maximizable: false,
71
+ timeTravelVisible: true,
72
+ recordingsVisible: true,
73
+ navbarVisible: true,
74
+ replace: true,
71
75
  },
72
- ...
76
+ obliqueViewer: {
77
+ closable: true,
78
+ maximizable: false,
79
+ }
73
80
  })
74
81
  ```
75
82
 
76
- #### Destroy
83
+ ### Events
84
+
85
+ You can listen for events both on the global `StreetSmartApi` object and on a specific viewer object, returned by
86
+ the `open` function.
87
+
88
+ Please check the documentation or the typescript declarations for all available events.
89
+ #### Example: global events
90
+
91
+ ```ts
92
+ import { GlobalViewerEvents, MeasurementEvents, StreetSmartApi } from "@cyclomedia/streetsmart-api";
93
+
94
+ StreetSmartApi
95
+ .on(MeasurementEvents.MEASUREMENT_SAVED, (evt) => {
96
+ const { activeMeasurement } = evt.detail
97
+ console.log(activeMeasurement.geometry)
98
+ })
99
+ .on(GlobalViewerEvents.VIEWER_ADDED, (evt) => {
100
+ const viewerId = evt.detail.viewer.getId()
101
+ console.log("Viewer added: ", viewerId)
102
+ })
103
+ ```
77
104
 
78
- For options and behavior please refer to the [official docs](https://streetsmart.cyclomedia.com/api/v23.14/documentation/#destroy)
105
+ #### Example: viewer specific event
79
106
 
80
107
  ```ts
81
- StreetSmartApi.destroy({
82
- targetElement: HTMLElement,
83
- loginOauth: boolean
108
+ import { PanoramaViewer, PanoramaViewerEvents, StreetSmartApi, ViewerType } from "@cyclomedia/streetsmart-api";
109
+
110
+ try {
111
+ const viewers = await StreetSmartApi.open({
112
+ coordinate: [121692.34, 487812.37, 5.60],
113
+ dateRange: { from: '2022-01-01', to: '2024-01-01' }
114
+ }, {
115
+ viewerType: ViewerType.PANORAMA,
116
+ srs: 'EPSG:28992',
117
+ })
118
+
119
+ const panoramaViewer = viewers[0] as PanoramaViewer
120
+ panoramaViewer.on(PanoramaViewerEvents.RECORDING_CLICK, (evt) => {
121
+ const recording = evt.detail.recording
122
+ console.log("Clicked recording ", recording.id)
123
+ })
124
+ } catch (e) {
125
+ // handle error e
126
+ }
127
+
128
+ ```
129
+
130
+ ### Destroy
131
+
132
+ For more information please refer to
133
+ the [official docs](https://streetsmart.cyclomedia.com/api/v23.14/documentation/#destroy)
134
+
135
+ ```ts
136
+ import {StreetSmartApi} from "@cyclomedia/streetsmart-api";
137
+
138
+ await StreetSmartApi.destroy({
139
+ targetElement: document.getElementById('panorama-window'),
140
+ loginOauth: true,
84
141
  })
85
142
  ```
86
143
 
87
144
  ## FAQ
145
+
88
146
  - [What API functions are available?](#what-api-functions-are-available)
89
- - [The Point Cloud Viewer or 3DNL viewer don't load](#the-pointcloud-viewer-or-3dnl-viewer-don't-load)
90
147
 
91
148
  #### What API functions are available?
92
- Please see the [docs](https://streetsmart.cyclomedia.com/api/v23.14/documentation/) for all available functionality.
93
149
 
94
- #### The PointCloud Viewer or 3DNL viewer don't load
95
- Only the panorama and oblique viewer are working in this package.
96
- We are actively working on integrating the point cloud viewer and the mesh (3DNL) viewer.
150
+ Please see the [docs](https://streetsmart.cyclomedia.com/api/v23.14/documentation/) for all available functions.
151
+