proximiio-js-library 1.14.13 → 1.14.15
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 +10 -1
- package/lib/common.d.ts +3 -1
- package/lib/common.js +33 -1
- package/lib/components/map/main.d.ts +2 -0
- package/lib/components/map/main.js +22 -1
- package/lib/proximiio.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -461,7 +461,16 @@ const map = new Proximiio.Map({
|
|
|
461
461
|
|
|
462
462
|
// Only features within defined bounds will be retrieved from API, optional
|
|
463
463
|
// [[topleft lng, lat], [bottomright lng, lat]]
|
|
464
|
-
featuresMaxBounds: [[-73.9876, 40.7661], [-73.9397, 40.8002]]
|
|
464
|
+
featuresMaxBounds: [[-73.9876, 40.7661], [-73.9397, 40.8002]],
|
|
465
|
+
|
|
466
|
+
// If defined map data will be fetched from the defined url
|
|
467
|
+
bundleUrl: 'https://your-data.com/bundle',
|
|
468
|
+
|
|
469
|
+
// Map features will be fetched with parallel request queue from the bundle url
|
|
470
|
+
bundlePaginate: true,
|
|
471
|
+
|
|
472
|
+
// Map features will be fetched with parallel request queue from the api
|
|
473
|
+
apiPaginate: true
|
|
465
474
|
});
|
|
466
475
|
```
|
|
467
476
|
|
package/lib/common.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import Feature from './models/feature';
|
|
2
|
+
import { LngLatBoundsLike } from 'maplibre-gl';
|
|
2
3
|
export declare const axios: import("axios").AxiosInstance;
|
|
3
4
|
export declare const camelToKebab: (input: string) => string;
|
|
4
5
|
export declare const kebabToCamel: (input: string) => string;
|
|
@@ -36,4 +37,5 @@ declare const optimizeFeatures: (features: Feature[]) => {
|
|
|
36
37
|
properties: any;
|
|
37
38
|
}[];
|
|
38
39
|
declare const isLevelChanger: (poi: Feature) => boolean;
|
|
39
|
-
|
|
40
|
+
declare const pointInBounds: (point: [number, number], bounds: LngLatBoundsLike) => boolean;
|
|
41
|
+
export { calculateDimensions, convertToRTL, base64toBlob, throttle, filterByAmenity, validateLabelLine, optimizeFeatures, isLevelChanger, pointInBounds, };
|
package/lib/common.js
CHANGED
|
@@ -263,4 +263,36 @@ const isRamp = (poi) => {
|
|
|
263
263
|
const isLevelChanger = (poi) => {
|
|
264
264
|
return isElevator(poi) || isEscalator(poi) || isStairCase(poi) || isRamp(poi);
|
|
265
265
|
};
|
|
266
|
-
|
|
266
|
+
const pointInBounds = (point, bounds) => {
|
|
267
|
+
let minLng;
|
|
268
|
+
let minLat;
|
|
269
|
+
let maxLng;
|
|
270
|
+
let maxLat;
|
|
271
|
+
// Normalize bounds to [minLng, minLat, maxLng, maxLat]
|
|
272
|
+
if (Array.isArray(bounds[0])) {
|
|
273
|
+
// [[west, south], [east, north]]
|
|
274
|
+
const b = bounds;
|
|
275
|
+
minLng = Math.min(b[0][0], b[1][0]);
|
|
276
|
+
minLat = Math.min(b[0][1], b[1][1]);
|
|
277
|
+
maxLng = Math.max(b[0][0], b[1][0]);
|
|
278
|
+
maxLat = Math.max(b[0][1], b[1][1]);
|
|
279
|
+
}
|
|
280
|
+
else if (Array.isArray(bounds) && bounds.length === 4) {
|
|
281
|
+
// [west, south, east, north]
|
|
282
|
+
[minLng, minLat, maxLng, maxLat] = bounds;
|
|
283
|
+
}
|
|
284
|
+
else if (typeof bounds.getWest === 'function') {
|
|
285
|
+
// Mapbox's LngLatBounds instance
|
|
286
|
+
const b = bounds;
|
|
287
|
+
minLng = b.getWest();
|
|
288
|
+
minLat = b.getSouth();
|
|
289
|
+
maxLng = b.getEast();
|
|
290
|
+
maxLat = b.getNorth();
|
|
291
|
+
}
|
|
292
|
+
else {
|
|
293
|
+
throw new Error('Invalid bounds format');
|
|
294
|
+
}
|
|
295
|
+
const [lng, lat] = point;
|
|
296
|
+
return lng >= minLng && lng <= maxLng && lat >= minLat && lat <= maxLat;
|
|
297
|
+
};
|
|
298
|
+
export { calculateDimensions, convertToRTL, base64toBlob, throttle, filterByAmenity, validateLabelLine, optimizeFeatures, isLevelChanger, pointInBounds, };
|
|
@@ -178,6 +178,8 @@ export interface Options {
|
|
|
178
178
|
autoTrigger?: boolean;
|
|
179
179
|
autoLocate?: boolean;
|
|
180
180
|
position?: 'top-right' | 'top-left' | 'bottom-left' | 'bottom-right';
|
|
181
|
+
zoom?: number;
|
|
182
|
+
maxBounds?: LngLatBoundsLike;
|
|
181
183
|
};
|
|
182
184
|
language?: string;
|
|
183
185
|
routeColor?: string;
|
|
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import maplibregl from 'maplibre-gl';
|
|
11
|
-
import { axios, optimizeFeatures } from '../../common';
|
|
11
|
+
import { axios, optimizeFeatures, pointInBounds } from '../../common';
|
|
12
12
|
import { addFeatures, deleteFeatures, getAmenities, getAmenitiesBundle, getFeatures, getFeaturesBundle, } from '../../controllers/geo';
|
|
13
13
|
import { PlaceModel } from '../../models/place';
|
|
14
14
|
import { FloorModel } from '../../models/floor';
|
|
@@ -232,6 +232,7 @@ export class Map {
|
|
|
232
232
|
autoTrigger: true,
|
|
233
233
|
autoLocate: true,
|
|
234
234
|
position: 'top-right',
|
|
235
|
+
zoom: 17,
|
|
235
236
|
},
|
|
236
237
|
language: 'en',
|
|
237
238
|
routeWithDetails: true,
|
|
@@ -1164,6 +1165,9 @@ export class Map {
|
|
|
1164
1165
|
},
|
|
1165
1166
|
showAccuracyCircle: false,
|
|
1166
1167
|
trackUserLocation: true,
|
|
1168
|
+
fitBoundsOptions: {
|
|
1169
|
+
maxZoom: this.defaultOptions.geolocationControlOptions.zoom,
|
|
1170
|
+
},
|
|
1167
1171
|
});
|
|
1168
1172
|
this.map.addControl(geolocate, this.defaultOptions.geolocationControlOptions.position);
|
|
1169
1173
|
if (this.defaultOptions.geolocationControlOptions.autoTrigger) {
|
|
@@ -1187,9 +1191,26 @@ export class Map {
|
|
|
1187
1191
|
});
|
|
1188
1192
|
}
|
|
1189
1193
|
geolocate.on('geolocate', (data) => {
|
|
1194
|
+
if (this.defaultOptions.geolocationControlOptions.maxBounds &&
|
|
1195
|
+
!pointInBounds([data.coords.longitude, data.coords.latitude], this.defaultOptions.geolocationControlOptions.maxBounds)) {
|
|
1196
|
+
this.map.stop();
|
|
1197
|
+
return;
|
|
1198
|
+
}
|
|
1190
1199
|
this.startPoint = point([data.coords.longitude, data.coords.latitude], {
|
|
1191
1200
|
level: this.state.floor.level,
|
|
1192
1201
|
});
|
|
1202
|
+
this.map.flyTo({
|
|
1203
|
+
center: [data.coords.longitude, data.coords.latitude],
|
|
1204
|
+
zoom: this.defaultOptions.geolocationControlOptions.zoom,
|
|
1205
|
+
});
|
|
1206
|
+
});
|
|
1207
|
+
geolocate.on('trackuserlocationstart', (data) => {
|
|
1208
|
+
const position = data.target._lastKnownPosition.coords;
|
|
1209
|
+
if (this.defaultOptions.geolocationControlOptions.maxBounds &&
|
|
1210
|
+
!pointInBounds([position.longitude, position.latitude], this.defaultOptions.geolocationControlOptions.maxBounds)) {
|
|
1211
|
+
this.map.stop();
|
|
1212
|
+
return;
|
|
1213
|
+
}
|
|
1193
1214
|
});
|
|
1194
1215
|
}
|
|
1195
1216
|
}
|