becomap 1.6.2 → 1.6.9
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/lib/becomap.js +1 -1
- package/lib/index.d.ts +10 -0
- package/package.json +1 -1
- package/public/README.md +375 -0
- package/public/index.html +1032 -158
package/lib/index.d.ts
CHANGED
|
@@ -639,6 +639,16 @@ export interface BCRouteController {
|
|
|
639
639
|
* @param orderIndex - The order index of the step to display.
|
|
640
640
|
*/
|
|
641
641
|
showStepByOrderIndex(orderIndex: number): void;
|
|
642
|
+
/**
|
|
643
|
+
* Shows a specific route segment by its orderIndex.
|
|
644
|
+
* @param orderIndex - The order index of the segment to display.
|
|
645
|
+
*/
|
|
646
|
+
showSegmentByOrderIndex(orderIndex: number): void;
|
|
647
|
+
/**
|
|
648
|
+
* Gets the currently stored route segments.
|
|
649
|
+
* @returns Array of BCRouteSegment objects or null if no segments are stored.
|
|
650
|
+
*/
|
|
651
|
+
get segments(): BCRouteSegment[] | null;
|
|
642
652
|
/**
|
|
643
653
|
* Clears the current route from the map by removing the route layer or data from the map view.
|
|
644
654
|
* It relies on the routeController to manage route layers or data.
|
package/package.json
CHANGED
package/public/README.md
ADDED
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
# Becomap WebView Integration API
|
|
2
|
+
|
|
3
|
+
A complete reference for integrating Becomap WebView with native mobile applications. This document covers all public methods, parameters, callback events, error cases, and validation rules.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Table of Contents
|
|
8
|
+
- [Initialization](#initialization)
|
|
9
|
+
- [Public Methods](#public-methods)
|
|
10
|
+
- [Data Retrieval](#data-retrieval)
|
|
11
|
+
- [Selection & Navigation](#selection--navigation)
|
|
12
|
+
- [Viewport Control](#viewport-control)
|
|
13
|
+
- [Search](#search)
|
|
14
|
+
- [Routing](#routing)
|
|
15
|
+
- [System & Utility](#system--utility)
|
|
16
|
+
- [Callback Events](#callback-events)
|
|
17
|
+
- [Error Cases](#error-cases)
|
|
18
|
+
- [Parameter Validation](#parameter-validation)
|
|
19
|
+
- [Integration Example](#integration-example)
|
|
20
|
+
- [Message Format](#message-format)
|
|
21
|
+
- [Native Bridge](#native-bridge)
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Initialization
|
|
26
|
+
|
|
27
|
+
### `init(siteOptions)`
|
|
28
|
+
Initializes the map view.
|
|
29
|
+
|
|
30
|
+
**Parameters:**
|
|
31
|
+
- `siteOptions` (object, required):
|
|
32
|
+
- `clientId` (string, required)
|
|
33
|
+
- `clientSecret` (string, required)
|
|
34
|
+
- `siteIdentifier` (string, required)
|
|
35
|
+
|
|
36
|
+
**Errors:**
|
|
37
|
+
- Invalid site options
|
|
38
|
+
- Map container not found
|
|
39
|
+
- SDK load timeout
|
|
40
|
+
- Site data load failure
|
|
41
|
+
|
|
42
|
+
### `cleanup()`
|
|
43
|
+
Cleans up all resources, listeners, and state.
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Public Methods
|
|
48
|
+
|
|
49
|
+
### Data Retrieval
|
|
50
|
+
|
|
51
|
+
#### `getCurrentFloor()`
|
|
52
|
+
Returns the current floor object.
|
|
53
|
+
- **Callback:** `onGetCurrentFloor`
|
|
54
|
+
- **Errors:** MapView not initialized, Application destroyed
|
|
55
|
+
|
|
56
|
+
#### `getCategories()`
|
|
57
|
+
Returns an array of location categories.
|
|
58
|
+
- **Callback:** `onGetCategories`
|
|
59
|
+
- **Errors:** MapView not initialized
|
|
60
|
+
|
|
61
|
+
#### `getLocations()`
|
|
62
|
+
Returns an array of all locations.
|
|
63
|
+
- **Callback:** `onGetLocations`
|
|
64
|
+
- **Errors:** MapView not initialized
|
|
65
|
+
|
|
66
|
+
#### `getAmenities()`
|
|
67
|
+
Returns an array of all amenity locations.
|
|
68
|
+
- **Callback:** `onGetAmenities`
|
|
69
|
+
- **Errors:** MapView not initialized
|
|
70
|
+
|
|
71
|
+
#### `getAmenityTypes()`
|
|
72
|
+
Returns an array of amenity types.
|
|
73
|
+
- **Callback:** `onGetAmenityTypes`
|
|
74
|
+
- **Errors:** MapView not initialized
|
|
75
|
+
|
|
76
|
+
#### `getSessionId()`
|
|
77
|
+
Returns the current session ID.
|
|
78
|
+
- **Callback:** `onGetSessionId`
|
|
79
|
+
- **Errors:** MapView not initialized
|
|
80
|
+
|
|
81
|
+
#### `getHappenings(type)`
|
|
82
|
+
Returns an array of events/happenings.
|
|
83
|
+
- `type` (string, optional): Event type filter
|
|
84
|
+
- **Callback:** `onGetHappenings`
|
|
85
|
+
- **Errors:** MapView not initialized
|
|
86
|
+
|
|
87
|
+
#### `getEventSuggestions(sessionId, answers)`
|
|
88
|
+
Returns event suggestions based on session and answers.
|
|
89
|
+
- `sessionId` (string, required)
|
|
90
|
+
- `answers` (array, required)
|
|
91
|
+
- **Callback:** `onGetEventSuggestions`
|
|
92
|
+
- **Errors:** MapView not initialized
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
### Selection & Navigation
|
|
97
|
+
|
|
98
|
+
#### `selectFloorWithId(floorId)`
|
|
99
|
+
Selects a floor by ID.
|
|
100
|
+
- `floorId` (string|number, required)
|
|
101
|
+
- **Errors:** MapView not initialized, Invalid floor ID
|
|
102
|
+
|
|
103
|
+
#### `selectLocationWithId(locationId)`
|
|
104
|
+
Selects a location by ID.
|
|
105
|
+
- `locationId` (string|number, required)
|
|
106
|
+
- **Errors:** MapView not initialized, Invalid location ID
|
|
107
|
+
|
|
108
|
+
#### `selectAmenities(type)`
|
|
109
|
+
Selects amenities by type.
|
|
110
|
+
- `type` (string, required)
|
|
111
|
+
- **Errors:** MapView not initialized, Invalid type
|
|
112
|
+
|
|
113
|
+
#### `clearSelection()`
|
|
114
|
+
Clears all selections.
|
|
115
|
+
- **Errors:** MapView not initialized
|
|
116
|
+
|
|
117
|
+
#### `focusTo(location, zoom, bearing, pitch)`
|
|
118
|
+
Focuses the camera to a location.
|
|
119
|
+
- `location` (object, required)
|
|
120
|
+
- `zoom` (number, optional, 1-25)
|
|
121
|
+
- `bearing` (number, optional, 0-360)
|
|
122
|
+
- `pitch` (number, optional, 0-60)
|
|
123
|
+
- **Errors:** Invalid parameters, MapView not initialized
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
### Viewport Control
|
|
128
|
+
|
|
129
|
+
#### `updateZoom(zoom)`
|
|
130
|
+
Sets the zoom level.
|
|
131
|
+
- `zoom` (number, required, 1-25)
|
|
132
|
+
- **Errors:** MapView not initialized, Value out of range
|
|
133
|
+
|
|
134
|
+
#### `updatePitch(pitch)`
|
|
135
|
+
Sets the pitch angle.
|
|
136
|
+
- `pitch` (number, required, 0-60)
|
|
137
|
+
- **Errors:** MapView not initialized, Value out of range
|
|
138
|
+
|
|
139
|
+
#### `updateBearing(bearing)`
|
|
140
|
+
Sets the bearing angle.
|
|
141
|
+
- `bearing` (number, required, 0-360)
|
|
142
|
+
- **Errors:** MapView not initialized, Value out of range
|
|
143
|
+
|
|
144
|
+
#### `enableMultiSelection(val)`
|
|
145
|
+
Enables or disables multi-selection.
|
|
146
|
+
- `val` (boolean, required)
|
|
147
|
+
- **Errors:** MapView not initialized
|
|
148
|
+
|
|
149
|
+
#### `setBounds(sw, ne)`
|
|
150
|
+
Sets the map bounds.
|
|
151
|
+
- `sw` (object, required): Southwest coordinate
|
|
152
|
+
- `ne` (object, required): Northeast coordinate
|
|
153
|
+
- **Errors:** MapView not initialized
|
|
154
|
+
|
|
155
|
+
#### `setViewport(options)`
|
|
156
|
+
Sets the viewport with options.
|
|
157
|
+
- `options` (object, required)
|
|
158
|
+
- **Errors:** MapView not initialized
|
|
159
|
+
|
|
160
|
+
#### `resetDefaultViewport(options)`
|
|
161
|
+
Resets the viewport to default.
|
|
162
|
+
- `options` (object, required)
|
|
163
|
+
- **Errors:** MapView not initialized
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
### Search
|
|
168
|
+
|
|
169
|
+
#### `searchForLocations(query, callbackId)`
|
|
170
|
+
Searches for locations.
|
|
171
|
+
- `query` (string, required, max 100 chars)
|
|
172
|
+
- `callbackId` (string, required)
|
|
173
|
+
- **Callback:** `onSearchForLocations`
|
|
174
|
+
- **Errors:** Missing/invalid parameters, Search method not available
|
|
175
|
+
|
|
176
|
+
#### `searchForCategories(query, callbackId)`
|
|
177
|
+
Searches for categories.
|
|
178
|
+
- `query` (string, required)
|
|
179
|
+
- `callbackId` (string, required)
|
|
180
|
+
- **Callback:** `onSearchForCategories`
|
|
181
|
+
- **Errors:** Search method not available
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
### Routing
|
|
186
|
+
|
|
187
|
+
#### `getRoute(startID, goalID, waypoints, routeOptions)`
|
|
188
|
+
Calculates a route.
|
|
189
|
+
- `startID` (string|number, required)
|
|
190
|
+
- `goalID` (string|number, required)
|
|
191
|
+
- `waypoints` (array, optional, max 10)
|
|
192
|
+
- `routeOptions` (object, optional)
|
|
193
|
+
- **Callback:** `onGetRoute`
|
|
194
|
+
- **Errors:** Invalid parameters, No route found, Route data invalid
|
|
195
|
+
|
|
196
|
+
#### `showRoute(segmentOrderIndex?)`
|
|
197
|
+
Shows a route or a specific segment.
|
|
198
|
+
- `segmentOrderIndex` (number, optional)
|
|
199
|
+
- **Errors:** Route controller not available, Invalid segment index, No segments
|
|
200
|
+
|
|
201
|
+
#### `showStep(step)`
|
|
202
|
+
Shows a specific route step.
|
|
203
|
+
- `step` (number, required)
|
|
204
|
+
- **Errors:** MapView not initialized, Invalid step
|
|
205
|
+
|
|
206
|
+
#### `clearAllRoutes()`
|
|
207
|
+
Clears all displayed routes.
|
|
208
|
+
- **Errors:** MapView not initialized
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
### System & Utility
|
|
213
|
+
|
|
214
|
+
#### `getAppState()`
|
|
215
|
+
Returns the current application state.
|
|
216
|
+
- **Callback:** `onGetAppState`
|
|
217
|
+
|
|
218
|
+
#### `healthCheck()`
|
|
219
|
+
Returns health and connectivity status.
|
|
220
|
+
- **Callback:** `onHealthCheck`
|
|
221
|
+
|
|
222
|
+
#### `recoverFromError()`
|
|
223
|
+
Attempts to recover from an error state.
|
|
224
|
+
- **Callback:** `onErrorRecovery`
|
|
225
|
+
|
|
226
|
+
#### `getDebugInfo()`
|
|
227
|
+
Returns debug information.
|
|
228
|
+
- **Callback:** `onGetDebugInfo`
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
## Callback Events
|
|
233
|
+
|
|
234
|
+
| Event Name | When Fired | Payload Example |
|
|
235
|
+
|------------------------|-----------------------------------|----------------------------------|
|
|
236
|
+
| onRenderComplete | Map is ready | `{ site: { ... } }` |
|
|
237
|
+
| onViewChange | View changed | `{ viewOptions: { ... } }` |
|
|
238
|
+
| onLocationSelect | Location selected | `{ locations: [ ... ] }` |
|
|
239
|
+
| onFloorSwitch | Floor switched | `{ floor: { ... } }` |
|
|
240
|
+
| onStepLoad | Route step loaded | `{ step: { ... } }` |
|
|
241
|
+
| onWalkthroughEnd | Navigation ended | `{}` |
|
|
242
|
+
| onGetCurrentFloor | Floor data returned | `{ ... }` |
|
|
243
|
+
| onGetCategories | Categories array | `[ ... ]` |
|
|
244
|
+
| onGetLocations | Locations array | `[ ... ]` |
|
|
245
|
+
| onGetAmenities | Amenities array | `[ ... ]` |
|
|
246
|
+
| onGetAmenityTypes | Amenity types array | `[ ... ]` |
|
|
247
|
+
| onGetSessionId | Session ID | `"session-id"` |
|
|
248
|
+
| onGetHappenings | Events array | `[ ... ]` |
|
|
249
|
+
| onGetEventSuggestions | Suggestions array | `[ ... ]` |
|
|
250
|
+
| onSearchForLocations | Location search results | `{ callbackId, results, error? }`|
|
|
251
|
+
| onSearchForCategories | Category search results | `{ callbackId, results, error? }`|
|
|
252
|
+
| onGetRoute | Route data | `[ ... ]` |
|
|
253
|
+
| onError | All error conditions | `{ operation, error }` |
|
|
254
|
+
| onHealthCheck | Health status | `{ ... }` |
|
|
255
|
+
| onGetAppState | App state | `{ appState, hasMapView, hasSite }`|
|
|
256
|
+
| onErrorRecovery | Recovery status | `{}` |
|
|
257
|
+
| onGetDebugInfo | Debug data | `{ ... }` |
|
|
258
|
+
| onCleanupComplete | Cleanup done | `{}` |
|
|
259
|
+
|
|
260
|
+
---
|
|
261
|
+
|
|
262
|
+
## Error Cases
|
|
263
|
+
|
|
264
|
+
All errors are now standardized to use the `onError` callback with a consistent payload format. Here's a comprehensive table of all operations and their error conditions:
|
|
265
|
+
|
|
266
|
+
| Operation Name | Error Conditions | Example Error Message |
|
|
267
|
+
|----------------|------------------|----------------------|
|
|
268
|
+
| `init` | Invalid siteOptions, SDK load failure, site data load failure | "Invalid siteOptions provided" |
|
|
269
|
+
| `load` | Map rendering failure, site data processing error | "Failed to load map data" |
|
|
270
|
+
| `switchToFloor` | Error processing floor switch data | "Error processing floor switch" |
|
|
271
|
+
| `stepLoad` | Error processing route step data | "Error processing route step" |
|
|
272
|
+
| `walkthroughEnd` | Error processing walkthrough completion | "Error processing walkthrough completion" |
|
|
273
|
+
| `getCurrentFloor` | MapView not initialized, floor data unavailable | "MapView not initialized" |
|
|
274
|
+
| `selectFloorWithId` | Invalid floor ID, MapView not initialized | "Invalid floor ID" |
|
|
275
|
+
| `selectLocationWithId` | Invalid location ID, MapView not initialized | "Invalid location ID" |
|
|
276
|
+
| `getCategories` | MapView not initialized, categories data unavailable | "Categories data unavailable" |
|
|
277
|
+
| `getLocations` | MapView not initialized, locations data unavailable | "Locations data unavailable" |
|
|
278
|
+
| `getAmenities` | MapView not initialized, amenities data unavailable | "Amenities data unavailable" |
|
|
279
|
+
| `getAmenityTypes` | MapView not initialized, amenity types unavailable | "Amenity types unavailable" |
|
|
280
|
+
| `selectAmenities` | Invalid amenity type, MapView not initialized | "Invalid amenity type" |
|
|
281
|
+
| `getSessionId` | Session ID retrieval failure, MapView not initialized | "Session ID retrieval failed" |
|
|
282
|
+
| `getHappenings` | MapView not initialized, happenings data unavailable | "Happenings data unavailable" |
|
|
283
|
+
| `getEventSuggestions` | Invalid parameters, suggestion retrieval failure | "Event suggestions retrieval failed" |
|
|
284
|
+
| `focusTo` | Missing location parameter, zoom/bearing/pitch out of range | "zoom out of valid range" |
|
|
285
|
+
| `clearSelection` | MapView not initialized | "MapView not initialized" |
|
|
286
|
+
| `updateZoom` | Invalid zoom value, MapView not initialized | "Invalid zoom value" |
|
|
287
|
+
| `updatePitch` | Invalid pitch value, MapView not initialized | "Invalid pitch value" |
|
|
288
|
+
| `updateBearing` | Invalid bearing value, MapView not initialized | "Invalid bearing value" |
|
|
289
|
+
| `enableMultiSelection` | Invalid boolean value, MapView not initialized | "Invalid boolean value" |
|
|
290
|
+
| `setBounds` | Invalid bounds parameters, MapView not initialized | "Invalid bounds parameters" |
|
|
291
|
+
| `setViewport` | Invalid viewport options, MapView not initialized | "Invalid viewport options" |
|
|
292
|
+
| `resetDefaultViewport` | Invalid options, MapView not initialized | "Invalid viewport options" |
|
|
293
|
+
| `getRoute` | Invalid parameters, no route found, route data corruption | "No route found between specified locations" |
|
|
294
|
+
| `showRoute` | Route controller unavailable, invalid segment index, no segments | "Route controller not available" |
|
|
295
|
+
| `showStep` | Invalid step index, route controller unavailable | "Invalid step index" |
|
|
296
|
+
| `clearAllRoutes` | Route controller not initialized | "Route controller not initialized" |
|
|
297
|
+
|
|
298
|
+
### Search Method Validation Errors
|
|
299
|
+
|
|
300
|
+
| Method | Error Callback | Validation Rules | Error Conditions |
|
|
301
|
+
|--------|----------------|------------------|------------------|
|
|
302
|
+
| `searchForLocations` | `onSearchForLocations` | query: required, string, max 100 chars; callbackId: required, string | Missing parameters, query too long |
|
|
303
|
+
| `searchForCategories` | `onSearchForCategories` | query: required, string; callbackId: required, string | Missing parameters |
|
|
304
|
+
|
|
305
|
+
**Standardized error payload format:**
|
|
306
|
+
```json
|
|
307
|
+
{
|
|
308
|
+
"operation": "operationName",
|
|
309
|
+
"error": "descriptive error message explaining what went wrong"
|
|
310
|
+
}
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
**Note:** All error handling now uses the `onError` callback exclusively. Previous error callbacks like `onFocusToError`, `onGetRouteError`, and `onShowRouteError` have been removed in favor of the standardized `onError` callback.
|
|
314
|
+
|
|
315
|
+
---
|
|
316
|
+
|
|
317
|
+
## Parameter Validation
|
|
318
|
+
|
|
319
|
+
- **Required:** If a parameter is required and missing, an error is returned.
|
|
320
|
+
- **Type:** If a parameter is of the wrong type, an error is returned.
|
|
321
|
+
- **Range:**
|
|
322
|
+
- `zoom`: 1-25
|
|
323
|
+
- `bearing`: 0-360
|
|
324
|
+
- `pitch`: 0-60
|
|
325
|
+
- `waypoints`: max 10
|
|
326
|
+
- **Max Length:**
|
|
327
|
+
- `query` (search): 100 characters
|
|
328
|
+
|
|
329
|
+
**Validation error example:**
|
|
330
|
+
```json
|
|
331
|
+
{
|
|
332
|
+
"operation": "focusTo",
|
|
333
|
+
"error": "zoom out of valid range"
|
|
334
|
+
}
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
---
|
|
338
|
+
|
|
339
|
+
## Integration Example
|
|
340
|
+
|
|
341
|
+
```javascript
|
|
342
|
+
// 1. Initialize
|
|
343
|
+
init({
|
|
344
|
+
clientId: "your-client-id",
|
|
345
|
+
clientSecret: "your-secret",
|
|
346
|
+
siteIdentifier: "site-id"
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
// 2. Wait for onRenderComplete event
|
|
350
|
+
// 3. Use public methods
|
|
351
|
+
getLocations();
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
---
|
|
355
|
+
|
|
356
|
+
## Message Format
|
|
357
|
+
|
|
358
|
+
All messages sent to the native bridge follow this format:
|
|
359
|
+
```json
|
|
360
|
+
{
|
|
361
|
+
"type": "onLocationSelect",
|
|
362
|
+
"payload": { "locations": [ ... ] },
|
|
363
|
+
"timestamp": 1234567890
|
|
364
|
+
}
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
---
|
|
368
|
+
|
|
369
|
+
## Native Bridge
|
|
370
|
+
- **iOS:** `window.webkit.messageHandlers.jsHandler`
|
|
371
|
+
- **Android:** `window.jsHandler.postMessage`
|
|
372
|
+
|
|
373
|
+
---
|
|
374
|
+
|
|
375
|
+
For further details, see the code in `public/index.html` or contact the SDK maintainers.
|