proximiio-js-library 1.2.0

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.
Files changed (100) hide show
  1. package/README.md +719 -0
  2. package/assets/proximiio-js-library.css +520 -0
  3. package/assets/tbtnav.js +3 -0
  4. package/assets/wayfinding.d.ts +3 -0
  5. package/assets/wayfinding.js +1586 -0
  6. package/lib/common.d.ts +7 -0
  7. package/lib/common.js +49 -0
  8. package/lib/components/map/constants.d.ts +6 -0
  9. package/lib/components/map/constants.js +30 -0
  10. package/lib/components/map/custom-layers.d.ts +5 -0
  11. package/lib/components/map/custom-layers.js +74 -0
  12. package/lib/components/map/icons.d.ts +23 -0
  13. package/lib/components/map/icons.js +64 -0
  14. package/lib/components/map/layers/any_layer.d.ts +9 -0
  15. package/lib/components/map/layers/any_layer.js +2 -0
  16. package/lib/components/map/layers/background_layer.d.ts +16 -0
  17. package/lib/components/map/layers/background_layer.js +52 -0
  18. package/lib/components/map/layers/base_layer.d.ts +18 -0
  19. package/lib/components/map/layers/base_layer.js +127 -0
  20. package/lib/components/map/layers/circle_layer.d.ts +25 -0
  21. package/lib/components/map/layers/circle_layer.js +62 -0
  22. package/lib/components/map/layers/fill_extrusion_layer.d.ts +21 -0
  23. package/lib/components/map/layers/fill_extrusion_layer.js +57 -0
  24. package/lib/components/map/layers/fill_layer.d.ts +21 -0
  25. package/lib/components/map/layers/fill_layer.js +57 -0
  26. package/lib/components/map/layers/heatmap_layer.d.ts +18 -0
  27. package/lib/components/map/layers/heatmap_layer.js +54 -0
  28. package/lib/components/map/layers/hillshade_layer.d.ts +19 -0
  29. package/lib/components/map/layers/hillshade_layer.js +55 -0
  30. package/lib/components/map/layers/line_layer.d.ts +28 -0
  31. package/lib/components/map/layers/line_layer.js +64 -0
  32. package/lib/components/map/layers/raster_layer.d.ts +21 -0
  33. package/lib/components/map/layers/raster_layer.js +57 -0
  34. package/lib/components/map/layers/symbol_layer.d.ts +71 -0
  35. package/lib/components/map/layers/symbol_layer.js +153 -0
  36. package/lib/components/map/main.d.ts +625 -0
  37. package/lib/components/map/main.js +1765 -0
  38. package/lib/components/map/metadata.d.ts +134 -0
  39. package/lib/components/map/metadata.js +135 -0
  40. package/lib/components/map/routing.d.ts +12 -0
  41. package/lib/components/map/routing.js +74 -0
  42. package/lib/components/map/sources/base_source.d.ts +10 -0
  43. package/lib/components/map/sources/base_source.js +38 -0
  44. package/lib/components/map/sources/cluster_source.d.ts +7 -0
  45. package/lib/components/map/sources/cluster_source.js +30 -0
  46. package/lib/components/map/sources/data_source.d.ts +17 -0
  47. package/lib/components/map/sources/data_source.js +46 -0
  48. package/lib/components/map/sources/geojson_source.d.ts +16 -0
  49. package/lib/components/map/sources/geojson_source.js +77 -0
  50. package/lib/components/map/sources/image_source_manager.d.ts +16 -0
  51. package/lib/components/map/sources/image_source_manager.js +131 -0
  52. package/lib/components/map/sources/routing_source.d.ts +22 -0
  53. package/lib/components/map/sources/routing_source.js +131 -0
  54. package/lib/components/map/sources/synthetic_source.d.ts +7 -0
  55. package/lib/components/map/sources/synthetic_source.js +32 -0
  56. package/lib/components/map/sources/vector_source.d.ts +8 -0
  57. package/lib/components/map/sources/vector_source.js +31 -0
  58. package/lib/components/select/main.d.ts +66 -0
  59. package/lib/components/select/main.js +195 -0
  60. package/lib/controllers/auth.d.ts +48 -0
  61. package/lib/controllers/auth.js +156 -0
  62. package/lib/controllers/floors.d.ts +14 -0
  63. package/lib/controllers/floors.js +105 -0
  64. package/lib/controllers/geo.d.ts +10 -0
  65. package/lib/controllers/geo.js +131 -0
  66. package/lib/controllers/places.d.ts +14 -0
  67. package/lib/controllers/places.js +108 -0
  68. package/lib/controllers/repository.d.ts +24 -0
  69. package/lib/controllers/repository.js +68 -0
  70. package/lib/controllers/style.d.ts +4 -0
  71. package/lib/controllers/style.js +76 -0
  72. package/lib/eventable.d.ts +7 -0
  73. package/lib/eventable.js +29 -0
  74. package/lib/index.d.ts +26 -0
  75. package/lib/index.js +14 -0
  76. package/lib/models/amenity.d.ts +11 -0
  77. package/lib/models/amenity.js +41 -0
  78. package/lib/models/auth-data.d.ts +4 -0
  79. package/lib/models/auth-data.js +2 -0
  80. package/lib/models/base.d.ts +7 -0
  81. package/lib/models/base.js +18 -0
  82. package/lib/models/feature.d.ts +46 -0
  83. package/lib/models/feature.js +277 -0
  84. package/lib/models/floor.d.ts +30 -0
  85. package/lib/models/floor.js +51 -0
  86. package/lib/models/geopoint.d.ts +6 -0
  87. package/lib/models/geopoint.js +2 -0
  88. package/lib/models/mapbox-options.d.ts +171 -0
  89. package/lib/models/mapbox-options.js +2 -0
  90. package/lib/models/person.d.ts +8 -0
  91. package/lib/models/person.js +18 -0
  92. package/lib/models/place.d.ts +14 -0
  93. package/lib/models/place.js +40 -0
  94. package/lib/models/poi_type.d.ts +19 -0
  95. package/lib/models/poi_type.js +25 -0
  96. package/lib/models/style.d.ts +53 -0
  97. package/lib/models/style.js +424 -0
  98. package/lib/proximiio.js +2 -0
  99. package/lib/proximiio.js.LICENSE.txt +79 -0
  100. package/package.json +61 -0
