venue-js 1.1.1 → 1.2.0-next.2
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/dist/index.d.mts +39 -126
- package/dist/index.d.ts +39 -126
- package/dist/index.js +307 -325
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +298 -318
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -79,7 +79,7 @@ var defaultFeatureQueryOptionsMap = {
|
|
|
79
79
|
};
|
|
80
80
|
|
|
81
81
|
// src/data/api/delivery-project.ts
|
|
82
|
-
async function
|
|
82
|
+
async function fetchDeliveryApi(projectId, apiKey, featureType, baseUrl = DEFAULT_BASE_URL) {
|
|
83
83
|
switch (featureType) {
|
|
84
84
|
case "label":
|
|
85
85
|
case "element": {
|
|
@@ -113,14 +113,78 @@ async function fetchFeature(projectId, apiKey, featureType, baseUrl = DEFAULT_BA
|
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
|
-
|
|
116
|
+
async function fetchPreviewApi(projectId, previewToken, featureType, baseUrl = DEFAULT_BASE_URL) {
|
|
117
|
+
switch (featureType) {
|
|
118
|
+
case "label":
|
|
119
|
+
case "element": {
|
|
120
|
+
const pluralFeatureType = `${featureType}s`;
|
|
121
|
+
const res = await fetch(
|
|
122
|
+
`${baseUrl}/preview/projects/${projectId}/${pluralFeatureType}.geojson`,
|
|
123
|
+
{
|
|
124
|
+
headers: {
|
|
125
|
+
Authorization: `Bearer ${previewToken}`
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
);
|
|
129
|
+
if (res.status !== 200) return [];
|
|
130
|
+
const items = await res.json();
|
|
131
|
+
return items;
|
|
132
|
+
}
|
|
133
|
+
case "sponsored-content": {
|
|
134
|
+
const res = await fetch(
|
|
135
|
+
`${baseUrl}/preview/projects/${projectId}/sponsored-content.json`,
|
|
136
|
+
{
|
|
137
|
+
headers: {
|
|
138
|
+
Authorization: `Bearer ${previewToken}`
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
);
|
|
142
|
+
if (res.status !== 200) return [];
|
|
143
|
+
const jsonRes = await res.json();
|
|
144
|
+
const items = jsonRes.data;
|
|
145
|
+
return items.map((item) => ({
|
|
146
|
+
id: item.id,
|
|
147
|
+
...item.attributes
|
|
148
|
+
}));
|
|
149
|
+
}
|
|
150
|
+
default: {
|
|
151
|
+
const res = await fetch(
|
|
152
|
+
`${baseUrl}/preview/projects/${projectId}/imdf/${featureType}.geojson`,
|
|
153
|
+
{
|
|
154
|
+
headers: {
|
|
155
|
+
Authorization: `Bearer ${previewToken}`
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
);
|
|
159
|
+
if (res.status !== 200) return [];
|
|
160
|
+
const collections = await res.json();
|
|
161
|
+
return collections.features;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
var safeFetchFeature = async (featureType, params) => {
|
|
166
|
+
const mode = params.mode ?? "delivery";
|
|
167
|
+
const projectId = params.projectId;
|
|
168
|
+
const apiKey = params.apiKey;
|
|
169
|
+
const previewToken = params.previewToken;
|
|
170
|
+
const baseUrl = params.baseUrl ?? DEFAULT_BASE_URL;
|
|
117
171
|
try {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
172
|
+
let result = [];
|
|
173
|
+
if (mode === "delivery") {
|
|
174
|
+
result = await fetchDeliveryApi(
|
|
175
|
+
projectId,
|
|
176
|
+
apiKey,
|
|
177
|
+
featureType,
|
|
178
|
+
baseUrl
|
|
179
|
+
);
|
|
180
|
+
} else if (mode === "preview") {
|
|
181
|
+
result = await fetchPreviewApi(
|
|
182
|
+
projectId,
|
|
183
|
+
previewToken,
|
|
184
|
+
featureType,
|
|
185
|
+
baseUrl
|
|
186
|
+
);
|
|
187
|
+
}
|
|
124
188
|
return result ?? [];
|
|
125
189
|
} catch (e) {
|
|
126
190
|
return Promise.resolve([]);
|
|
@@ -402,18 +466,22 @@ function matchFilters(item, filters) {
|
|
|
402
466
|
var getDataClient = (options) => {
|
|
403
467
|
const observers = /* @__PURE__ */ new Map();
|
|
404
468
|
const queryClient = options.queryClient ?? new QueryClient();
|
|
405
|
-
const { projectId, apiKey, baseUrl } = options;
|
|
469
|
+
const { mode = "delivery", projectId, apiKey, baseUrl, previewToken } = options;
|
|
406
470
|
if (!projectId)
|
|
407
471
|
throw new Error(
|
|
408
472
|
"Cannot create VenueDataClient. Reason: `projectId` is missing"
|
|
409
473
|
);
|
|
410
|
-
if (!apiKey)
|
|
474
|
+
if (mode === "delivery" && !apiKey)
|
|
411
475
|
throw new Error(
|
|
412
476
|
"Cannot create VenueDataClient. Reason: `apiKey` is missing"
|
|
413
477
|
);
|
|
478
|
+
if (mode === "preview" && !previewToken)
|
|
479
|
+
throw new Error(
|
|
480
|
+
"Cannot create VenueDataClient. Reason: `previewToken` is missing"
|
|
481
|
+
);
|
|
414
482
|
const createDeliveryApiQueryOptions = (featureType) => ({
|
|
415
483
|
queryKey: ["_deliveryapi", featureType],
|
|
416
|
-
queryFn: () => safeFetchFeature(projectId, apiKey,
|
|
484
|
+
queryFn: () => safeFetchFeature(featureType, { mode, projectId, apiKey, previewToken, baseUrl })
|
|
417
485
|
});
|
|
418
486
|
const internalFilterByType = async (featureType) => {
|
|
419
487
|
try {
|
|
@@ -525,7 +593,6 @@ import {
|
|
|
525
593
|
ui as ui3,
|
|
526
594
|
Map as Map2,
|
|
527
595
|
TileLayer,
|
|
528
|
-
Extent,
|
|
529
596
|
LineString as LineString3,
|
|
530
597
|
Marker as Marker2,
|
|
531
598
|
Coordinate as Coordinate4
|
|
@@ -611,132 +678,6 @@ function isNumber(num) {
|
|
|
611
678
|
// src/IndoorMap/IndoorMap.ts
|
|
612
679
|
import turfDistance from "@turf/distance";
|
|
613
680
|
import turfCenter3 from "@turf/center";
|
|
614
|
-
|
|
615
|
-
// ../../node_modules/@turf/meta/dist/esm/index.js
|
|
616
|
-
function coordEach(geojson, callback, excludeWrapCoord) {
|
|
617
|
-
if (geojson === null) return;
|
|
618
|
-
var j, k, l, geometry, stopG, coords, geometryMaybeCollection, wrapShrink = 0, coordIndex = 0, isGeometryCollection, type = geojson.type, isFeatureCollection = type === "FeatureCollection", isFeature = type === "Feature", stop = isFeatureCollection ? geojson.features.length : 1;
|
|
619
|
-
for (var featureIndex = 0; featureIndex < stop; featureIndex++) {
|
|
620
|
-
geometryMaybeCollection = isFeatureCollection ? geojson.features[featureIndex].geometry : isFeature ? geojson.geometry : geojson;
|
|
621
|
-
isGeometryCollection = geometryMaybeCollection ? geometryMaybeCollection.type === "GeometryCollection" : false;
|
|
622
|
-
stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1;
|
|
623
|
-
for (var geomIndex = 0; geomIndex < stopG; geomIndex++) {
|
|
624
|
-
var multiFeatureIndex = 0;
|
|
625
|
-
var geometryIndex = 0;
|
|
626
|
-
geometry = isGeometryCollection ? geometryMaybeCollection.geometries[geomIndex] : geometryMaybeCollection;
|
|
627
|
-
if (geometry === null) continue;
|
|
628
|
-
coords = geometry.coordinates;
|
|
629
|
-
var geomType = geometry.type;
|
|
630
|
-
wrapShrink = excludeWrapCoord && (geomType === "Polygon" || geomType === "MultiPolygon") ? 1 : 0;
|
|
631
|
-
switch (geomType) {
|
|
632
|
-
case null:
|
|
633
|
-
break;
|
|
634
|
-
case "Point":
|
|
635
|
-
if (callback(
|
|
636
|
-
coords,
|
|
637
|
-
coordIndex,
|
|
638
|
-
featureIndex,
|
|
639
|
-
multiFeatureIndex,
|
|
640
|
-
geometryIndex
|
|
641
|
-
) === false)
|
|
642
|
-
return false;
|
|
643
|
-
coordIndex++;
|
|
644
|
-
multiFeatureIndex++;
|
|
645
|
-
break;
|
|
646
|
-
case "LineString":
|
|
647
|
-
case "MultiPoint":
|
|
648
|
-
for (j = 0; j < coords.length; j++) {
|
|
649
|
-
if (callback(
|
|
650
|
-
coords[j],
|
|
651
|
-
coordIndex,
|
|
652
|
-
featureIndex,
|
|
653
|
-
multiFeatureIndex,
|
|
654
|
-
geometryIndex
|
|
655
|
-
) === false)
|
|
656
|
-
return false;
|
|
657
|
-
coordIndex++;
|
|
658
|
-
if (geomType === "MultiPoint") multiFeatureIndex++;
|
|
659
|
-
}
|
|
660
|
-
if (geomType === "LineString") multiFeatureIndex++;
|
|
661
|
-
break;
|
|
662
|
-
case "Polygon":
|
|
663
|
-
case "MultiLineString":
|
|
664
|
-
for (j = 0; j < coords.length; j++) {
|
|
665
|
-
for (k = 0; k < coords[j].length - wrapShrink; k++) {
|
|
666
|
-
if (callback(
|
|
667
|
-
coords[j][k],
|
|
668
|
-
coordIndex,
|
|
669
|
-
featureIndex,
|
|
670
|
-
multiFeatureIndex,
|
|
671
|
-
geometryIndex
|
|
672
|
-
) === false)
|
|
673
|
-
return false;
|
|
674
|
-
coordIndex++;
|
|
675
|
-
}
|
|
676
|
-
if (geomType === "MultiLineString") multiFeatureIndex++;
|
|
677
|
-
if (geomType === "Polygon") geometryIndex++;
|
|
678
|
-
}
|
|
679
|
-
if (geomType === "Polygon") multiFeatureIndex++;
|
|
680
|
-
break;
|
|
681
|
-
case "MultiPolygon":
|
|
682
|
-
for (j = 0; j < coords.length; j++) {
|
|
683
|
-
geometryIndex = 0;
|
|
684
|
-
for (k = 0; k < coords[j].length; k++) {
|
|
685
|
-
for (l = 0; l < coords[j][k].length - wrapShrink; l++) {
|
|
686
|
-
if (callback(
|
|
687
|
-
coords[j][k][l],
|
|
688
|
-
coordIndex,
|
|
689
|
-
featureIndex,
|
|
690
|
-
multiFeatureIndex,
|
|
691
|
-
geometryIndex
|
|
692
|
-
) === false)
|
|
693
|
-
return false;
|
|
694
|
-
coordIndex++;
|
|
695
|
-
}
|
|
696
|
-
geometryIndex++;
|
|
697
|
-
}
|
|
698
|
-
multiFeatureIndex++;
|
|
699
|
-
}
|
|
700
|
-
break;
|
|
701
|
-
case "GeometryCollection":
|
|
702
|
-
for (j = 0; j < geometry.geometries.length; j++)
|
|
703
|
-
if (coordEach(geometry.geometries[j], callback, excludeWrapCoord) === false)
|
|
704
|
-
return false;
|
|
705
|
-
break;
|
|
706
|
-
default:
|
|
707
|
-
throw new Error("Unknown Geometry Type");
|
|
708
|
-
}
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
// ../../node_modules/@turf/bbox/dist/esm/index.js
|
|
714
|
-
function bbox(geojson, options = {}) {
|
|
715
|
-
if (geojson.bbox != null && true !== options.recompute) {
|
|
716
|
-
return geojson.bbox;
|
|
717
|
-
}
|
|
718
|
-
const result = [Infinity, Infinity, -Infinity, -Infinity];
|
|
719
|
-
coordEach(geojson, (coord) => {
|
|
720
|
-
if (result[0] > coord[0]) {
|
|
721
|
-
result[0] = coord[0];
|
|
722
|
-
}
|
|
723
|
-
if (result[1] > coord[1]) {
|
|
724
|
-
result[1] = coord[1];
|
|
725
|
-
}
|
|
726
|
-
if (result[2] < coord[0]) {
|
|
727
|
-
result[2] = coord[0];
|
|
728
|
-
}
|
|
729
|
-
if (result[3] < coord[1]) {
|
|
730
|
-
result[3] = coord[1];
|
|
731
|
-
}
|
|
732
|
-
});
|
|
733
|
-
return result;
|
|
734
|
-
}
|
|
735
|
-
var index_default = bbox;
|
|
736
|
-
|
|
737
|
-
// src/IndoorMap/IndoorMap.ts
|
|
738
|
-
import scale from "@turf/transform-scale";
|
|
739
|
-
import bboxPolygon from "@turf/bbox-polygon";
|
|
740
681
|
import { PerspectiveCamera } from "three";
|
|
741
682
|
|
|
742
683
|
// src/IndoorMap/constants.ts
|
|
@@ -2942,8 +2883,133 @@ var createHighlighExtrudeObjectController = (obj, { color }) => {
|
|
|
2942
2883
|
};
|
|
2943
2884
|
|
|
2944
2885
|
// src/IndoorMap/camera/CameraManager.ts
|
|
2945
|
-
|
|
2946
|
-
|
|
2886
|
+
import { Extent } from "maptalks";
|
|
2887
|
+
|
|
2888
|
+
// ../../node_modules/@turf/meta/dist/esm/index.js
|
|
2889
|
+
function coordEach(geojson, callback, excludeWrapCoord) {
|
|
2890
|
+
if (geojson === null) return;
|
|
2891
|
+
var j, k, l, geometry, stopG, coords, geometryMaybeCollection, wrapShrink = 0, coordIndex = 0, isGeometryCollection, type = geojson.type, isFeatureCollection = type === "FeatureCollection", isFeature = type === "Feature", stop = isFeatureCollection ? geojson.features.length : 1;
|
|
2892
|
+
for (var featureIndex = 0; featureIndex < stop; featureIndex++) {
|
|
2893
|
+
geometryMaybeCollection = isFeatureCollection ? geojson.features[featureIndex].geometry : isFeature ? geojson.geometry : geojson;
|
|
2894
|
+
isGeometryCollection = geometryMaybeCollection ? geometryMaybeCollection.type === "GeometryCollection" : false;
|
|
2895
|
+
stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1;
|
|
2896
|
+
for (var geomIndex = 0; geomIndex < stopG; geomIndex++) {
|
|
2897
|
+
var multiFeatureIndex = 0;
|
|
2898
|
+
var geometryIndex = 0;
|
|
2899
|
+
geometry = isGeometryCollection ? geometryMaybeCollection.geometries[geomIndex] : geometryMaybeCollection;
|
|
2900
|
+
if (geometry === null) continue;
|
|
2901
|
+
coords = geometry.coordinates;
|
|
2902
|
+
var geomType = geometry.type;
|
|
2903
|
+
wrapShrink = excludeWrapCoord && (geomType === "Polygon" || geomType === "MultiPolygon") ? 1 : 0;
|
|
2904
|
+
switch (geomType) {
|
|
2905
|
+
case null:
|
|
2906
|
+
break;
|
|
2907
|
+
case "Point":
|
|
2908
|
+
if (callback(
|
|
2909
|
+
coords,
|
|
2910
|
+
coordIndex,
|
|
2911
|
+
featureIndex,
|
|
2912
|
+
multiFeatureIndex,
|
|
2913
|
+
geometryIndex
|
|
2914
|
+
) === false)
|
|
2915
|
+
return false;
|
|
2916
|
+
coordIndex++;
|
|
2917
|
+
multiFeatureIndex++;
|
|
2918
|
+
break;
|
|
2919
|
+
case "LineString":
|
|
2920
|
+
case "MultiPoint":
|
|
2921
|
+
for (j = 0; j < coords.length; j++) {
|
|
2922
|
+
if (callback(
|
|
2923
|
+
coords[j],
|
|
2924
|
+
coordIndex,
|
|
2925
|
+
featureIndex,
|
|
2926
|
+
multiFeatureIndex,
|
|
2927
|
+
geometryIndex
|
|
2928
|
+
) === false)
|
|
2929
|
+
return false;
|
|
2930
|
+
coordIndex++;
|
|
2931
|
+
if (geomType === "MultiPoint") multiFeatureIndex++;
|
|
2932
|
+
}
|
|
2933
|
+
if (geomType === "LineString") multiFeatureIndex++;
|
|
2934
|
+
break;
|
|
2935
|
+
case "Polygon":
|
|
2936
|
+
case "MultiLineString":
|
|
2937
|
+
for (j = 0; j < coords.length; j++) {
|
|
2938
|
+
for (k = 0; k < coords[j].length - wrapShrink; k++) {
|
|
2939
|
+
if (callback(
|
|
2940
|
+
coords[j][k],
|
|
2941
|
+
coordIndex,
|
|
2942
|
+
featureIndex,
|
|
2943
|
+
multiFeatureIndex,
|
|
2944
|
+
geometryIndex
|
|
2945
|
+
) === false)
|
|
2946
|
+
return false;
|
|
2947
|
+
coordIndex++;
|
|
2948
|
+
}
|
|
2949
|
+
if (geomType === "MultiLineString") multiFeatureIndex++;
|
|
2950
|
+
if (geomType === "Polygon") geometryIndex++;
|
|
2951
|
+
}
|
|
2952
|
+
if (geomType === "Polygon") multiFeatureIndex++;
|
|
2953
|
+
break;
|
|
2954
|
+
case "MultiPolygon":
|
|
2955
|
+
for (j = 0; j < coords.length; j++) {
|
|
2956
|
+
geometryIndex = 0;
|
|
2957
|
+
for (k = 0; k < coords[j].length; k++) {
|
|
2958
|
+
for (l = 0; l < coords[j][k].length - wrapShrink; l++) {
|
|
2959
|
+
if (callback(
|
|
2960
|
+
coords[j][k][l],
|
|
2961
|
+
coordIndex,
|
|
2962
|
+
featureIndex,
|
|
2963
|
+
multiFeatureIndex,
|
|
2964
|
+
geometryIndex
|
|
2965
|
+
) === false)
|
|
2966
|
+
return false;
|
|
2967
|
+
coordIndex++;
|
|
2968
|
+
}
|
|
2969
|
+
geometryIndex++;
|
|
2970
|
+
}
|
|
2971
|
+
multiFeatureIndex++;
|
|
2972
|
+
}
|
|
2973
|
+
break;
|
|
2974
|
+
case "GeometryCollection":
|
|
2975
|
+
for (j = 0; j < geometry.geometries.length; j++)
|
|
2976
|
+
if (coordEach(geometry.geometries[j], callback, excludeWrapCoord) === false)
|
|
2977
|
+
return false;
|
|
2978
|
+
break;
|
|
2979
|
+
default:
|
|
2980
|
+
throw new Error("Unknown Geometry Type");
|
|
2981
|
+
}
|
|
2982
|
+
}
|
|
2983
|
+
}
|
|
2984
|
+
}
|
|
2985
|
+
|
|
2986
|
+
// ../../node_modules/@turf/bbox/dist/esm/index.js
|
|
2987
|
+
function bbox(geojson, options = {}) {
|
|
2988
|
+
if (geojson.bbox != null && true !== options.recompute) {
|
|
2989
|
+
return geojson.bbox;
|
|
2990
|
+
}
|
|
2991
|
+
const result = [Infinity, Infinity, -Infinity, -Infinity];
|
|
2992
|
+
coordEach(geojson, (coord) => {
|
|
2993
|
+
if (result[0] > coord[0]) {
|
|
2994
|
+
result[0] = coord[0];
|
|
2995
|
+
}
|
|
2996
|
+
if (result[1] > coord[1]) {
|
|
2997
|
+
result[1] = coord[1];
|
|
2998
|
+
}
|
|
2999
|
+
if (result[2] < coord[0]) {
|
|
3000
|
+
result[2] = coord[0];
|
|
3001
|
+
}
|
|
3002
|
+
if (result[3] < coord[1]) {
|
|
3003
|
+
result[3] = coord[1];
|
|
3004
|
+
}
|
|
3005
|
+
});
|
|
3006
|
+
return result;
|
|
3007
|
+
}
|
|
3008
|
+
var index_default = bbox;
|
|
3009
|
+
|
|
3010
|
+
// src/IndoorMap/camera/CameraManager.ts
|
|
3011
|
+
import scale from "@turf/transform-scale";
|
|
3012
|
+
import bboxPolygon from "@turf/bbox-polygon";
|
|
2947
3013
|
var CameraManager = class {
|
|
2948
3014
|
map;
|
|
2949
3015
|
constructor(map, options) {
|
|
@@ -2952,67 +3018,55 @@ var CameraManager = class {
|
|
|
2952
3018
|
this.setView(options?.defaultView);
|
|
2953
3019
|
}
|
|
2954
3020
|
}
|
|
2955
|
-
/** Private method */
|
|
2956
|
-
#animateflyTo(viewOptions = {}, options = {}, callbackOption = () => {
|
|
2957
|
-
}) {
|
|
2958
|
-
const { start, end } = {
|
|
2959
|
-
start: (frame) => {
|
|
2960
|
-
},
|
|
2961
|
-
end: (frame) => {
|
|
2962
|
-
},
|
|
2963
|
-
...callbackOption
|
|
2964
|
-
};
|
|
2965
|
-
this.map.flyTo(viewOptions, options, (frame) => {
|
|
2966
|
-
if (frame.state.playState === "running" && frame.state.progress === 0)
|
|
2967
|
-
start(frame);
|
|
2968
|
-
if (frame.state.playState === "finished") end(frame);
|
|
2969
|
-
});
|
|
2970
|
-
}
|
|
2971
3021
|
/** Public methods */
|
|
2972
3022
|
getView = () => {
|
|
2973
3023
|
return this.map.getView();
|
|
2974
3024
|
};
|
|
2975
|
-
getZoom = () => {
|
|
2976
|
-
return this.map.getView().zoom;
|
|
2977
|
-
};
|
|
2978
3025
|
setView = (value) => {
|
|
2979
3026
|
this.map.setView(value);
|
|
2980
3027
|
};
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
const {
|
|
2984
|
-
zoom = ZOOM_OUT_LEVEL,
|
|
2985
|
-
pitch = 60,
|
|
2986
|
-
duration = 600,
|
|
2987
|
-
easing = "out",
|
|
2988
|
-
bearing = currentView.bearing
|
|
2989
|
-
} = options;
|
|
2990
|
-
this.#animateflyTo(
|
|
2991
|
-
{
|
|
2992
|
-
center: center2,
|
|
2993
|
-
zoom,
|
|
2994
|
-
pitch,
|
|
2995
|
-
bearing
|
|
2996
|
-
},
|
|
2997
|
-
{ duration, easing }
|
|
2998
|
-
);
|
|
3028
|
+
animateTo = (view, options = {}, step) => {
|
|
3029
|
+
this.map.animateTo(view, options, step);
|
|
2999
3030
|
};
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
} = options;
|
|
3007
|
-
this.#animateflyTo(
|
|
3008
|
-
{
|
|
3009
|
-
center: centerPoint,
|
|
3010
|
-
zoom,
|
|
3011
|
-
pitch
|
|
3012
|
-
},
|
|
3013
|
-
{ duration, easing }
|
|
3031
|
+
setMaxExtent(extent) {
|
|
3032
|
+
return this.map.setMaxExtent(extent);
|
|
3033
|
+
}
|
|
3034
|
+
getFeatureExtent = (feature2, scaleFactor = 1) => {
|
|
3035
|
+
const [minX, minY, maxX, maxY] = index_default(
|
|
3036
|
+
scale(bboxPolygon(index_default(feature2)), scaleFactor)
|
|
3014
3037
|
);
|
|
3038
|
+
return new Extent(minX, minY, maxX, maxY);
|
|
3039
|
+
};
|
|
3040
|
+
getExtentZoom = (extent, options = {
|
|
3041
|
+
isFraction: false,
|
|
3042
|
+
padding: {
|
|
3043
|
+
paddingLeft: 0,
|
|
3044
|
+
paddingRight: 0,
|
|
3045
|
+
paddingTop: 0,
|
|
3046
|
+
paddingBottom: 0
|
|
3047
|
+
}
|
|
3048
|
+
}) => {
|
|
3049
|
+
const { isFraction = false, padding } = options;
|
|
3050
|
+
return this.map.getFitZoom(extent, isFraction, padding);
|
|
3015
3051
|
};
|
|
3052
|
+
set maxZoom(value) {
|
|
3053
|
+
this.map.setMaxZoom(value);
|
|
3054
|
+
const spatialReference = {
|
|
3055
|
+
projection: "EPSG:3857",
|
|
3056
|
+
resolutions: (function() {
|
|
3057
|
+
const resolutions = [];
|
|
3058
|
+
const d = 2 * 6378137 * Math.PI;
|
|
3059
|
+
for (let i = 0; i < value; i++) {
|
|
3060
|
+
resolutions[i] = d / (256 * Math.pow(2, i));
|
|
3061
|
+
}
|
|
3062
|
+
return resolutions;
|
|
3063
|
+
})()
|
|
3064
|
+
};
|
|
3065
|
+
this.map.setSpatialReference(spatialReference);
|
|
3066
|
+
}
|
|
3067
|
+
set minZoom(value) {
|
|
3068
|
+
this.map.setMinZoom(value);
|
|
3069
|
+
}
|
|
3016
3070
|
};
|
|
3017
3071
|
|
|
3018
3072
|
// src/IndoorMap/renderer/RendererManager.ts
|
|
@@ -3314,41 +3368,45 @@ var Element3DRenderer = class extends EventTarget {
|
|
|
3314
3368
|
} = getGeometryOption(feature2, this.options);
|
|
3315
3369
|
const _this = this;
|
|
3316
3370
|
const createPolygon = (geometry, feature3) => {
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3371
|
+
try {
|
|
3372
|
+
const [outerRing, ...innerRings] = geometry.coordinates;
|
|
3373
|
+
const offsetFeature = offset !== 0 ? turfBuffer2(geometry, offset, { units: "meters" }) : feature3;
|
|
3374
|
+
const color = feature3.properties.style.polygonFill ?? colorOptions ?? "#ffffff";
|
|
3375
|
+
if (color === "transparent") return;
|
|
3376
|
+
const material = this.getOrCreateMaterialByColor(color);
|
|
3377
|
+
const altitude = feature3.properties.ordinal * HEIGHT_METER;
|
|
3378
|
+
const height = feature3.properties.height ?? heightOptions ?? HEIGHT_METER;
|
|
3379
|
+
const bottomHeight = feature3.properties.bottomHeight ?? bottomHeightOptions ?? 0;
|
|
3380
|
+
const extrudedPolygon = this.threeLayer.toExtrudePolygon(
|
|
3381
|
+
offsetFeature,
|
|
3382
|
+
{ asynchronous: true, ...options, height, bottomHeight, altitude },
|
|
3383
|
+
material
|
|
3384
|
+
);
|
|
3385
|
+
extrudedPolygon.on("click", (e) => {
|
|
3386
|
+
console.log(e.target.options.polygon.id);
|
|
3387
|
+
});
|
|
3388
|
+
const topLineStrings = [
|
|
3389
|
+
new maptalks4.LineString(outerRing),
|
|
3390
|
+
...innerRings.map((innerRing) => new maptalks4.LineString(innerRing))
|
|
3391
|
+
];
|
|
3392
|
+
const topLines = this.threeLayer.toLines(
|
|
3393
|
+
topLineStrings,
|
|
3394
|
+
{ altitude, bottomHeight: bottomHeight + height + 1e-3, interactive: false },
|
|
3395
|
+
this.lineMaterial
|
|
3396
|
+
);
|
|
3397
|
+
const bottomLineStrings = [
|
|
3398
|
+
new maptalks4.LineString(outerRing),
|
|
3399
|
+
...innerRings.map((innerRing) => new maptalks4.LineString(innerRing))
|
|
3400
|
+
];
|
|
3401
|
+
const bottomLines = this.threeLayer.toLines(
|
|
3402
|
+
bottomLineStrings,
|
|
3403
|
+
{ altitude, bottomHeight, interactive: false },
|
|
3404
|
+
this.lineMaterial
|
|
3405
|
+
);
|
|
3406
|
+
return [extrudedPolygon, topLines, bottomLines];
|
|
3407
|
+
} catch (err) {
|
|
3408
|
+
throw new Error(`Cannot create polygon, ${err.message}`);
|
|
3409
|
+
}
|
|
3352
3410
|
};
|
|
3353
3411
|
try {
|
|
3354
3412
|
switch (feature2.geometry.type) {
|
|
@@ -3368,7 +3426,7 @@ var Element3DRenderer = class extends EventTarget {
|
|
|
3368
3426
|
}
|
|
3369
3427
|
}
|
|
3370
3428
|
} catch (err) {
|
|
3371
|
-
console.log(`error createGeometry`, { feature: feature2, options });
|
|
3429
|
+
console.log(`error createGeometry`, err, { feature: feature2, options });
|
|
3372
3430
|
}
|
|
3373
3431
|
};
|
|
3374
3432
|
async createEscalator(f, coordinate, options) {
|
|
@@ -3938,6 +3996,8 @@ var RendererManager = class extends EventTarget {
|
|
|
3938
3996
|
}
|
|
3939
3997
|
const thisOrdinal = escalator.properties.ordinal;
|
|
3940
3998
|
const relationship = escalatorRelationships[0];
|
|
3999
|
+
if (!relationship.properties.origin?.id) throw new Error(`relationship (id=${relationship.id}) - origin not exists`);
|
|
4000
|
+
if (!relationship.properties.destination?.id) throw new Error(`relationship (id=${relationship.id}) - destination not exists`);
|
|
3941
4001
|
const bothOpeningIds = [relationship.properties.origin.id, relationship.properties.destination.id];
|
|
3942
4002
|
const bothOpenings = await Promise.all(
|
|
3943
4003
|
bothOpeningIds.map((id) => this.#dataClient.findById("opening", id, { populate: true }))
|
|
@@ -3953,7 +4013,7 @@ var RendererManager = class extends EventTarget {
|
|
|
3953
4013
|
this.addElementsToManager(escalator.id, _elements, escalator.properties.ordinal);
|
|
3954
4014
|
}
|
|
3955
4015
|
} catch (err) {
|
|
3956
|
-
console.log(`cannot create escalator`, err);
|
|
4016
|
+
console.log(`cannot create escalator`, err.message);
|
|
3957
4017
|
}
|
|
3958
4018
|
}
|
|
3959
4019
|
this.changeLevelByOrdinal(this.currentOrdinals);
|
|
@@ -4089,7 +4149,7 @@ var IndoorMap = class extends EventTarget {
|
|
|
4089
4149
|
layers: []
|
|
4090
4150
|
});
|
|
4091
4151
|
this.rendererManager = new RendererManager(this.map, options.dataClient, options.renderer);
|
|
4092
|
-
this.camera = new CameraManager(this.map);
|
|
4152
|
+
this.camera = new CameraManager(this.map, options.camera);
|
|
4093
4153
|
this.locale = locale;
|
|
4094
4154
|
this.pixelRatio = pixelRatio;
|
|
4095
4155
|
this.onMapReady = onMapReady;
|
|
@@ -4107,12 +4167,12 @@ var IndoorMap = class extends EventTarget {
|
|
|
4107
4167
|
this.camera.setView({ center: center2, pitch: 60, zoom: 19 });
|
|
4108
4168
|
});
|
|
4109
4169
|
}
|
|
4110
|
-
on(eventName, handler) {
|
|
4111
|
-
this.map.on(eventName, handler);
|
|
4112
|
-
}
|
|
4113
4170
|
/**
|
|
4114
4171
|
* Events
|
|
4115
4172
|
*/
|
|
4173
|
+
on(eventName, handler) {
|
|
4174
|
+
this.map.on(eventName, handler);
|
|
4175
|
+
}
|
|
4116
4176
|
handleMapClick = ({ coordinate }) => {
|
|
4117
4177
|
const { x, y } = coordinate;
|
|
4118
4178
|
console.log(
|
|
@@ -4168,40 +4228,12 @@ var IndoorMap = class extends EventTarget {
|
|
|
4168
4228
|
this.map.off("moveend", this.#findAndSetVenueInView);
|
|
4169
4229
|
}
|
|
4170
4230
|
}
|
|
4171
|
-
get ordinals() {
|
|
4172
|
-
return this.#ordinals || [];
|
|
4173
|
-
}
|
|
4174
|
-
set ordinals(value) {
|
|
4175
|
-
if (!Array.isArray(value)) throw new Error("ordinals must be Array");
|
|
4176
|
-
this.#ordinals = value;
|
|
4177
|
-
}
|
|
4178
4231
|
set billboards(value) {
|
|
4179
4232
|
this.#billboards = value;
|
|
4180
4233
|
}
|
|
4181
|
-
set mapConfig(value) {
|
|
4182
|
-
this.#mapConfig = value;
|
|
4183
|
-
}
|
|
4184
4234
|
set mapDecorations(value) {
|
|
4185
4235
|
this.#mapDecorations = value;
|
|
4186
4236
|
}
|
|
4187
|
-
set maxZoom(value) {
|
|
4188
|
-
this.map.setMaxZoom(value);
|
|
4189
|
-
const spatialReference = {
|
|
4190
|
-
projection: "EPSG:3857",
|
|
4191
|
-
resolutions: (function() {
|
|
4192
|
-
const resolutions = [];
|
|
4193
|
-
const d = 2 * 6378137 * Math.PI;
|
|
4194
|
-
for (let i = 0; i < value; i++) {
|
|
4195
|
-
resolutions[i] = d / (256 * Math.pow(2, i));
|
|
4196
|
-
}
|
|
4197
|
-
return resolutions;
|
|
4198
|
-
})()
|
|
4199
|
-
};
|
|
4200
|
-
this.map.setSpatialReference(spatialReference);
|
|
4201
|
-
}
|
|
4202
|
-
set minZoom(value) {
|
|
4203
|
-
this.map.setMinZoom(value);
|
|
4204
|
-
}
|
|
4205
4237
|
set groundLabels(value) {
|
|
4206
4238
|
this.#groundLabels = value;
|
|
4207
4239
|
}
|
|
@@ -4237,9 +4269,6 @@ var IndoorMap = class extends EventTarget {
|
|
|
4237
4269
|
this.#onClickElement(e);
|
|
4238
4270
|
this.#isClicked = false;
|
|
4239
4271
|
};
|
|
4240
|
-
setCenter(center2, padding) {
|
|
4241
|
-
this.map.setCenter(center2, padding);
|
|
4242
|
-
}
|
|
4243
4272
|
async #legacy_createElements() {
|
|
4244
4273
|
const {
|
|
4245
4274
|
// 2D
|
|
@@ -4461,7 +4490,7 @@ var IndoorMap = class extends EventTarget {
|
|
|
4461
4490
|
const {
|
|
4462
4491
|
geometry: { coordinates }
|
|
4463
4492
|
} = turfCenter3(feature2);
|
|
4464
|
-
this.camera.
|
|
4493
|
+
this.camera.animateTo({ center: coordinates, pitch: 45 });
|
|
4465
4494
|
});
|
|
4466
4495
|
object3ds.push(object);
|
|
4467
4496
|
this.#objects.push(object);
|
|
@@ -4544,27 +4573,6 @@ var IndoorMap = class extends EventTarget {
|
|
|
4544
4573
|
changeLevelByOrdinal(ordinal) {
|
|
4545
4574
|
this.rendererManager.changeLevelByOrdinal(ordinal);
|
|
4546
4575
|
}
|
|
4547
|
-
getFeatureExtent = (feature2, scaleFactor = 1) => {
|
|
4548
|
-
const [minX, minY, maxX, maxY] = index_default(
|
|
4549
|
-
scale(bboxPolygon(index_default(feature2)), scaleFactor)
|
|
4550
|
-
);
|
|
4551
|
-
return new Extent(minX, minY, maxX, maxY);
|
|
4552
|
-
};
|
|
4553
|
-
getExtentCenter = (extent) => {
|
|
4554
|
-
return extent.getCenter();
|
|
4555
|
-
};
|
|
4556
|
-
getExtentZoom = (extent, options = {
|
|
4557
|
-
isFraction: false,
|
|
4558
|
-
padding: {
|
|
4559
|
-
paddingLeft: 0,
|
|
4560
|
-
paddingRight: 0,
|
|
4561
|
-
paddingTop: 0,
|
|
4562
|
-
paddingBottom: 0
|
|
4563
|
-
}
|
|
4564
|
-
}) => {
|
|
4565
|
-
const { isFraction = false, padding } = options;
|
|
4566
|
-
return this.map.getFitZoom(extent, isFraction, padding);
|
|
4567
|
-
};
|
|
4568
4576
|
findVenueInView = () => {
|
|
4569
4577
|
const mapCenter = this.map.getCenter();
|
|
4570
4578
|
const result = this.#venues.reduce((closest, venue) => {
|
|
@@ -4577,9 +4585,6 @@ var IndoorMap = class extends EventTarget {
|
|
|
4577
4585
|
}, null);
|
|
4578
4586
|
return result;
|
|
4579
4587
|
};
|
|
4580
|
-
flyTo = (center2, options) => {
|
|
4581
|
-
this.camera.flyTo(center2, options);
|
|
4582
|
-
};
|
|
4583
4588
|
getLineStringBearing = (feature2) => {
|
|
4584
4589
|
const { geometry } = feature2;
|
|
4585
4590
|
const path = new LineString3(geometry.coordinates);
|
|
@@ -5095,33 +5100,6 @@ var IndoorMap = class extends EventTarget {
|
|
|
5095
5100
|
/**
|
|
5096
5101
|
* render (frame)
|
|
5097
5102
|
*/
|
|
5098
|
-
getTargetViewCenter = (targetView, options = { offset: { top: 0, left: 0, right: 0, bottom: 0 } }) => {
|
|
5099
|
-
const map = this.map;
|
|
5100
|
-
const { offset } = options;
|
|
5101
|
-
const { top = 0, left = 0, right = 0, bottom = 0 } = offset;
|
|
5102
|
-
const originalState = {
|
|
5103
|
-
bearing: map.getBearing(),
|
|
5104
|
-
center: map.getCenter(),
|
|
5105
|
-
pitch: map.getPitch(),
|
|
5106
|
-
zoom: map.getZoom()
|
|
5107
|
-
};
|
|
5108
|
-
const finalView = {
|
|
5109
|
-
bearing: _6.isNil(targetView.bearing) ? map.getBearing() : targetView.bearing,
|
|
5110
|
-
center: _6.isNil(targetView.center) ? map.getCenter() : targetView.center,
|
|
5111
|
-
pitch: _6.isNil(targetView.pitch) ? map.getPitch() : targetView.pitch,
|
|
5112
|
-
zoom: _6.isNil(targetView.zoom) ? map.getZoom() : targetView.zoom
|
|
5113
|
-
};
|
|
5114
|
-
map.setView(finalView);
|
|
5115
|
-
const projectedTargetCenter = map.coordinateToContainerPoint(finalView.center).add(right / 2 - left / 2, bottom / 2 - top / 2);
|
|
5116
|
-
const adjustedTargetCenter = map.containerPointToCoordinate(
|
|
5117
|
-
projectedTargetCenter
|
|
5118
|
-
);
|
|
5119
|
-
map.setView(originalState);
|
|
5120
|
-
return adjustedTargetCenter;
|
|
5121
|
-
};
|
|
5122
|
-
setMaxExtent(extent) {
|
|
5123
|
-
return this.map.setMaxExtent(extent);
|
|
5124
|
-
}
|
|
5125
5103
|
render() {
|
|
5126
5104
|
const view = this.map.getView();
|
|
5127
5105
|
const currBearing = view.bearing;
|
|
@@ -5130,7 +5108,8 @@ var IndoorMap = class extends EventTarget {
|
|
|
5130
5108
|
this.threeLayer.redraw();
|
|
5131
5109
|
}
|
|
5132
5110
|
if (this.threeLayer) {
|
|
5133
|
-
const
|
|
5111
|
+
const currentView = this.camera.getView();
|
|
5112
|
+
const objectOpacity = _6.clamp(38 - 2 * currentView.zoom, 0, 1);
|
|
5134
5113
|
this.#objects.forEach((object) => {
|
|
5135
5114
|
object.getObject3d().traverse((child) => {
|
|
5136
5115
|
if (child.isMesh) child.material.opacity = objectOpacity;
|
|
@@ -5141,7 +5120,7 @@ var IndoorMap = class extends EventTarget {
|
|
|
5141
5120
|
if (this.#billboardObjects) {
|
|
5142
5121
|
this.#billboardObjects.forEach((object) => {
|
|
5143
5122
|
const objectScale = _6.clamp(
|
|
5144
|
-
20 - 1 *
|
|
5123
|
+
20 - 1 * currentView.zoom,
|
|
5145
5124
|
1,
|
|
5146
5125
|
1.05
|
|
5147
5126
|
);
|
|
@@ -5202,7 +5181,8 @@ export {
|
|
|
5202
5181
|
createSpriteMaterialByLabelSymbol,
|
|
5203
5182
|
createStyledUIMarkerElement,
|
|
5204
5183
|
defaultFeatureQueryOptionsMap,
|
|
5205
|
-
|
|
5184
|
+
fetchDeliveryApi,
|
|
5185
|
+
fetchPreviewApi,
|
|
5206
5186
|
getBearingBetweenPoints,
|
|
5207
5187
|
getCenterFromGeometry,
|
|
5208
5188
|
getDataClient,
|