proximiio-js-library 1.8.4 → 1.9.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.
- package/README.md +192 -53
- package/lib/components/map/custom-layers.d.ts +9 -3
- package/lib/components/map/custom-layers.js +129 -93
- package/lib/components/map/layers/fill_extrusion_layer.d.ts +6 -6
- package/lib/components/map/layers/symbol_layer.d.ts +14 -14
- package/lib/components/map/main.d.ts +37 -8
- package/lib/components/map/main.js +131 -55
- package/lib/models/style.d.ts +1 -1
- package/lib/models/style.js +7 -2
- package/lib/proximiio.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,25 +1,33 @@
|
|
|
1
1
|
# Proximi.io JS Library
|
|
2
2
|
|
|
3
3
|
## Getting work
|
|
4
|
+
|
|
4
5
|
In case of cloning the repo from GitHub please run `npm install` afterwards.
|
|
5
6
|
|
|
6
7
|
### Using just in browser
|
|
8
|
+
|
|
7
9
|
This requires to load js file into script tag of html file.
|
|
10
|
+
|
|
8
11
|
```
|
|
9
12
|
<script src="lib/proximiio.js"></script>
|
|
10
13
|
```
|
|
11
14
|
|
|
12
15
|
### Using in node.js
|
|
16
|
+
|
|
13
17
|
```
|
|
14
18
|
const Proximiio = require('lib/index').default;
|
|
15
19
|
```
|
|
16
20
|
|
|
17
21
|
### Using with modern javascript frameworks (Angular, React)
|
|
22
|
+
|
|
18
23
|
Install with npm
|
|
24
|
+
|
|
19
25
|
```
|
|
20
26
|
npm install proximiio-js-library
|
|
21
27
|
```
|
|
28
|
+
|
|
22
29
|
and then import into project with
|
|
30
|
+
|
|
23
31
|
```
|
|
24
32
|
import Proximiio from 'proximiio-js-library'
|
|
25
33
|
```
|
|
@@ -27,6 +35,7 @@ import Proximiio from 'proximiio-js-library'
|
|
|
27
35
|
## Available methods
|
|
28
36
|
|
|
29
37
|
#### Log in
|
|
38
|
+
|
|
30
39
|
You can log in with email and password or with the token.
|
|
31
40
|
Successful log in is required for all other afterwards methods so execute this as soon as possible.
|
|
32
41
|
|
|
@@ -61,6 +70,7 @@ Proximiio.default.Auth.getUserConfig()
|
|
|
61
70
|
```
|
|
62
71
|
|
|
63
72
|
#### Get list of places
|
|
73
|
+
|
|
64
74
|
```
|
|
65
75
|
// node.js & react/angular
|
|
66
76
|
Proximiio.Places.getPlaces()
|
|
@@ -70,6 +80,7 @@ Proximiio.default.Places.getPlaces()
|
|
|
70
80
|
```
|
|
71
81
|
|
|
72
82
|
#### Get list of floors
|
|
83
|
+
|
|
73
84
|
```
|
|
74
85
|
// node.js & react/angular
|
|
75
86
|
Proximiio.Floors.getFloors()
|
|
@@ -79,7 +90,9 @@ Proximiio.default.Floors.getFloors()
|
|
|
79
90
|
```
|
|
80
91
|
|
|
81
92
|
###### Available arguments for lists
|
|
93
|
+
|
|
82
94
|
You can pass arguments to list calls for pagination, order, filtering in this order.
|
|
95
|
+
|
|
83
96
|
```
|
|
84
97
|
limit?: number, // total results to return
|
|
85
98
|
skip?: number, // how many results to skip from beginning
|
|
@@ -95,61 +108,76 @@ Map is generated using the [Mapbox GL library](https://docs.mapbox.com/mapbox-gl
|
|
|
95
108
|
|
|
96
109
|
```
|
|
97
110
|
<link href='https://api.mapbox.com/mapbox-gl-js/v1.12.0/mapbox-gl.css' rel='stylesheet' />
|
|
98
|
-
```
|
|
111
|
+
```
|
|
99
112
|
|
|
100
113
|
To generate map, create div element with id param defined
|
|
114
|
+
|
|
101
115
|
```
|
|
102
116
|
<div id="proximiioMap"></div>
|
|
103
117
|
```
|
|
118
|
+
|
|
104
119
|
Now you can call
|
|
120
|
+
|
|
105
121
|
```
|
|
106
122
|
const map = new Proximiio.Map({
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
123
|
+
selector: 'customMap', // optional, id of map container, default 'proximiioMap'
|
|
124
|
+
allowNewFeatureModal: false, // optional, if true, you'll be able to add new features via modal dialog, default false
|
|
125
|
+
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'
|
|
126
|
+
enableTBTNavigation: true, // optional, you'll receive turn-by-turn text navigation object in found route listener response, default: true
|
|
127
|
+
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/
|
|
128
|
+
defaultPlaceId: 'my_place_id', // optional, you can specify default place, if not specified the first place found will be used as default
|
|
129
|
+
zoomIntoPlace: false // optional, the map will center and zoom into the default place location, default: true
|
|
130
|
+
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)
|
|
131
|
+
kioskSettings: {
|
|
132
|
+
coordinates: [number, number], // coordinates for a kiosk start point
|
|
133
|
+
level: number // floor level of a kiosk starting point
|
|
118
134
|
},
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
135
|
+
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, you can customize polygon colors for different states via polygonsOptions
|
|
136
|
+
polygonsOptions: {
|
|
137
|
+
defaultPolygonColor: string; // optional, default: '#dbd7e8', default color of the polygons
|
|
138
|
+
hoverPolygonColor: string; // optional, default: '#a58dfa', hover color of the polygons
|
|
139
|
+
selectedPolygonColor: string; // optional, default: '#6945ed', selected color of the polygons
|
|
140
|
+
defaultLabelColor: string; // optional, default: '#6945ed', default color of the polygon labels
|
|
141
|
+
hoverLabelColor: string; // optional, default: '#fff', hover color of the polygon labels
|
|
142
|
+
selectedLabelColor: string; // optional, default: '#fff', selected color of the polygon labels
|
|
143
|
+
}
|
|
144
|
+
considerVisibilityParam: false, // optional, default: true, if enabled all pois with visibility property defined as 'hidden' will not be visible as default, will be possible to toggle them with toggleHiddenPois() method
|
|
145
|
+
fitBoundsPadding: 200, // optional, default 250, number | PaddingOptions, the amount of padding in pixels to add to the given bounds for found route, https://docs.mapbox.com/mapbox-gl-js/api/properties/#paddingoptions
|
|
146
|
+
minFitBoundsDistance: 50, // optional, default 15, number, the minimum route length in meters to zoom into it's bounds, if length is smaller regular center change will be used
|
|
147
|
+
showLevelDirectionIcon: false // optional, default: false, if enabled arrow icon will be shown at the levelchanger indicating direction of level change along the found route,
|
|
148
|
+
showRasterFloorplans: false // optional, default: false, if enabled raster floorplans will be visible,
|
|
149
|
+
animatedRoute: false // optional, default: false, EXPERIMENTAL, if enabled animated dot will be displayed along the route,
|
|
150
|
+
useRasterTiles: false, // optional, default: false, this will add raster tile source and layer with defined options from rasterTilesOptions
|
|
151
|
+
rasterTilesOptions: {
|
|
152
|
+
tilesUrl: string[], // mandatory
|
|
153
|
+
tileSize: number, // optional, default: 256,
|
|
154
|
+
minZoom: number, // optional, default: 15,
|
|
155
|
+
maxZoom: number, // optional, default: 22,
|
|
156
|
+
beforeLayer: string, // optional, default: 'proximiio-shop',
|
|
157
|
+
attribution: string, // optional
|
|
158
|
+
},
|
|
159
|
+
handleUrlParams: false, // optional, default: false, if enabled you can define place, start and destination features for routing in url params and library will handle those, you can change param names via urlParams option listed below
|
|
160
|
+
urlParams: {
|
|
137
161
|
startFeature: string, // optional, default: 'startFeature', library will search for the start feature by it's id or title defined within provided param
|
|
138
162
|
destinationFeature: string, // optional, default: 'destinationFeature', library will search for the destination feature by it's id or title defined within provided param
|
|
139
163
|
defaultPlace: string, // optional, default: 'defaultPlace', library will search for the place by it's id or title defined within provided param
|
|
140
|
-
|
|
141
|
-
|
|
164
|
+
},
|
|
165
|
+
useGpsLocation: false, // optional, default: false, if enabled your location will be detected with geolocation API and used as a starting point for routing
|
|
142
166
|
});
|
|
143
167
|
```
|
|
168
|
+
|
|
144
169
|
#### Initiating with url params
|
|
170
|
+
|
|
145
171
|
Library can handle some params from url in case you will enable `handleUrlParams` in map constructor. There's nothing else special required, just provide them in browser url like this as default:
|
|
146
172
|
|
|
147
173
|
`http://your-server/?startFeature=featureIdOrTitle&destinationFeature=featureIdOrTitle&defaultPlace=placeIdOrTitle`
|
|
148
174
|
|
|
149
175
|
#### Required Data for 3D Polygons
|
|
176
|
+
|
|
150
177
|
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.
|
|
151
178
|
|
|
152
179
|
Polygon Feature Example:
|
|
180
|
+
|
|
153
181
|
```
|
|
154
182
|
{
|
|
155
183
|
"type": "Feature",
|
|
@@ -173,7 +201,9 @@ Polygon Feature Example:
|
|
|
173
201
|
}
|
|
174
202
|
}
|
|
175
203
|
```
|
|
204
|
+
|
|
176
205
|
POI Feature Example:
|
|
206
|
+
|
|
177
207
|
```
|
|
178
208
|
{
|
|
179
209
|
"type": "Feature",
|
|
@@ -193,15 +223,19 @@ POI Feature Example:
|
|
|
193
223
|
}
|
|
194
224
|
}
|
|
195
225
|
```
|
|
226
|
+
|
|
196
227
|
#### Available Methods
|
|
197
228
|
|
|
198
229
|
##### Get the mapbpox instance
|
|
230
|
+
|
|
199
231
|
```
|
|
200
232
|
map.getMapboxInstance(); // this will return mapbox instance
|
|
201
233
|
```
|
|
202
234
|
|
|
203
235
|
##### Set active place
|
|
236
|
+
|
|
204
237
|
This method will set an active place, load floors etc. Have to be called after map is ready, see getMapReadyListener.
|
|
238
|
+
|
|
205
239
|
```
|
|
206
240
|
// @param placeId {string} Id of the place to be set as active on map
|
|
207
241
|
// @param zoomIntoPlace {boolean} should zoom into active place, optional
|
|
@@ -214,25 +248,35 @@ map.getMapReadyListener().subscribe(ready => {
|
|
|
214
248
|
```
|
|
215
249
|
|
|
216
250
|
##### Set active floor
|
|
251
|
+
|
|
217
252
|
Have to be called after map is ready, see getMapReadyListener.
|
|
253
|
+
|
|
218
254
|
###### by id
|
|
255
|
+
|
|
219
256
|
This method will set an active floor based on it's id.
|
|
257
|
+
|
|
220
258
|
```
|
|
221
259
|
map.getMapReadyListener().subscribe(ready => {
|
|
222
260
|
console.log('map ready', ready);
|
|
223
261
|
map.setFloorById(myFloorId);
|
|
224
262
|
});
|
|
225
263
|
```
|
|
264
|
+
|
|
226
265
|
###### by level
|
|
266
|
+
|
|
227
267
|
This method will set an active floor based on it's level.
|
|
268
|
+
|
|
228
269
|
```
|
|
229
270
|
map.getMapReadyListener().subscribe(ready => {
|
|
230
271
|
console.log('map ready', ready);
|
|
231
272
|
map.setFloorByLevel(0);
|
|
232
273
|
});
|
|
233
274
|
```
|
|
275
|
+
|
|
234
276
|
###### by way
|
|
277
|
+
|
|
235
278
|
This method will set an active floor based on the way of the next floor, e.g if we wanna go up or down.
|
|
279
|
+
|
|
236
280
|
```
|
|
237
281
|
map.getMapReadyListener().subscribe(ready => {
|
|
238
282
|
console.log('map ready', ready);
|
|
@@ -241,7 +285,9 @@ map.getMapReadyListener().subscribe(ready => {
|
|
|
241
285
|
```
|
|
242
286
|
|
|
243
287
|
#### Set new kiosk settings
|
|
288
|
+
|
|
244
289
|
With this method you can override kiosk coordinates position and it's floor level
|
|
290
|
+
|
|
245
291
|
```
|
|
246
292
|
const map = new Proximiio.Map({
|
|
247
293
|
isKiosk: true,
|
|
@@ -256,8 +302,10 @@ map.getMapReadyListener().subscribe(ready => {
|
|
|
256
302
|
});
|
|
257
303
|
```
|
|
258
304
|
|
|
259
|
-
#### Set different bounding box padding
|
|
305
|
+
#### Set different bounding box padding
|
|
306
|
+
|
|
260
307
|
This method will set padding for zooming into bounding box of found route
|
|
308
|
+
|
|
261
309
|
```
|
|
262
310
|
const map = new Proximiio.Map({
|
|
263
311
|
fitBoundsPadding: 200
|
|
@@ -271,7 +319,9 @@ map.getMapReadyListener().subscribe(ready => {
|
|
|
271
319
|
##### Find Route
|
|
272
320
|
|
|
273
321
|
###### by features id
|
|
322
|
+
|
|
274
323
|
This method will generate route based on selected features by their ids.
|
|
324
|
+
|
|
275
325
|
```
|
|
276
326
|
// @param idTo {string} finish feature id
|
|
277
327
|
// @param idFrom {string} start feature id, optional for kiosk
|
|
@@ -282,8 +332,11 @@ map.getMapReadyListener().subscribe(ready => {
|
|
|
282
332
|
map.findRouteByIds('idTo', 'idFrom');
|
|
283
333
|
});
|
|
284
334
|
```
|
|
335
|
+
|
|
285
336
|
###### by features title
|
|
337
|
+
|
|
286
338
|
This method will generate route based on selected features by their titles.
|
|
339
|
+
|
|
287
340
|
```
|
|
288
341
|
// @param titleTo {string} finish feature title
|
|
289
342
|
// @param titleFrom {string} start feature title, optional for kiosk
|
|
@@ -296,7 +349,9 @@ map.getMapReadyListener().subscribe(ready => {
|
|
|
296
349
|
```
|
|
297
350
|
|
|
298
351
|
###### by coords
|
|
352
|
+
|
|
299
353
|
This method will generate route based on attached coords.
|
|
354
|
+
|
|
300
355
|
```
|
|
301
356
|
// @param latTo {number} finish latitude coordinate
|
|
302
357
|
// @param lngTo {number} finish longitude coordinate
|
|
@@ -313,7 +368,9 @@ map.getMapReadyListener().subscribe(ready => {
|
|
|
313
368
|
```
|
|
314
369
|
|
|
315
370
|
###### by coords
|
|
371
|
+
|
|
316
372
|
This method will generate route based on attached coords.
|
|
373
|
+
|
|
317
374
|
```
|
|
318
375
|
// @param latTo {number} finish latitude coordinate
|
|
319
376
|
// @param lngTo {number} finish longitude coordinate
|
|
@@ -330,7 +387,9 @@ map.getMapReadyListener().subscribe(ready => {
|
|
|
330
387
|
```
|
|
331
388
|
|
|
332
389
|
###### by nearest amenity feature
|
|
390
|
+
|
|
333
391
|
This method will generate route based on nearest amenity feature.
|
|
392
|
+
|
|
334
393
|
```
|
|
335
394
|
// @param amenityId {string} amenity id of a nearest feature to look for
|
|
336
395
|
// @param idFrom {string} start feature id, optional for kiosk
|
|
@@ -343,7 +402,9 @@ map.getMapReadyListener().subscribe(ready => {
|
|
|
343
402
|
```
|
|
344
403
|
|
|
345
404
|
##### Cancel Route
|
|
405
|
+
|
|
346
406
|
Use this method to cancel generated route.
|
|
407
|
+
|
|
347
408
|
```
|
|
348
409
|
map.getMapReadyListener().subscribe(ready => {
|
|
349
410
|
console.log('map ready', ready);
|
|
@@ -352,7 +413,9 @@ map.getMapReadyListener().subscribe(ready => {
|
|
|
352
413
|
```
|
|
353
414
|
|
|
354
415
|
##### Get turn by turn navigation object
|
|
416
|
+
|
|
355
417
|
Retrieves the turn by turn navigation object.
|
|
418
|
+
|
|
356
419
|
```
|
|
357
420
|
map.getMapReadyListener().subscribe(ready => {
|
|
358
421
|
console.log('map ready', ready);
|
|
@@ -361,7 +424,9 @@ map.getMapReadyListener().subscribe(ready => {
|
|
|
361
424
|
```
|
|
362
425
|
|
|
363
426
|
##### Center to route
|
|
427
|
+
|
|
364
428
|
This method will center the map to generated route bounds.
|
|
429
|
+
|
|
365
430
|
```
|
|
366
431
|
map.getMapReadyListener().subscribe(ready => {
|
|
367
432
|
console.log('map ready', ready);
|
|
@@ -370,7 +435,9 @@ map.getMapReadyListener().subscribe(ready => {
|
|
|
370
435
|
```
|
|
371
436
|
|
|
372
437
|
##### Center to feature
|
|
438
|
+
|
|
373
439
|
This method will center the map to feature coordinates.
|
|
440
|
+
|
|
374
441
|
```
|
|
375
442
|
map.getMapReadyListener().subscribe(ready => {
|
|
376
443
|
console.log('map ready', ready);
|
|
@@ -379,12 +446,14 @@ map.getMapReadyListener().subscribe(ready => {
|
|
|
379
446
|
```
|
|
380
447
|
|
|
381
448
|
##### Center to coordinates
|
|
449
|
+
|
|
382
450
|
This method will center the map to provided coordinates.
|
|
451
|
+
|
|
383
452
|
```
|
|
384
453
|
// @param lat {number} latitude coordinate, required
|
|
385
454
|
// @param lng {number} longitude coordinate, required
|
|
386
455
|
// @param zoom {number} zoom level, optional, 18 as default
|
|
387
|
-
|
|
456
|
+
|
|
388
457
|
map.getMapReadyListener().subscribe(ready => {
|
|
389
458
|
console.log('map ready', ready);
|
|
390
459
|
map.centerToCoordinates(48.60678469647394, 17.833135351538658, 20);
|
|
@@ -392,8 +461,10 @@ map.getMapReadyListener().subscribe(ready => {
|
|
|
392
461
|
```
|
|
393
462
|
|
|
394
463
|
##### Toggle hidden poi visibility
|
|
464
|
+
|
|
395
465
|
This method will toggle hidden poi visibility based on the visibility param in poi properties.
|
|
396
|
-
|
|
466
|
+
|
|
467
|
+
```
|
|
397
468
|
map.getMapReadyListener().subscribe(ready => {
|
|
398
469
|
console.log('map ready', ready);
|
|
399
470
|
map.toggleHiddenPois();
|
|
@@ -401,8 +472,10 @@ map.getMapReadyListener().subscribe(ready => {
|
|
|
401
472
|
```
|
|
402
473
|
|
|
403
474
|
##### Toggle raster floorplans visibility
|
|
475
|
+
|
|
404
476
|
This method will toggle raster floorplans visibility.
|
|
405
|
-
|
|
477
|
+
|
|
478
|
+
```
|
|
406
479
|
map.getMapReadyListener().subscribe(ready => {
|
|
407
480
|
console.log('map ready', ready);
|
|
408
481
|
map.toggleRasterFloorplans();
|
|
@@ -410,7 +483,9 @@ map.getMapReadyListener().subscribe(ready => {
|
|
|
410
483
|
```
|
|
411
484
|
|
|
412
485
|
##### Add New Feature
|
|
486
|
+
|
|
413
487
|
Add new feature to map.
|
|
488
|
+
|
|
414
489
|
```
|
|
415
490
|
// @param title {string} feature title, required
|
|
416
491
|
// @param level {number} feature floor level, required
|
|
@@ -429,7 +504,9 @@ map.getMapReadyListener().subscribe(ready => {
|
|
|
429
504
|
```
|
|
430
505
|
|
|
431
506
|
##### Update Feature
|
|
507
|
+
|
|
432
508
|
Update existing map feature.
|
|
509
|
+
|
|
433
510
|
```
|
|
434
511
|
// @param id {string} feature id
|
|
435
512
|
// @param title {string} feature title, optional
|
|
@@ -448,7 +525,9 @@ map.getMapReadyListener().subscribe(ready => {
|
|
|
448
525
|
```
|
|
449
526
|
|
|
450
527
|
##### Delete Feature
|
|
528
|
+
|
|
451
529
|
Delete existing map feature.
|
|
530
|
+
|
|
452
531
|
```
|
|
453
532
|
// @param id {string} feature id
|
|
454
533
|
|
|
@@ -459,7 +538,9 @@ map.getMapReadyListener().subscribe(ready => {
|
|
|
459
538
|
```
|
|
460
539
|
|
|
461
540
|
##### Get list of added features
|
|
541
|
+
|
|
462
542
|
Retrieves the list of only newly added features.
|
|
543
|
+
|
|
463
544
|
```
|
|
464
545
|
map.getMapReadyListener().subscribe(ready => {
|
|
465
546
|
console.log('map ready', ready);
|
|
@@ -470,7 +551,9 @@ map.getMapReadyListener().subscribe(ready => {
|
|
|
470
551
|
##### Showing Person Icon
|
|
471
552
|
|
|
472
553
|
###### setPerson()
|
|
554
|
+
|
|
473
555
|
Method for setting a person icon on a Map, this method is resetting the previous state of all persons added before.
|
|
556
|
+
|
|
474
557
|
```
|
|
475
558
|
// @param lat {number} latitude coordinate of person.
|
|
476
559
|
// @param lng {number} longitude coordinate of person.
|
|
@@ -484,7 +567,9 @@ map.getMapReadyListener().subscribe(ready => {
|
|
|
484
567
|
```
|
|
485
568
|
|
|
486
569
|
###### upsertPerson()
|
|
570
|
+
|
|
487
571
|
Method for add/update person icon on a Map.
|
|
572
|
+
|
|
488
573
|
```
|
|
489
574
|
// @param lat {number} latitude coordinate of person.
|
|
490
575
|
// @param lng {number} longitude coordinate of person.
|
|
@@ -500,9 +585,12 @@ map.getMapReadyListener().subscribe(ready => {
|
|
|
500
585
|
##### Map Features Filtering
|
|
501
586
|
|
|
502
587
|
###### Setting new feature filter
|
|
503
|
-
|
|
588
|
+
|
|
589
|
+
With this method you set only defined poi feature to be visible, calling this method multiple times will set another feature to be visible without hiding the previous one, with inverted set to true defined feature will hide instead.
|
|
590
|
+
|
|
504
591
|
```
|
|
505
592
|
// param query {string} id or title of the feature
|
|
593
|
+
// param inverted {boolean} when set to true, defined feature will hide, optional
|
|
506
594
|
|
|
507
595
|
const map = new Proximiio.Map();
|
|
508
596
|
map.getMapReadyListener().subscribe(ready => {
|
|
@@ -512,9 +600,12 @@ map.getMapReadyListener().subscribe(ready => {
|
|
|
512
600
|
```
|
|
513
601
|
|
|
514
602
|
###### Removing created feature filter
|
|
603
|
+
|
|
515
604
|
Method for removing previously created feature filters.
|
|
605
|
+
|
|
516
606
|
```
|
|
517
607
|
// param query {string} id or title of the feature
|
|
608
|
+
// param inverted {boolean} have to be set to same value like it was in setFeatureFilter method, optional
|
|
518
609
|
|
|
519
610
|
const map = new Proximiio.Map();
|
|
520
611
|
map.getMapReadyListener().subscribe(ready => {
|
|
@@ -524,7 +615,9 @@ map.getMapReadyListener().subscribe(ready => {
|
|
|
524
615
|
```
|
|
525
616
|
|
|
526
617
|
###### Resetting all feature filters
|
|
618
|
+
|
|
527
619
|
Method for removing all active feature filters.
|
|
620
|
+
|
|
528
621
|
```
|
|
529
622
|
const map = new Proximiio.Map();
|
|
530
623
|
map.getMapReadyListener().subscribe(ready => {
|
|
@@ -533,38 +626,59 @@ map.getMapReadyListener().subscribe(ready => {
|
|
|
533
626
|
});
|
|
534
627
|
```
|
|
535
628
|
|
|
629
|
+
###### Hiding all pois features
|
|
630
|
+
|
|
631
|
+
Method for hiding all pois features on map.
|
|
632
|
+
|
|
633
|
+
```
|
|
634
|
+
const map = new Proximiio.Map();
|
|
635
|
+
map.getMapReadyListener().subscribe(ready => {
|
|
636
|
+
console.log('map ready', ready);
|
|
637
|
+
map.hidePois();
|
|
638
|
+
});
|
|
639
|
+
```
|
|
640
|
+
|
|
536
641
|
###### Setting new amenity filter
|
|
537
|
-
|
|
642
|
+
|
|
643
|
+
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. With inverted option set to true, defined amenity features will hide. Category and inverted options can't be defined at the same time.
|
|
538
644
|
|
|
539
645
|
```
|
|
540
646
|
// param amenityId {string} only features of defined amenityId will be visible
|
|
541
647
|
// 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
|
|
542
|
-
|
|
648
|
+
// param inverted {boolean} when set to true, defined amenity features will hide, optional
|
|
649
|
+
|
|
543
650
|
const map = new Proximiio.Map();
|
|
544
651
|
map.getMapReadyListener().subscribe(ready => {
|
|
545
652
|
console.log('map ready', ready);
|
|
546
653
|
map.setAmenityFilter('myamenity');
|
|
654
|
+
// inverted method
|
|
655
|
+
map.setAmenityFilter('myamenity', null, true);
|
|
547
656
|
});
|
|
548
657
|
```
|
|
549
658
|
|
|
550
659
|
###### Removing created amenity filter
|
|
660
|
+
|
|
551
661
|
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.
|
|
552
662
|
|
|
553
663
|
```
|
|
554
664
|
// param amenityId {string} remove the filter for a defined amenityId
|
|
555
665
|
// 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
|
|
556
|
-
|
|
666
|
+
// param inverted {boolean} have to be set to same value like it was in setAmenityFilter method, optional
|
|
667
|
+
|
|
557
668
|
const map = new Proximiio.Map();
|
|
558
669
|
map.getMapReadyListener().subscribe(ready => {
|
|
559
670
|
console.log('map ready', ready);
|
|
560
671
|
map.removeAmenityFilter('myamenity');
|
|
672
|
+
// remove inverted method
|
|
673
|
+
map.removeAmenityFilter('myamenity', null, true);
|
|
561
674
|
});
|
|
562
675
|
```
|
|
563
676
|
|
|
564
677
|
###### Resetting all amenity filters
|
|
678
|
+
|
|
565
679
|
Method for removing all active amenity filters.
|
|
566
680
|
|
|
567
|
-
```
|
|
681
|
+
```
|
|
568
682
|
const map = new Proximiio.Map();
|
|
569
683
|
map.getMapReadyListener().subscribe(ready => {
|
|
570
684
|
console.log('map ready', ready);
|
|
@@ -573,12 +687,13 @@ map.getMapReadyListener().subscribe(ready => {
|
|
|
573
687
|
```
|
|
574
688
|
|
|
575
689
|
###### Setting new amenities category
|
|
690
|
+
|
|
576
691
|
You can define your own categories of amenities, which you can then use for advanced filtering.
|
|
577
692
|
|
|
578
693
|
```
|
|
579
694
|
// param id {string} category id, have to be used when calling setAmenityFilter() method as second param.
|
|
580
695
|
// param amenities {Array of strings} list of the amenities id
|
|
581
|
-
|
|
696
|
+
|
|
582
697
|
const map = new Proximiio.Map();
|
|
583
698
|
map.getMapReadyListener().subscribe(ready => {
|
|
584
699
|
console.log('map ready', ready);
|
|
@@ -587,11 +702,12 @@ map.getMapReadyListener().subscribe(ready => {
|
|
|
587
702
|
```
|
|
588
703
|
|
|
589
704
|
###### Removing amenities category
|
|
705
|
+
|
|
590
706
|
Method for removing previously created categories.
|
|
591
707
|
|
|
592
708
|
```
|
|
593
709
|
// param id {string} category id.
|
|
594
|
-
|
|
710
|
+
|
|
595
711
|
const map = new Proximiio.Map();
|
|
596
712
|
map.getMapReadyListener().subscribe(ready => {
|
|
597
713
|
console.log('map ready', ready);
|
|
@@ -600,9 +716,10 @@ map.getMapReadyListener().subscribe(ready => {
|
|
|
600
716
|
```
|
|
601
717
|
|
|
602
718
|
###### Resetting all amenity categories
|
|
719
|
+
|
|
603
720
|
Method for removing all active amenity categories.
|
|
604
721
|
|
|
605
|
-
```
|
|
722
|
+
```
|
|
606
723
|
const map = new Proximiio.Map();
|
|
607
724
|
map.getMapReadyListener().subscribe(ready => {
|
|
608
725
|
console.log('map ready', ready);
|
|
@@ -613,6 +730,7 @@ map.getMapReadyListener().subscribe(ready => {
|
|
|
613
730
|
#### Available Listeners
|
|
614
731
|
|
|
615
732
|
##### Listen to map ready event
|
|
733
|
+
|
|
616
734
|
```
|
|
617
735
|
map.getMapReadyListener().subscribe(ready => {
|
|
618
736
|
console.log('map ready', ready);
|
|
@@ -620,6 +738,7 @@ map.getMapReadyListener().subscribe(ready => {
|
|
|
620
738
|
```
|
|
621
739
|
|
|
622
740
|
##### Listen to place select event
|
|
741
|
+
|
|
623
742
|
```
|
|
624
743
|
map.getPlaceSelectListener().subscribe(place => {
|
|
625
744
|
console.log('selected place', place);
|
|
@@ -627,6 +746,7 @@ map.getPlaceSelectListener().subscribe(place => {
|
|
|
627
746
|
```
|
|
628
747
|
|
|
629
748
|
##### Listen to floor select event
|
|
749
|
+
|
|
630
750
|
```
|
|
631
751
|
map.getFloorSelectListener().subscribe(floor => {
|
|
632
752
|
console.log('selected floor', floor);
|
|
@@ -634,6 +754,7 @@ map.getFloorSelectListener().subscribe(floor => {
|
|
|
634
754
|
```
|
|
635
755
|
|
|
636
756
|
##### Listen to route found event
|
|
757
|
+
|
|
637
758
|
```
|
|
638
759
|
map.getRouteFoundListener().subscribe(res => {
|
|
639
760
|
console.log('route found successfully', res.route);
|
|
@@ -642,6 +763,7 @@ map.getRouteFoundListener().subscribe(res => {
|
|
|
642
763
|
```
|
|
643
764
|
|
|
644
765
|
##### Listen to route failed event
|
|
766
|
+
|
|
645
767
|
```
|
|
646
768
|
map.getRouteFailedListener().subscribe(() => {
|
|
647
769
|
console.log('route not found');
|
|
@@ -649,6 +771,7 @@ map.getRouteFailedListener().subscribe(() => {
|
|
|
649
771
|
```
|
|
650
772
|
|
|
651
773
|
##### Listen to route cancel event
|
|
774
|
+
|
|
652
775
|
```
|
|
653
776
|
map.getRouteCancelListener().subscribe(() => {
|
|
654
777
|
console.log('route cancelled);
|
|
@@ -656,6 +779,7 @@ map.getRouteCancelListener().subscribe(() => {
|
|
|
656
779
|
```
|
|
657
780
|
|
|
658
781
|
##### Listen to feature add event
|
|
782
|
+
|
|
659
783
|
```
|
|
660
784
|
map.getFeatureAddListener().subscribe(feature => {
|
|
661
785
|
console.log('feature added', feature);
|
|
@@ -663,6 +787,7 @@ map.getFeatureAddListener().subscribe(feature => {
|
|
|
663
787
|
```
|
|
664
788
|
|
|
665
789
|
##### Listen to feature update event
|
|
790
|
+
|
|
666
791
|
```
|
|
667
792
|
map.getFeatureUpdateListener().subscribe(feature => {
|
|
668
793
|
console.log('feature updated', feature);
|
|
@@ -670,6 +795,7 @@ map.getFeatureUpdateListener().subscribe(feature => {
|
|
|
670
795
|
```
|
|
671
796
|
|
|
672
797
|
##### Listen to feature delete event
|
|
798
|
+
|
|
673
799
|
```
|
|
674
800
|
map.getFeatureDeleteListener().subscribe(() => {
|
|
675
801
|
console.log('feature deleted');
|
|
@@ -677,6 +803,7 @@ map.getFeatureDeleteListener().subscribe(() => {
|
|
|
677
803
|
```
|
|
678
804
|
|
|
679
805
|
##### Listen to polygon click event
|
|
806
|
+
|
|
680
807
|
```
|
|
681
808
|
map.getPolygonClickListener().subscribe((poi) => {
|
|
682
809
|
console.log('polygon clicked', poi);
|
|
@@ -684,6 +811,7 @@ map.getPolygonClickListener().subscribe((poi) => {
|
|
|
684
811
|
```
|
|
685
812
|
|
|
686
813
|
##### Listen to poi click event
|
|
814
|
+
|
|
687
815
|
```
|
|
688
816
|
map.getPoiClickListener().subscribe((poi) => {
|
|
689
817
|
console.log('poi clicked', poi);
|
|
@@ -691,6 +819,7 @@ map.getPoiClickListener().subscribe((poi) => {
|
|
|
691
819
|
```
|
|
692
820
|
|
|
693
821
|
##### Listen to persons update event
|
|
822
|
+
|
|
694
823
|
```
|
|
695
824
|
map.getPersonUpdateListener().subscribe((personsList) => {
|
|
696
825
|
console.log('current persons', personsList);
|
|
@@ -702,10 +831,13 @@ map.getPersonUpdateListener().subscribe((personsList) => {
|
|
|
702
831
|
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.
|
|
703
832
|
|
|
704
833
|
To generate select widget, create input element with id param defined, for styling please assign also class param.
|
|
834
|
+
|
|
705
835
|
```
|
|
706
836
|
<input id="proximiioSelect" class="proximiio-select" type="text" tabIndex="1"/>
|
|
707
837
|
```
|
|
838
|
+
|
|
708
839
|
Now you can call
|
|
840
|
+
|
|
709
841
|
```
|
|
710
842
|
// @param dataset { Datasets } predefined proximi.io dataset to search on, could be Places | Floors | Pois
|
|
711
843
|
// @param options { AutocompleteOptions } autocomplete.js options, check https://tarekraafat.github.io/autoComplete.js/#/configuration for more info
|
|
@@ -717,6 +849,7 @@ const select = new Proximiio.Select('Places', { placeHolder: 'Pick the place', r
|
|
|
717
849
|
#### Available Listeners
|
|
718
850
|
|
|
719
851
|
##### Listen to select event
|
|
852
|
+
|
|
720
853
|
```
|
|
721
854
|
select.getSelectListener().subscribe(place => {
|
|
722
855
|
console.log('place selected', place);
|
|
@@ -728,6 +861,7 @@ select.getSelectListener().subscribe(place => {
|
|
|
728
861
|
### Generate route on map with select components
|
|
729
862
|
|
|
730
863
|
JS
|
|
864
|
+
|
|
731
865
|
```
|
|
732
866
|
// initiate map component
|
|
733
867
|
const map = new Proximiio.Map();
|
|
@@ -736,10 +870,10 @@ const map = new Proximiio.Map();
|
|
|
736
870
|
map.getMapReadyListener().subscribe(() => {
|
|
737
871
|
let fromPoi = null;
|
|
738
872
|
let toPoi = null;
|
|
739
|
-
|
|
873
|
+
|
|
740
874
|
// initiate select component for starting point
|
|
741
875
|
const fromPoiSelect = new Proximiio.Select('Pois', { placeHolder: 'Pick the start poi', highlight: true, selector: '#from-poi-select' });
|
|
742
|
-
|
|
876
|
+
|
|
743
877
|
// listen to event when something is selected
|
|
744
878
|
fromPoiSelect.getSelectListener().subscribe(poi => {
|
|
745
879
|
fromPoi = poi;
|
|
@@ -750,10 +884,10 @@ map.getMapReadyListener().subscribe(() => {
|
|
|
750
884
|
map.findRouteByIds(fromPoi.id, toPoi.id);
|
|
751
885
|
}
|
|
752
886
|
})
|
|
753
|
-
|
|
887
|
+
|
|
754
888
|
// initiate select component for ending point
|
|
755
889
|
const toPoiSelect = new Proximiio.Select('Pois', { placeHolder: 'Pick the end poi', highlight: true, selector: '#to-poi-select' });
|
|
756
|
-
|
|
890
|
+
|
|
757
891
|
// listen to event when something is selected
|
|
758
892
|
toPoiSelect.getSelectListener().subscribe(poi => {
|
|
759
893
|
toPoi = poi;
|
|
@@ -768,16 +902,18 @@ map.getMapReadyListener().subscribe(() => {
|
|
|
768
902
|
```
|
|
769
903
|
|
|
770
904
|
HTML
|
|
905
|
+
|
|
771
906
|
```
|
|
772
907
|
<input id="from-poi-select" class="proximiio-select" type="text" tabIndex="1"/>
|
|
773
908
|
<input id="to-poi-select" class="proximiio-select" type="text" tabIndex="1"/>
|
|
774
909
|
```
|
|
775
910
|
|
|
776
911
|
### Adding new features and updating their positions
|
|
777
|
-
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.
|
|
778
912
|
|
|
913
|
+
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.
|
|
779
914
|
|
|
780
915
|
JS
|
|
916
|
+
|
|
781
917
|
```
|
|
782
918
|
// lets assume you have a list of custom poi features
|
|
783
919
|
const customPoiList = [{
|
|
@@ -808,15 +944,15 @@ const map = new Proximiio.Map();
|
|
|
808
944
|
// listen to event when map component is loaded
|
|
809
945
|
map.getMapReadyListener().subscribe(res => {
|
|
810
946
|
console.log('map ready', res);
|
|
811
|
-
|
|
947
|
+
|
|
812
948
|
// get current mapbox instance bounds
|
|
813
949
|
let bounds = map.getMapboxInstance().getBounds();
|
|
814
|
-
|
|
950
|
+
|
|
815
951
|
// loop for each point of our features list
|
|
816
952
|
for (let poi of customPoiList) {
|
|
817
953
|
// for demo purposes we use turf to get random position based on the current map bounds
|
|
818
954
|
const position = turf.randomPosition([bounds._ne.lng, bounds._ne.lat, bounds._sw.lng, bounds._sw.lat]);
|
|
819
|
-
|
|
955
|
+
|
|
820
956
|
// finally add feature to map
|
|
821
957
|
map.addCustomFeature(poi.title, poi.level, position[1], position[0], '', poi.id);
|
|
822
958
|
}
|
|
@@ -827,7 +963,7 @@ map.getMapReadyListener().subscribe(res => {
|
|
|
827
963
|
for (let poi of customPoiList) {
|
|
828
964
|
// use turf to get new random position
|
|
829
965
|
const position = turf.randomPosition([bounds._ne.lng, bounds._ne.lat, bounds._sw.lng, bounds._sw.lat]);
|
|
830
|
-
|
|
966
|
+
|
|
831
967
|
// update the feature position
|
|
832
968
|
map.updateFeature(poi.id, poi.title, poi.level, position[1], position[0]);
|
|
833
969
|
}
|
|
@@ -836,12 +972,15 @@ map.getMapReadyListener().subscribe(res => {
|
|
|
836
972
|
```
|
|
837
973
|
|
|
838
974
|
HTML
|
|
975
|
+
|
|
839
976
|
```
|
|
840
977
|
<div id="proximiioMap" style="height: 500px;"></div>
|
|
841
978
|
```
|
|
842
979
|
|
|
843
980
|
## Build
|
|
981
|
+
|
|
844
982
|
In case of any changes of library itself (means at `./src` folder), you can rebuild with
|
|
983
|
+
|
|
845
984
|
```
|
|
846
985
|
npm run build
|
|
847
986
|
```
|