@aibee/crc-bmap 0.3.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/bmap.cjs.min.js +7 -7
- package/lib/bmap.cjs.min.js.map +3 -3
- package/lib/bmap.esm.js +67 -21
- package/lib/bmap.esm.js.map +2 -2
- package/lib/bmap.esm.min.js +8 -8
- package/lib/bmap.esm.min.js.map +3 -3
- package/lib/bmap.min.js +7 -7
- package/lib/bmap.min.js.map +3 -3
- package/lib/src/loader/AibeeLoader/index.d.ts +3 -1
- package/lib/src/utils/index-db.d.ts +1 -1
- package/package.json +1 -1
package/lib/bmap.esm.js
CHANGED
|
@@ -5374,7 +5374,7 @@ var MergeGraphic = class extends Object3D13 {
|
|
|
5374
5374
|
this.geometry = this.initGeometry();
|
|
5375
5375
|
this.initMaterial();
|
|
5376
5376
|
this.initMesh();
|
|
5377
|
-
this.mesh.position.z = this.options[0].deltaHeight;
|
|
5377
|
+
this.mesh.position.z = this.options[0].deltaHeight + this.options[0].airHeight;
|
|
5378
5378
|
if (this.options[0].strokeOpacity !== 0) {
|
|
5379
5379
|
this.initLineMaterial();
|
|
5380
5380
|
this.initLineGeometry();
|
|
@@ -9442,8 +9442,17 @@ var BMapSelect = class extends Plugin {
|
|
|
9442
9442
|
};
|
|
9443
9443
|
onBoxSelected = ({ list }) => {
|
|
9444
9444
|
this._list.clear();
|
|
9445
|
+
this._poiList.clear();
|
|
9445
9446
|
list.forEach((item) => {
|
|
9446
|
-
this.
|
|
9447
|
+
if (this.options.elements.includes("graphic")) {
|
|
9448
|
+
this._list.add(item);
|
|
9449
|
+
}
|
|
9450
|
+
if (this.options.elements.includes("poi")) {
|
|
9451
|
+
const poi = this.bmap.getPoiById(item.options.id);
|
|
9452
|
+
if (poi) {
|
|
9453
|
+
this._poiList.add(poi);
|
|
9454
|
+
}
|
|
9455
|
+
}
|
|
9447
9456
|
});
|
|
9448
9457
|
this.selectEnd();
|
|
9449
9458
|
};
|
|
@@ -10602,12 +10611,12 @@ async function downloadFileToJson(fileId, config) {
|
|
|
10602
10611
|
|
|
10603
10612
|
// src/utils/index-db.ts
|
|
10604
10613
|
var _db;
|
|
10605
|
-
function createDb(database = "aibee_map") {
|
|
10614
|
+
function createDb(database = "aibee_map", version = 1) {
|
|
10606
10615
|
return new Promise((resolve, reject) => {
|
|
10607
10616
|
if (_db) {
|
|
10608
10617
|
return resolve({ db: _db, type: "success" });
|
|
10609
10618
|
}
|
|
10610
|
-
const request = indexedDB.open(database);
|
|
10619
|
+
const request = indexedDB.open(database, version);
|
|
10611
10620
|
request.onupgradeneeded = function(event) {
|
|
10612
10621
|
_db = event.target.result;
|
|
10613
10622
|
console.log("onupgradeneeded");
|
|
@@ -10647,9 +10656,10 @@ function set(storeName, key, value, db = _db) {
|
|
|
10647
10656
|
if (!db) {
|
|
10648
10657
|
reject("\u6CA1\u6709db");
|
|
10649
10658
|
}
|
|
10650
|
-
return new Promise((resolve2, reject2) => {
|
|
10659
|
+
return new Promise(async (resolve2, reject2) => {
|
|
10660
|
+
const has = await get(storeName, key);
|
|
10651
10661
|
const objectStore = db.transaction([storeName], "readwrite").objectStore(storeName);
|
|
10652
|
-
const request = objectStore.add({ key, value });
|
|
10662
|
+
const request = has !== null ? objectStore.put({ key, value }) : objectStore.add({ key, value });
|
|
10653
10663
|
request.onsuccess = function(event) {
|
|
10654
10664
|
resolve2(event);
|
|
10655
10665
|
};
|
|
@@ -10687,8 +10697,10 @@ var defaultAibeeLoaderOption = {
|
|
|
10687
10697
|
};
|
|
10688
10698
|
var MapVersionStoreName = "map_version";
|
|
10689
10699
|
var RouteVersionStoreName = "route_version";
|
|
10700
|
+
var FacilityVersionStoreName = "facility_version";
|
|
10690
10701
|
var MapDataStoreName = "map_data";
|
|
10691
10702
|
var RoadNetworkDataStoreName = "road_network_data";
|
|
10703
|
+
var FacilityDataStoreName = "facility_data";
|
|
10692
10704
|
var ParkingTypeIconMap = {
|
|
10693
10705
|
half: half_default,
|
|
10694
10706
|
power: power_default,
|
|
@@ -10697,24 +10709,28 @@ var ParkingTypeIconMap = {
|
|
|
10697
10709
|
var AibeeLoader = class {
|
|
10698
10710
|
constructor(bmap) {
|
|
10699
10711
|
this.bmap = bmap;
|
|
10700
|
-
this.initDb();
|
|
10712
|
+
this.initDbPromise = this.initDb();
|
|
10701
10713
|
}
|
|
10702
10714
|
floors = [];
|
|
10715
|
+
initDbPromise = Promise.resolve();
|
|
10716
|
+
db = null;
|
|
10703
10717
|
async initDb() {
|
|
10704
10718
|
try {
|
|
10705
|
-
const { db, type } = await createDb();
|
|
10719
|
+
const { db, type } = await createDb("aibee_map", 2);
|
|
10706
10720
|
if (type === "onupgradeneeded") {
|
|
10707
10721
|
createStore(MapVersionStoreName);
|
|
10708
10722
|
createStore(RouteVersionStoreName);
|
|
10723
|
+
createStore(FacilityVersionStoreName);
|
|
10709
10724
|
createStore(MapDataStoreName);
|
|
10710
10725
|
createStore(RoadNetworkDataStoreName);
|
|
10726
|
+
createStore(FacilityDataStoreName);
|
|
10711
10727
|
}
|
|
10728
|
+
this.db = db;
|
|
10712
10729
|
} catch (e) {
|
|
10713
10730
|
console.log("[\u6253\u5F00indexDb\u9519\u8BEF]", e);
|
|
10714
10731
|
}
|
|
10715
10732
|
}
|
|
10716
10733
|
async load(data) {
|
|
10717
|
-
this.clear();
|
|
10718
10734
|
if (Array.isArray(data)) {
|
|
10719
10735
|
this.floors = data;
|
|
10720
10736
|
} else {
|
|
@@ -10725,10 +10741,10 @@ var AibeeLoader = class {
|
|
|
10725
10741
|
}
|
|
10726
10742
|
}
|
|
10727
10743
|
setCacheData(storeName, key, data) {
|
|
10728
|
-
return set(storeName, `${key}`, data);
|
|
10744
|
+
return this.initDbPromise.then(() => set(storeName, `${key}`, data, this.db));
|
|
10729
10745
|
}
|
|
10730
10746
|
getCacheData(storeName, key) {
|
|
10731
|
-
return get(storeName, `${key}
|
|
10747
|
+
return this.initDbPromise.then(() => get(storeName, `${key}`, this.db));
|
|
10732
10748
|
}
|
|
10733
10749
|
getFloorCacheKey(floorInfo) {
|
|
10734
10750
|
return `${floorInfo.floor_id}`;
|
|
@@ -10751,7 +10767,8 @@ var AibeeLoader = class {
|
|
|
10751
10767
|
}
|
|
10752
10768
|
}
|
|
10753
10769
|
return this.getFloorDataByFloorInfo(floorInfo);
|
|
10754
|
-
} catch {
|
|
10770
|
+
} catch (e) {
|
|
10771
|
+
console.log("[get floor data error]", e);
|
|
10755
10772
|
return this.getFloorDataByFloorInfo(floorInfo);
|
|
10756
10773
|
}
|
|
10757
10774
|
}
|
|
@@ -10798,8 +10815,34 @@ var AibeeLoader = class {
|
|
|
10798
10815
|
return res.filter((item) => item.points);
|
|
10799
10816
|
}
|
|
10800
10817
|
async getFacilitiesData() {
|
|
10801
|
-
|
|
10802
|
-
|
|
10818
|
+
const floorInfo = this.floors[0];
|
|
10819
|
+
if (!floorInfo) {
|
|
10820
|
+
return null;
|
|
10821
|
+
}
|
|
10822
|
+
const cacheKey = this.getFloorCacheKey(floorInfo);
|
|
10823
|
+
const getFacilityUrl = async () => {
|
|
10824
|
+
const res = await fetch(floorInfo.entry_infra_url).then((res2) => res2.json());
|
|
10825
|
+
if (res) {
|
|
10826
|
+
this.setCacheData(FacilityDataStoreName, cacheKey, res);
|
|
10827
|
+
this.setCacheData(FacilityVersionStoreName, cacheKey, floorInfo.version_id);
|
|
10828
|
+
}
|
|
10829
|
+
return res;
|
|
10830
|
+
};
|
|
10831
|
+
try {
|
|
10832
|
+
const cacheVersion = await this.getCacheData(FacilityVersionStoreName, cacheKey);
|
|
10833
|
+
if (cacheVersion === floorInfo.version_id) {
|
|
10834
|
+
const res = await this.getCacheData(
|
|
10835
|
+
FacilityDataStoreName,
|
|
10836
|
+
cacheKey
|
|
10837
|
+
);
|
|
10838
|
+
if (res) {
|
|
10839
|
+
return res;
|
|
10840
|
+
}
|
|
10841
|
+
}
|
|
10842
|
+
return getFacilityUrl();
|
|
10843
|
+
} catch (e) {
|
|
10844
|
+
console.log("[get facility error]", e);
|
|
10845
|
+
return getFacilityUrl();
|
|
10803
10846
|
}
|
|
10804
10847
|
}
|
|
10805
10848
|
// 空闲时间请求其他数据
|
|
@@ -10843,11 +10886,12 @@ var AibeeLoader = class {
|
|
|
10843
10886
|
fillOpacity,
|
|
10844
10887
|
strokeColor,
|
|
10845
10888
|
strokeOpacity,
|
|
10846
|
-
height
|
|
10889
|
+
height,
|
|
10890
|
+
airHeight
|
|
10847
10891
|
} = options;
|
|
10848
|
-
let key = `${fillColor.toLowerCase()}-${fillOpacity}-${strokeColor.toLowerCase()}-${strokeOpacity}-${height}`;
|
|
10892
|
+
let key = `${fillColor.toLowerCase()}-${fillOpacity}-${strokeColor.toLowerCase()}-${strokeOpacity}-${height}-${airHeight}`;
|
|
10849
10893
|
if (strokeOpacity === 0) {
|
|
10850
|
-
key = `${fillColor.toLowerCase()}-${fillOpacity}-${height}`;
|
|
10894
|
+
key = `${fillColor.toLowerCase()}-${fillOpacity}-${height}-${airHeight}`;
|
|
10851
10895
|
}
|
|
10852
10896
|
if (obj[key]) {
|
|
10853
10897
|
obj[key].push(options);
|
|
@@ -10967,7 +11011,8 @@ var AibeeLoader = class {
|
|
|
10967
11011
|
icon: options.poi_info.icon,
|
|
10968
11012
|
text: options.poi_info.showName || options.store_name || options.poi_info.text,
|
|
10969
11013
|
position: { x: pos[0], y: pos[1], z: options.airHeight + options.height },
|
|
10970
|
-
icon_size: [18, 18]
|
|
11014
|
+
icon_size: [18, 18],
|
|
11015
|
+
level: options.poi_info.level || 0
|
|
10971
11016
|
});
|
|
10972
11017
|
floor.poiLayer2.pushPoi(poi);
|
|
10973
11018
|
if (poi) {
|
|
@@ -10995,7 +11040,8 @@ var AibeeLoader = class {
|
|
|
10995
11040
|
icon: options.poi_info.icon,
|
|
10996
11041
|
text: options.poi_info.showName || options.store_name || options.poi_info.text,
|
|
10997
11042
|
position: { x: pos[0], y: pos[1], z: options.airHeight + options.height },
|
|
10998
|
-
icon_size: [18, 18]
|
|
11043
|
+
icon_size: [18, 18],
|
|
11044
|
+
level: options.poi_info.level || 0
|
|
10999
11045
|
});
|
|
11000
11046
|
floor.poiLayer2.pushPoi(poi);
|
|
11001
11047
|
poi.userData.type = "facility";
|
|
@@ -11082,11 +11128,11 @@ var AibeeLoader = class {
|
|
|
11082
11128
|
floor.updateBox();
|
|
11083
11129
|
return floor;
|
|
11084
11130
|
}
|
|
11085
|
-
clear() {
|
|
11131
|
+
async clear() {
|
|
11132
|
+
await this.initDbPromise.then(() => closeDb());
|
|
11086
11133
|
}
|
|
11087
11134
|
dispose() {
|
|
11088
11135
|
this.clear();
|
|
11089
|
-
closeDb();
|
|
11090
11136
|
}
|
|
11091
11137
|
};
|
|
11092
11138
|
|