package/README.md ADDED
@@ -0,0 +1,719 @@
1
+ # Proximi.io JS Library
2
+
3
+ ## Getting work
4
+ In case of cloning the repo from GitHub please run `npm install` afterwards.
5
+
6
+ ### Using just in browser
7
+ This requires to load js file into script tag of html file.
8
+ ```
9
+ <script src="lib/proximiio.js"></script>
10
+ ```
11
+
12
+ ### Using in node.js
13
+ ```
14
+ const Proximiio = require('lib/index').default;
15
+ ```
16
+
17
+ ### Using with modern javascript frameworks (Angular, React)
18
+ Install with npm
19
+ ```
20
+ npm install proximiio-js-library
21
+ ```
22
+ and then import into project with
23
+ ```
24
+ import Proximiio from 'proximiio-js-library'
25
+ ```
26
+
27
+ ## Available methods
28
+
29
+ #### Log in
30
+ You can log in with email and password or with the token.
31
+ Successful log in is required for all other afterwards methods so execute this as soon as possible.
32
+
33
+ ###### Log in with email/password
34
+
35
+ ```
36
+ // node.js & react/angular
37
+ Proximiio.Auth.login('email', 'password')
38
+
39
+ // browser
40
+ Proximiio.default.Auth.login('email', 'password')
41
+ ```
42
+
43
+ ###### Log in with token
44
+
45
+ ```
46
+ // node.js & react/angular
47
+ Proximiio.Auth.loginWithToken('token')
48
+
49
+ // browser
50
+ Proximiio.default.Auth.loginWithToken('token')
51
+ ```
52
+
53
+ ###### Get User Config Data
54
+
55
+ ```
56
+ // node.js & react/angular
57
+ Proximiio.Auth.getUserConfig()
58
+
59
+ // browser
60
+ Proximiio.default.Auth.getUserConfig()
61
+ ```
62
+
63
+ #### Get list of places
64
+ ```
65
+ // node.js & react/angular
66
+ Proximiio.Places.getPlaces()
67
+
68
+ // browser
69
+ Proximiio.default.Places.getPlaces()
70
+ ```
71
+
72
+ #### Get list of floors
73
+ ```
74
+ // node.js & react/angular
75
+ Proximiio.Floors.getFloors()
76
+
77
+ // browser
78
+ Proximiio.default.Floors.getFloors()
79
+ ```
80
+
81
+ ###### Available arguments for lists
82
+ You can pass arguments to list calls for pagination, order, filtering in this order.
83
+ ```
84
+ limit?: number, // total results to return
85
+ skip?: number, // how many results to skip from beginning
86
+ order?: string, // specify field to order results by e.g 'createdAt'
87
+ dir?: string, // direction of results order, could be 'asc' or 'desc'
88
+ filterByIndex?: string, // specify field for filtering e.g 'name'
89
+ q?: string // query to filter
90
+ ```
91
+
92
+ ### Map Component
93
+
94
+ Map is generated using the [Mapbox GL library](https://docs.mapbox.com/mapbox-gl-js/api/map/), it's necessary to load it's css file in your html `<head>` tag.
95
+
96
+ ```
97
+ <link href='https://api.mapbox.com/mapbox-gl-js/v1.12.0/mapbox-gl.css' rel='stylesheet' />
98
+ ```
99
+
100
+ To generate map, create div element with id param defined
101
+ ```
102
+ <div id="proximiioMap"></div>
103
+ ```
104
+ Now you can call
105
+ ```
106
+ const map = new Proximiio.Map({
107
+ selector: 'customMap', // optional, id of map container, default 'proximiioMap'
108
+ allowNewFeatureModal: false, // optional, if true, you'll be able to add new features via modal dialog, default false
109
+ newFeatureModalEvent: 'click', // optional, choose which event should open the modal for adding new features (should be map event https://docs.mapbox.com/mapbox-gl-js/api/map/#map-events), default 'click'
110
+ enableTBTNavigation: true, // optional, you'll receive turn-by-turn text navigation object in found route listener response, default: true
111
+ mapboxOptions: { MapboxOptions }, // optional, you can pass mapbox initial options like center or zoom here, all options can be found at https://docs.mapbox.com/mapbox-gl-js/api/map/
112
+ defaultPlaceId: 'my_place_id', // optional, you can specify default place, if not specified the first place found will be used as default
113
+ zoomIntoPlace: false // optional, the map will center and zoom into the default place location, default: true
114
+ isKiosk: false, // optional, this will enable kiosk like behavior for the map (will add dot at spiecified coordinates in kioskSettings and this point will be set as a starting point for generated routes)
115
+ kioskSettings: {
116
+ coordinates: [number, number], // coordinates for a kiosk start point
117
+ level: number // floor level of a kiosk starting point
118
+ },
119
+ initPolygons: false // optional, default: false, if enabled and yours geojson includes required data the map will show defined features as polygons with hover/click effect.
120
+ });
121
+ ```
122
+ #### Required Data for 3D Polygons
123
+ As first there must be a MultiPolygon feature created which will be a polygon itself, it's also nice to have a label-line property in properties set. Label-line is just imaginary line alongside which poi title will be drawn. At last, you have to connect poi to polygon via adding its id to poi metadata like polygon_id property.
124
+
125
+ Polygon Feature Example:
126
+ ```
127
+ {
128
+ "type": "Feature",
129
+ "geometry": {
130
+ "type": "MultiPolygon",
131
+ "coordinates": coordinates of all corner points
132
+ },
133
+ "properties": {
134
+ "id": "my-poi-polygon-id",
135
+ "label-line": [
136
+ [
137
+ longitude,
138
+ latitude
139
+ ],
140
+ [
141
+ longitude,
142
+ latitude
143
+ ]
144
+ ],
145
+ ...
146
+ }
147
+ }
148
+ ```
149
+ POI Feature Example:
150
+ ```
151
+ {
152
+ "type": "Feature",
153
+ "geometry": {
154
+ "type": "Point",
155
+ "coordinates": [longitude, latitude]
156
+ },
157
+ "properties": {
158
+ "usecase": "poi",
159
+ "type": "poi",
160
+ "id": "my-poi-id",
161
+ ...
162
+ "metadata": {
163
+ "polygon_id": "my-poi-polygon-id",
164
+ ...
165
+ }
166
+ }
167
+ }
168
+ ```
169
+ #### Available Methods
170
+
171
+ ##### Get the mapbpox instance
172
+ ```
173
+ map.getMapboxInstance(); // this will return mapbox instance
174
+ ```
175
+
176
+ ##### Set active place
177
+ This method will set an active place, load floors etc. Have to be called after map is ready, see getMapReadyListener.
178
+ ```
179
+ // @param placeId {string} Id of the place to be set as active on map
180
+ // @param zoomIntoPlace {boolean} should zoom into active place, optional
181
+ // @param floorLevel {number} Level of the floor to be set as active on map, optional
182
+
183
+ map.getMapReadyListener().subscribe(ready => {
184
+ console.log('map ready', ready);
185
+ map.setPlace(myPlaceId);
186
+ });
187
+ ```
188
+
189
+ ##### Set active floor
190
+ Have to be called after map is ready, see getMapReadyListener.
191
+ ###### by id
192
+ This method will set an active floor based on it's id.
193
+ ```
194
+ map.getMapReadyListener().subscribe(ready => {
195
+ console.log('map ready', ready);
196
+ map.setFloorById(myFloorId);
197
+ });
198
+ ```
199
+ ###### by level
200
+ This method will set an active floor based on it's level.
201
+ ```
202
+ map.getMapReadyListener().subscribe(ready => {
203
+ console.log('map ready', ready);
204
+ map.setFloorByLevel(0);
205
+ });
206
+ ```
207
+ ###### by way
208
+ This method will set an active floor based on the way of the next floor, e.g if we wanna go up or down.
209
+ ```
210
+ map.getMapReadyListener().subscribe(ready => {
211
+ console.log('map ready', ready);
212
+ map.setFloorByWay('up');
213
+ });
214
+ ```
215
+
216
+ #### Set new kiosk settings
217
+ With this method you can override kiosk coordinates position and it's floor level
218
+ ```
219
+ const map = new Proximiio.Map({
220
+ isKiosk: true,
221
+ kioskSettings: {
222
+ coordinates: [17.833135351538658, 48.60678469647394],
223
+ level: 0
224
+ }
225
+ });
226
+ map.getMapReadyListener().subscribe(ready => {
227
+ console.log('map ready', ready);
228
+ map.setKiosk(48.606703739771774, 17.833092384506614, 1);
229
+ });
230
+ ```
231
+
232
+ ##### Find Route
233
+
234
+ ###### by features id
235
+ This method will generate route based on selected features by their ids.
236
+ ```
237
+ // @param idTo {string} finish feature id
238
+ // @param idFrom {string} start feature id, optional for kiosk
239
+ // @param accessibleRoute {boolean} if true generated routed will be accessible without stairs, etc., optional
240
+
241
+ map.getMapReadyListener().subscribe(ready => {
242
+ console.log('map ready', ready);
243
+ map.findRouteByIds('idTo', 'idFrom');
244
+ });
245
+ ```
246
+ ###### by features title
247
+ This method will generate route based on selected features by their titles.
248
+ ```
249
+ // @param titleTo {string} finish feature title
250
+ // @param titleFrom {string} start feature title, optional for kiosk
251
+ // @param accessibleRoute {boolean} if true generated routed will be accessible without stairs, etc., optional
252
+
253
+ map.getMapReadyListener().subscribe(ready => {
254
+ console.log('map ready', ready);
255
+ map.findRouteByTitle('titleTo', 'titleFrom');
256
+ });
257
+ ```
258
+
259
+ ###### by coords
260
+ This method will generate route based on attached coords.
261
+ ```
262
+ // @param latTo {number} finish latitude coordinate
263
+ // @param lngTo {number} finish longitude coordinate
264
+ // @param levelTo {number} finish level
265
+ // @param latFrom {number} start latitude coordinate, optional for kiosk
266
+ // @param lngFrom {number} start longitude coordinate, optional for kiosk
267
+ // @param levelFrom {number} start level, optional for kiosk
268
+ // @param accessibleRoute {boolean} if true generated routed will be accessible without stairs, etc., optional
269
+
270
+ map.getMapReadyListener().subscribe(ready => {
271
+ console.log('map ready', ready);
272
+ map.findRouteByCoords(48.606703739771774, 17.833092384506614, 0, 48.60684545080579, 17.833450676669543, 0);
273
+ });
274
+ ```
275
+
276
+ ##### Cancel Route
277
+ Use this method to cancel generated route.
278
+ ```
279
+ map.getMapReadyListener().subscribe(ready => {
280
+ console.log('map ready', ready);
281
+ map.cancelRoute();
282
+ });
283
+ ```
284
+
285
+ ##### Get turn by turn navigation object
286
+ Retrieves the turn by turn navigation object.
287
+ ```
288
+ map.getMapReadyListener().subscribe(ready => {
289
+ console.log('map ready', ready);
290
+ const TBTNav = map.getTBTNav();
291
+ });
292
+ ```
293
+
294
+ ##### Center to route
295
+ This method will center the map to generated route bounds.
296
+ ```
297
+ map.getMapReadyListener().subscribe(ready => {
298
+ console.log('map ready', ready);
299
+ map.centerToRoute();
300
+ });
301
+ ```
302
+
303
+ ##### Center to feature
304
+ This method will center the map to feature coordinates.
305
+ ```
306
+ map.getMapReadyListener().subscribe(ready => {
307
+ console.log('map ready', ready);
308
+ map.centerToFeature('featureId');
309
+ });
310
+ ```
311
+
312
+ ##### Center to coordinates
313
+ This method will center the map to provided coordinates.
314
+ ```
315
+ // @param lat {number} latitude coordinate, required
316
+ // @param lng {number} longitude coordinate, required
317
+ // @param zoom {number} zoom level, optional, 18 as default
318
+
319
+ map.getMapReadyListener().subscribe(ready => {
320
+ console.log('map ready', ready);
321
+ map.centerToCoordinates(48.60678469647394, 17.833135351538658, 20);
322
+ });
323
+ ```
324
+
325
+ ##### Add New Feature
326
+ Add new feature to map.
327
+ ```
328
+ // @param title {string} feature title, required
329
+ // @param level {number} feature floor level, required
330
+ // @param lat {number} feature latitude coordinate, required
331
+ // @param lng {number} feature longitude coordinate, required
332
+ // @param icon {string} feature icon image in base64 format, optional
333
+ // @param id {string} feature id, optional, will be autogenerated if not defined
334
+ // @param placeId {string} feature place_id, optional
335
+ // @param floorId {string} feature floor_id, optional
336
+ // @return <Promise>{Feature} newly added feature
337
+
338
+ map.getMapReadyListener().subscribe(ready => {
339
+ console.log('map ready', ready);
340
+ const myFeature = map.addCustomFeature('myPOI', 0, 48.606703739771774, 17.833092384506614);
341
+ });
342
+ ```
343
+
344
+ ##### Update Feature
345
+ Update existing map feature.
346
+ ```
347
+ // @param id {string} feature id
348
+ // @param title {string} feature title, optional
349
+ // @param level {number} feature floor level, optional
350
+ // @param lat {number} feature latitude coordinate, optional
351
+ // @param lng {number} feature longitude coordinate, optional
352
+ // @param icon {string} feature icon image in base64 format, optional
353
+ // @param placeId {string} feature place_id, optional
354
+ // @param floorId {string} feature floor_id, optional
355
+ // @return <Promise>{Feature} newly added feature
356
+
357
+ map.getMapReadyListener().subscribe(ready => {
358
+ console.log('map ready', ready);
359
+ const myFeature = map.updateFeature('poiId', 'myPOI', 0, 48.606703739771774, 17.8330923845066);
360
+ });
361
+ ```
362
+
363
+ ##### Delete Feature
364
+ Delete existing map feature.
365
+ ```
366
+ // @param id {string} feature id
367
+
368
+ map.getMapReadyListener().subscribe(ready => {
369
+ console.log('map ready', ready);
370
+ map.deleteFeature('poiId');
371
+ });
372
+ ```
373
+
374
+ ##### Get list of added features
375
+ Retrieves the list of only newly added features.
376
+ ```
377
+ map.getMapReadyListener().subscribe(ready => {
378
+ console.log('map ready', ready);
379
+ const features = map.getCustomFeaturesList();
380
+ });
381
+ ```
382
+
383
+ ##### Showing Person Icon
384
+
385
+ ###### setPerson()
386
+ Method for setting a person icon on a Map, this method is resetting the previous state of all persons added before.
387
+ ```
388
+ // @param lat {number} latitude coordinate of person.
389
+ // @param lng {number} longitude coordinate of person.
390
+ // @param level {number} floor level of person.
391
+ // @param id {string | number} id of person, optional.
392
+
393
+ map.getMapReadyListener().subscribe(ready => {
394
+ console.log('map ready', ready);
395
+ map.setPerson(48.606703739771774, 17.833092384506614, 0);
396
+ });
397
+ ```
398
+
399
+ ###### upsertPerson()
400
+ Method for add/update person icon on a Map.
401
+ ```
402
+ // @param lat {number} latitude coordinate of person.
403
+ // @param lng {number} longitude coordinate of person.
404
+ // @param level {number} floor level of person.
405
+ // @param id {string | number} id of person, optional.
406
+
407
+ map.getMapReadyListener().subscribe(ready => {
408
+ console.log('map ready', ready);
409
+ map.upsertPerson(48.606703739771774, 17.833092384506614, 0, 'person-1');
410
+ });
411
+ ```
412
+
413
+ ##### Map Features Filtering
414
+
415
+ ###### Setting new filter
416
+ You'll be able to show features only for defined amenity id on map with this method, also with defining the category _(NOTE: you have to create them before with [setAmenitiesCategory()](#setting-new-amenities-category) method)_, filtering will be set only for defined array of amenities in the category. With category set, only one amenity filter can be active at the time, while without the category they stack so multiple amenities can be active.
417
+
418
+ ```
419
+ // param amenityId {string} only features of defined amenityId will be visible
420
+ // param category {string} id of the amenities category added via setAmenitiesCategory, optional, if defined filtering will be set only for defined array of amenities in same method
421
+
422
+ const map = new Proximiio.Map();
423
+ map.getMapReadyListener().subscribe(ready => {
424
+ console.log('map ready', ready);
425
+ map.setAmenityFilter('myamenity');
426
+ });
427
+ ```
428
+
429
+ ###### Removing created filter
430
+ Method for removing previously created amenity filters. In case amenity filter has been set with the category parameter, you have to use same param for removing the filter.
431
+
432
+ ```
433
+ // param amenityId {string} remove the filter for a defined amenityId
434
+ // param category {string} id of the amenities category added via setAmenitiesCategory, optional, if defined filtering will be removed only for defined array of amenities in same method
435
+
436
+ const map = new Proximiio.Map();
437
+ map.getMapReadyListener().subscribe(ready => {
438
+ console.log('map ready', ready);
439
+ map.removeAmenityFilter('myamenity');
440
+ });
441
+ ```
442
+
443
+ ###### Resetting all filters
444
+ Method for removing all active filters.
445
+
446
+ ```
447
+ const map = new Proximiio.Map();
448
+ map.getMapReadyListener().subscribe(ready => {
449
+ console.log('map ready', ready);
450
+ map.resetAmenityFilters();
451
+ });
452
+ ```
453
+
454
+ ###### Setting new amenities category
455
+ You can define your own categories of amenities, which you can then use for advanced filtering.
456
+
457
+ ```
458
+ // param id {string} category id, have to be used when calling setAmenityFilter() method as second param.
459
+ // param amenities {Array of strings} list of the amenities id
460
+
461
+ const map = new Proximiio.Map();
462
+ map.getMapReadyListener().subscribe(ready => {
463
+ console.log('map ready', ready);
464
+ map.setAmenitiesCategory('shops', ['id1', 'id2']);
465
+ });
466
+ ```
467
+
468
+ ###### Removing amenities category
469
+ Method for removing previously created categories.
470
+
471
+ ```
472
+ // param id {string} category id.
473
+
474
+ const map = new Proximiio.Map();
475
+ map.getMapReadyListener().subscribe(ready => {
476
+ console.log('map ready', ready);
477
+ map.removeAmenitiesCategory('shops');
478
+ });
479
+ ```
480
+
481
+ ###### Resetting all amenity categories
482
+ Method for removing all active amenity categories.
483
+
484
+ ```
485
+ const map = new Proximiio.Map();
486
+ map.getMapReadyListener().subscribe(ready => {
487
+ console.log('map ready', ready);
488
+ map.resetAmenitiesCategory();
489
+ });
490
+ ```
491
+
492
+ #### Available Listeners
493
+
494
+ ##### Listen to map ready event
495
+ ```
496
+ map.getMapReadyListener().subscribe(ready => {
497
+ console.log('map ready', ready);
498
+ });
499
+ ```
500
+
501
+ ##### Listen to place select event
502
+ ```
503
+ map.getPlaceSelectListener().subscribe(place => {
504
+ console.log('selected place', place);
505
+ });
506
+ ```
507
+
508
+ ##### Listen to floor select event
509
+ ```
510
+ map.getFloorSelectListener().subscribe(floor => {
511
+ console.log('selected floor', floor);
512
+ });
513
+ ```
514
+
515
+ ##### Listen to route found event
516
+ ```
517
+ map.getRouteFoundListener().subscribe(res => {
518
+ console.log('route found successfully', res.route);
519
+ console.log('turn by turn text navigation output', res.TBTNav);
520
+ });
521
+ ```
522
+
523
+ ##### Listen to route failed event
524
+ ```
525
+ map.getRouteFailedListener().subscribe(() => {
526
+ console.log('route not found');
527
+ });
528
+ ```
529
+
530
+ ##### Listen to route cancel event
531
+ ```
532
+ map.getRouteCancelListener().subscribe(() => {
533
+ console.log('route cancelled);
534
+ });
535
+ ```
536
+
537
+ ##### Listen to feature add event
538
+ ```
539
+ map.getFeatureAddListener().subscribe(feature => {
540
+ console.log('feature added', feature);
541
+ });
542
+ ```
543
+
544
+ ##### Listen to feature update event
545
+ ```
546
+ map.getFeatureUpdateListener().subscribe(feature => {
547
+ console.log('feature updated', feature);
548
+ });
549
+ ```
550
+
551
+ ##### Listen to feature delete event
552
+ ```
553
+ map.getFeatureDeleteListener().subscribe(() => {
554
+ console.log('feature deleted');
555
+ });
556
+ ```
557
+
558
+ ##### Listen to polygon click event
559
+ ```
560
+ map.getPolygonClickListener().subscribe((poi) => {
561
+ console.log('polygon clicked', poi);
562
+ });
563
+ ```
564
+
565
+ ##### Listen to persons update event
566
+ ```
567
+ map.getPersonUpdateListener().subscribe((personsList) => {
568
+ console.log('current persons', personsList);
569
+ });
570
+ ```
571
+
572
+ ### Select Component
573
+
574
+ Select component is generated using the [Autocomplete.js](https://tarekraafat.github.io/autoComplete.js) library. Optionally load [css file](assets/proximiio-js-library.css) into your project from assets folder, feel free to fit it to your requirements.
575
+
576
+ To generate select widget, create input element with id param defined, for styling please assign also class param.
577
+ ```
578
+ <input id="proximiioSelect" class="proximiio-select" type="text" tabIndex="1"/>
579
+ ```
580
+ Now you can call
581
+ ```
582
+ // @param dataset { Datasets } predefined proximi.io dataset to search on, could be Places | Floors | Pois
583
+ // @param options { AutocompleteOptions } autocomplete.js options, check https://tarekraafat.github.io/autoComplete.js/#/configuration for more info
584
+ // @param useApiSearch { boolean } use this option if you want to use api to filter the results, necessary if you have 100+ places | floors.
585
+
586
+ const select = new Proximiio.Select('Places', { placeHolder: 'Pick the place', resultItem: { highlight: { render: true } } });
587
+ ```
588
+
589
+ #### Available Listeners
590
+
591
+ ##### Listen to select event
592
+ ```
593
+ select.getSelectListener().subscribe(place => {
594
+ console.log('place selected', place);
595
+ });
596
+ ```
597
+
598
+ ## Examples
599
+
600
+ ### Generate route on map with select components
601
+
602
+ JS
603
+ ```
604
+ // initiate map component
605
+ const map = new Proximiio.Map();
606
+
607
+ // listen to event when map component is loaded
608
+ map.getMapReadyListener().subscribe(() => {
609
+ let fromPoi = null;
610
+ let toPoi = null;
611
+
612
+ // initiate select component for starting point
613
+ const fromPoiSelect = new Proximiio.Select('Pois', { placeHolder: 'Pick the start poi', highlight: true, selector: '#from-poi-select' });
614
+
615
+ // listen to event when something is selected
616
+ fromPoiSelect.getSelectListener().subscribe(poi => {
617
+ fromPoi = poi;
618
+ map.centerToFeature(poi.id); // optional, this will centerize map to selected point
619
+ console.log('from poi selected', poi);
620
+ // generate route in case both start and end points are available
621
+ if (fromPoi && toPoi) {
622
+ map.findRouteByIds(fromPoi.id, toPoi.id);
623
+ }
624
+ })
625
+
626
+ // initiate select component for ending point
627
+ const toPoiSelect = new Proximiio.Select('Pois', { placeHolder: 'Pick the end poi', highlight: true, selector: '#to-poi-select' });
628
+
629
+ // listen to event when something is selected
630
+ toPoiSelect.getSelectListener().subscribe(poi => {
631
+ toPoi = poi;
632
+ map.centerToFeature(poi.id); // optional, this will centerize map to selected point
633
+ console.log('to poi selected', poi);
634
+ // generate route in case both start and end points are available
635
+ if (fromPoi && toPoi) {
636
+ map.findRouteByIds(fromPoi.id, toPoi.id);
637
+ }
638
+ })
639
+ })
640
+ ```
641
+
642
+ HTML
643
+ ```
644
+ <input id="from-poi-select" class="proximiio-select" type="text" tabIndex="1"/>
645
+ <input id="to-poi-select" class="proximiio-select" type="text" tabIndex="1"/>
646
+ ```
647
+
648
+ ### Adding new features and updating their positions
649
+ We are using some variables and turf to generate static data for demo purposes, you probably want to use your own api for that instead but the core idea of using `map.addCustomFeature()` to add feature to map and `map.updateFeature()` to update them, remains the same.
650
+
651
+
652
+ JS
653
+ ```
654
+ // lets assume you have a list of custom poi features
655
+ const customPoiList = [{
656
+ id: 'custom-poi-1',
657
+ title: 'Custom Poi',
658
+ level: 0
659
+ }, {
660
+ id: 'custom-poi-2',
661
+ title: 'Custom Poi 2',
662
+ level: 0
663
+ }, {
664
+ id: 'custom-poi-3',
665
+ title: 'Custom Poi 3',
666
+ level: 0
667
+ }, {
668
+ id: 'custom-poi-4',
669
+ title: 'Custom Poi 4',
670
+ level: 0
671
+ }, {
672
+ id: 'custom-poi-5',
673
+ title: 'Custom Poi 5',
674
+ level: 0
675
+ }];
676
+
677
+ // initiate map component
678
+ const map = new Proximiio.Map();
679
+
680
+ // listen to event when map component is loaded
681
+ map.getMapReadyListener().subscribe(res => {
682
+ console.log('map ready', res);
683
+
684
+ // get current mapbox instance bounds
685
+ let bounds = map.getMapboxInstance().getBounds();
686
+
687
+ // loop for each point of our features list
688
+ for (let poi of customPoiList) {
689
+ // for demo purposes we use turf to get random position based on the current map bounds
690
+ const position = turf.randomPosition([bounds._ne.lng, bounds._ne.lat, bounds._sw.lng, bounds._sw.lat]);
691
+
692
+ // finally add feature to map
693
+ map.addCustomFeature(poi.title, poi.level, position[1], position[0], '', poi.id);
694
+ }
695
+
696
+ // setting interval to update position each 5 seconds
697
+ setInterval(() => {
698
+ // again loop through the list of features
699
+ for (let poi of customPoiList) {
700
+ // use turf to get new random position
701
+ const position = turf.randomPosition([bounds._ne.lng, bounds._ne.lat, bounds._sw.lng, bounds._sw.lat]);
702
+
703
+ // update the feature position
704
+ map.updateFeature(poi.id, poi.title, poi.level, position[1], position[0]);
705
+ }
706
+ }, 5000);
707
+ });
708
+ ```
709
+
710
+ HTML
711
+ ```
712
+ <div id="proximiioMap" style="height: 500px;"></div>
713
+ ```
714
+
715
+ ## Build
716
+ In case of any changes of library itself (means at `./src` folder), you can rebuild with
717
+ ```
718
+ npm run build
719
+ ```