venue-js 1.3.1 → 1.4.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 +20 -7
- package/dist/index.d.ts +20 -7
- package/dist/index.js +77 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +77 -25
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -8,7 +8,7 @@ import { Map, Coordinate as Coordinate$1 } from 'maptalks-gl';
|
|
|
8
8
|
import { BaseObject, ThreeLayer } from 'maptalks.three';
|
|
9
9
|
import * as maptalks from 'maptalks';
|
|
10
10
|
import { Coordinate, Extent, Marker, ui, LineString as LineString$1, Polygon as Polygon$1, MultiPolygon as MultiPolygon$1, MultiLineString } from 'maptalks';
|
|
11
|
-
import { BaseObjectOptionType, ExtrudePolygonOptionType, ExtrudeLineOptionType } from 'maptalks.three/dist/type';
|
|
11
|
+
import { BaseObjectOptionType, BarOptionType, ExtrudePolygonOptionType, ExtrudeLineOptionType } from 'maptalks.three/dist/type';
|
|
12
12
|
import { PolygonOptionsType } from 'maptalks/dist/geometry/Polygon';
|
|
13
13
|
import { LineStringOptionsType } from 'maptalks/dist/geometry/LineString';
|
|
14
14
|
import { MapViewType, MapAnimationOptionsType, MapPaddingType } from 'maptalks/dist/map/Map';
|
|
@@ -84,7 +84,9 @@ type AnchorProperties = EntityTimestamps & {
|
|
|
84
84
|
unit_id: Id;
|
|
85
85
|
locale: string;
|
|
86
86
|
};
|
|
87
|
-
type AnchorFeature = ImdfFeature<AnchorGeometry, AnchorProperties
|
|
87
|
+
type AnchorFeature = ImdfFeature<AnchorGeometry, AnchorProperties> & {
|
|
88
|
+
feature_type: "anchor";
|
|
89
|
+
};
|
|
88
90
|
type AmenityGeometry = Point;
|
|
89
91
|
type AmenityProperties = EntityTimestamps & {
|
|
90
92
|
amenity_logo: Media | null;
|
|
@@ -489,6 +491,10 @@ type AnchorFeaturePopulated = AnchorFeature & {
|
|
|
489
491
|
* [IMDF] Level that kiosk is on
|
|
490
492
|
*/
|
|
491
493
|
level: LevelFeaturePopulated;
|
|
494
|
+
/**
|
|
495
|
+
* [venue.in.th] Venue that anchor is in
|
|
496
|
+
*/
|
|
497
|
+
venue: VenueFeaturePopulated;
|
|
492
498
|
/**
|
|
493
499
|
* [Derived] The section this anchor is on.
|
|
494
500
|
* This is added during feature enrichment and not part of the original IMDF dataset.
|
|
@@ -827,6 +833,15 @@ declare class TextSpriteMarker extends BaseObject {
|
|
|
827
833
|
setAltitude(altitude: number): this;
|
|
828
834
|
}
|
|
829
835
|
|
|
836
|
+
type ImageMarkerOptions = BaseObjectOptionType & {
|
|
837
|
+
src: string;
|
|
838
|
+
bottomHeight?: number;
|
|
839
|
+
leg?: Omit<BarOptionType, 'height'> & {
|
|
840
|
+
color: string;
|
|
841
|
+
};
|
|
842
|
+
};
|
|
843
|
+
type AnyMarkerOptions = TextMarkerOptions | ImageMarkerOptions;
|
|
844
|
+
|
|
830
845
|
type Stop = [zoom: number, value: number];
|
|
831
846
|
type MapElement = maptalks.Geometry | BaseObject;
|
|
832
847
|
/** 2D */
|
|
@@ -868,17 +883,15 @@ type BaseRenderManagerOptions = {
|
|
|
868
883
|
};
|
|
869
884
|
type RendererManagerOptions = BaseRenderManagerOptions & {
|
|
870
885
|
type: "2D";
|
|
871
|
-
elements
|
|
886
|
+
elements?: Element2DRendererOptions;
|
|
872
887
|
} | BaseRenderManagerOptions & {
|
|
873
888
|
type: "3D";
|
|
874
|
-
elements
|
|
889
|
+
elements?: Element3DRendererOptions;
|
|
875
890
|
};
|
|
876
891
|
type HighlightElementOptions = {
|
|
877
892
|
reset: boolean;
|
|
878
893
|
};
|
|
879
894
|
|
|
880
|
-
type AnyMarkerOptions = TextMarkerOptions;
|
|
881
|
-
|
|
882
895
|
declare class RendererManager extends EventTarget {
|
|
883
896
|
#private;
|
|
884
897
|
map: maptalks$1.Map;
|
|
@@ -906,7 +919,7 @@ declare class RendererManager extends EventTarget {
|
|
|
906
919
|
* ======================================================================== */
|
|
907
920
|
_getMarkersByOrdinal: (ordinal: number) => BaseObject[] | maptalks$1.ui.UIMarker[];
|
|
908
921
|
_addMarkersToManager: (id: any, markers: any, ordinal: any) => void;
|
|
909
|
-
createMarker(coordinate: Position, ordinal: number,
|
|
922
|
+
createMarker(type: 'text' | 'image', coordinate: Position, ordinal: number, textOrPath: string, options: AnyMarkerOptions): void;
|
|
910
923
|
clearMarkers(): void;
|
|
911
924
|
}
|
|
912
925
|
|
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { Map, Coordinate as Coordinate$1 } from 'maptalks-gl';
|
|
|
8
8
|
import { BaseObject, ThreeLayer } from 'maptalks.three';
|
|
9
9
|
import * as maptalks from 'maptalks';
|
|
10
10
|
import { Coordinate, Extent, Marker, ui, LineString as LineString$1, Polygon as Polygon$1, MultiPolygon as MultiPolygon$1, MultiLineString } from 'maptalks';
|
|
11
|
-
import { BaseObjectOptionType, ExtrudePolygonOptionType, ExtrudeLineOptionType } from 'maptalks.three/dist/type';
|
|
11
|
+
import { BaseObjectOptionType, BarOptionType, ExtrudePolygonOptionType, ExtrudeLineOptionType } from 'maptalks.three/dist/type';
|
|
12
12
|
import { PolygonOptionsType } from 'maptalks/dist/geometry/Polygon';
|
|
13
13
|
import { LineStringOptionsType } from 'maptalks/dist/geometry/LineString';
|
|
14
14
|
import { MapViewType, MapAnimationOptionsType, MapPaddingType } from 'maptalks/dist/map/Map';
|
|
@@ -84,7 +84,9 @@ type AnchorProperties = EntityTimestamps & {
|
|
|
84
84
|
unit_id: Id;
|
|
85
85
|
locale: string;
|
|
86
86
|
};
|
|
87
|
-
type AnchorFeature = ImdfFeature<AnchorGeometry, AnchorProperties
|
|
87
|
+
type AnchorFeature = ImdfFeature<AnchorGeometry, AnchorProperties> & {
|
|
88
|
+
feature_type: "anchor";
|
|
89
|
+
};
|
|
88
90
|
type AmenityGeometry = Point;
|
|
89
91
|
type AmenityProperties = EntityTimestamps & {
|
|
90
92
|
amenity_logo: Media | null;
|
|
@@ -489,6 +491,10 @@ type AnchorFeaturePopulated = AnchorFeature & {
|
|
|
489
491
|
* [IMDF] Level that kiosk is on
|
|
490
492
|
*/
|
|
491
493
|
level: LevelFeaturePopulated;
|
|
494
|
+
/**
|
|
495
|
+
* [venue.in.th] Venue that anchor is in
|
|
496
|
+
*/
|
|
497
|
+
venue: VenueFeaturePopulated;
|
|
492
498
|
/**
|
|
493
499
|
* [Derived] The section this anchor is on.
|
|
494
500
|
* This is added during feature enrichment and not part of the original IMDF dataset.
|
|
@@ -827,6 +833,15 @@ declare class TextSpriteMarker extends BaseObject {
|
|
|
827
833
|
setAltitude(altitude: number): this;
|
|
828
834
|
}
|
|
829
835
|
|
|
836
|
+
type ImageMarkerOptions = BaseObjectOptionType & {
|
|
837
|
+
src: string;
|
|
838
|
+
bottomHeight?: number;
|
|
839
|
+
leg?: Omit<BarOptionType, 'height'> & {
|
|
840
|
+
color: string;
|
|
841
|
+
};
|
|
842
|
+
};
|
|
843
|
+
type AnyMarkerOptions = TextMarkerOptions | ImageMarkerOptions;
|
|
844
|
+
|
|
830
845
|
type Stop = [zoom: number, value: number];
|
|
831
846
|
type MapElement = maptalks.Geometry | BaseObject;
|
|
832
847
|
/** 2D */
|
|
@@ -868,17 +883,15 @@ type BaseRenderManagerOptions = {
|
|
|
868
883
|
};
|
|
869
884
|
type RendererManagerOptions = BaseRenderManagerOptions & {
|
|
870
885
|
type: "2D";
|
|
871
|
-
elements
|
|
886
|
+
elements?: Element2DRendererOptions;
|
|
872
887
|
} | BaseRenderManagerOptions & {
|
|
873
888
|
type: "3D";
|
|
874
|
-
elements
|
|
889
|
+
elements?: Element3DRendererOptions;
|
|
875
890
|
};
|
|
876
891
|
type HighlightElementOptions = {
|
|
877
892
|
reset: boolean;
|
|
878
893
|
};
|
|
879
894
|
|
|
880
|
-
type AnyMarkerOptions = TextMarkerOptions;
|
|
881
|
-
|
|
882
895
|
declare class RendererManager extends EventTarget {
|
|
883
896
|
#private;
|
|
884
897
|
map: maptalks$1.Map;
|
|
@@ -906,7 +919,7 @@ declare class RendererManager extends EventTarget {
|
|
|
906
919
|
* ======================================================================== */
|
|
907
920
|
_getMarkersByOrdinal: (ordinal: number) => BaseObject[] | maptalks$1.ui.UIMarker[];
|
|
908
921
|
_addMarkersToManager: (id: any, markers: any, ordinal: any) => void;
|
|
909
|
-
createMarker(coordinate: Position, ordinal: number,
|
|
922
|
+
createMarker(type: 'text' | 'image', coordinate: Position, ordinal: number, textOrPath: string, options: AnyMarkerOptions): void;
|
|
910
923
|
clearMarkers(): void;
|
|
911
924
|
}
|
|
912
925
|
|
package/dist/index.js
CHANGED
|
@@ -455,6 +455,7 @@ var createPopulator = ({
|
|
|
455
455
|
};
|
|
456
456
|
const populateAnchor = async (anchor) => {
|
|
457
457
|
const unit = await internalFindById(anchor.properties.unit_id);
|
|
458
|
+
const venue = await internalFindById(unit.properties.venue_id);
|
|
458
459
|
const level = await internalFindById(unit.properties.level_id);
|
|
459
460
|
const sections = await internalFilterByType("section");
|
|
460
461
|
const section = sections.find((section2) => (0, import_boolean_within.booleanWithin)(anchor, section2));
|
|
@@ -464,7 +465,9 @@ var createPopulator = ({
|
|
|
464
465
|
...anchor.properties,
|
|
465
466
|
level: await populateLevel(level),
|
|
466
467
|
unit: await populateUnit(unit),
|
|
467
|
-
section: section ? await populateSection(section) : null
|
|
468
|
+
section: section ? await populateSection(section) : null,
|
|
469
|
+
venue: await populateVenue(venue),
|
|
470
|
+
ordinal: level.properties.ordinal
|
|
468
471
|
}
|
|
469
472
|
};
|
|
470
473
|
};
|
|
@@ -2739,7 +2742,7 @@ var CameraManager = class {
|
|
|
2739
2742
|
// src/IndoorMap/renderer/RendererManager.ts
|
|
2740
2743
|
var import_lodash_es4 = require("lodash-es");
|
|
2741
2744
|
var import_center3 = require("@turf/center");
|
|
2742
|
-
var
|
|
2745
|
+
var THREE4 = __toESM(require("three"));
|
|
2743
2746
|
|
|
2744
2747
|
// src/IndoorMap/renderer/3d/Element3DRenderer.ts
|
|
2745
2748
|
var maptalks4 = __toESM(require("maptalks-gl"));
|
|
@@ -3084,7 +3087,7 @@ var DEFAULT_POLYGON_OPTION = {
|
|
|
3084
3087
|
offset: 0,
|
|
3085
3088
|
altitude: 0
|
|
3086
3089
|
};
|
|
3087
|
-
var get3DRendererOption = (featureType, category, options) => {
|
|
3090
|
+
var get3DRendererOption = (featureType, category, options = {}) => {
|
|
3088
3091
|
try {
|
|
3089
3092
|
const option = options[featureType] ?? element3DRendererOptions[featureType];
|
|
3090
3093
|
return (category && option.byCategory?.[category]) ?? option?.default ?? DEFAULT_POLYGON_OPTION;
|
|
@@ -3545,6 +3548,12 @@ var Marker2DRenderer = class extends EventTarget {
|
|
|
3545
3548
|
marker.addTo(this.map);
|
|
3546
3549
|
return marker;
|
|
3547
3550
|
};
|
|
3551
|
+
createTextMarker = (position, label, options) => {
|
|
3552
|
+
return null;
|
|
3553
|
+
};
|
|
3554
|
+
createImageMarker = (position, src, options) => {
|
|
3555
|
+
return null;
|
|
3556
|
+
};
|
|
3548
3557
|
removeMarker = (marker) => {
|
|
3549
3558
|
marker.remove();
|
|
3550
3559
|
};
|
|
@@ -3556,6 +3565,7 @@ var Marker2DRenderer = class extends EventTarget {
|
|
|
3556
3565
|
|
|
3557
3566
|
// src/IndoorMap/renderer/3d/Marker3DRenderer.ts
|
|
3558
3567
|
var maptalks7 = __toESM(require("maptalks-gl"));
|
|
3568
|
+
var THREE3 = __toESM(require("three"));
|
|
3559
3569
|
|
|
3560
3570
|
// src/IndoorMap/renderer/3d/objects/TextSpriteMarker.ts
|
|
3561
3571
|
var import_maptalks8 = require("maptalks");
|
|
@@ -3755,21 +3765,35 @@ var TextSpriteMarker = class extends import_maptalks9.BaseObject {
|
|
|
3755
3765
|
};
|
|
3756
3766
|
|
|
3757
3767
|
// src/IndoorMap/renderer/3d/Marker3DRenderer.ts
|
|
3758
|
-
var HEIGHT_METER2 = 4;
|
|
3759
|
-
var MULTIORDINAL_HEIGHT_METER3 = 9;
|
|
3760
3768
|
var Marker3DRenderer = class extends EventTarget {
|
|
3761
3769
|
isReady = false;
|
|
3762
3770
|
threeLayer;
|
|
3763
3771
|
map;
|
|
3764
|
-
materialByKey;
|
|
3765
3772
|
constructor(map, options, layer) {
|
|
3766
3773
|
super();
|
|
3767
3774
|
this.map = map;
|
|
3768
3775
|
this.threeLayer = layer;
|
|
3769
3776
|
}
|
|
3770
|
-
|
|
3777
|
+
createPointMaterialFromSvg(svgPath, size = 40) {
|
|
3778
|
+
return new THREE3.PointsMaterial({
|
|
3779
|
+
size,
|
|
3780
|
+
sizeAttenuation: false,
|
|
3781
|
+
// Always same size in screen pixels (Screen pixel)
|
|
3782
|
+
// color: fillStyle,
|
|
3783
|
+
alphaTest: 0.5,
|
|
3784
|
+
// vertexColors: THREE.VertexColors,
|
|
3785
|
+
// color: 0xffffff,
|
|
3786
|
+
transparent: true,
|
|
3787
|
+
blending: THREE3.NormalBlending,
|
|
3788
|
+
depthTest: true,
|
|
3789
|
+
// POI is hidden behind building
|
|
3790
|
+
depthWrite: true,
|
|
3791
|
+
map: new THREE3.TextureLoader().load(svgPath)
|
|
3792
|
+
});
|
|
3793
|
+
}
|
|
3794
|
+
createTextMarker = (position, label, options) => {
|
|
3771
3795
|
const combinedOptions = {
|
|
3772
|
-
altitude:
|
|
3796
|
+
altitude: 0,
|
|
3773
3797
|
text: label,
|
|
3774
3798
|
...options ?? {}
|
|
3775
3799
|
};
|
|
@@ -3778,17 +3802,37 @@ var Marker3DRenderer = class extends EventTarget {
|
|
|
3778
3802
|
this.threeLayer.addMesh([marker]);
|
|
3779
3803
|
return marker;
|
|
3780
3804
|
};
|
|
3781
|
-
createImageMarker = () => {
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3805
|
+
createImageMarker = (position, src, options) => {
|
|
3806
|
+
const [lng, lat] = position;
|
|
3807
|
+
let meshes = [];
|
|
3808
|
+
const height = options.height ?? 0;
|
|
3809
|
+
const { leg, ...markerOptions } = options;
|
|
3810
|
+
const { color: legColor = "#000000", ...legOptions } = leg ?? {};
|
|
3811
|
+
const material = this.createPointMaterialFromSvg(src, 40);
|
|
3812
|
+
const marker = this.threeLayer.toPoint(new maptalks7.Coordinate(lng, lat), { height, ...markerOptions }, material);
|
|
3813
|
+
marker.getObject3d().renderOrder = 10;
|
|
3814
|
+
meshes.push(marker);
|
|
3815
|
+
if (options.leg) {
|
|
3816
|
+
const legMaterial = new THREE3.MeshLambertMaterial({ color: legColor, transparent: true });
|
|
3817
|
+
const leg2 = this.threeLayer.toBar(new maptalks7.Coordinate(lng, lat), { ...legOptions, height }, legMaterial);
|
|
3818
|
+
const legObj = leg2.getObject3d();
|
|
3819
|
+
legObj.traverse((o) => {
|
|
3820
|
+
if (o.isMesh && o.material) {
|
|
3821
|
+
o.material.depthWrite = false;
|
|
3822
|
+
o.material.depthTest = true;
|
|
3823
|
+
o.renderOrder = 0;
|
|
3824
|
+
}
|
|
3825
|
+
});
|
|
3826
|
+
meshes = [leg2, ...meshes];
|
|
3827
|
+
}
|
|
3828
|
+
this.threeLayer.addMesh(meshes);
|
|
3829
|
+
return meshes;
|
|
3785
3830
|
};
|
|
3786
3831
|
removeMarker = (marker) => {
|
|
3787
3832
|
marker.remove();
|
|
3788
3833
|
};
|
|
3789
3834
|
showMarkers(elements, ordinalDiff = 0) {
|
|
3790
3835
|
elements.forEach((element) => {
|
|
3791
|
-
element.setAltitude(ordinalDiff * MULTIORDINAL_HEIGHT_METER3);
|
|
3792
3836
|
element.show();
|
|
3793
3837
|
});
|
|
3794
3838
|
}
|
|
@@ -4327,7 +4371,11 @@ function inBBox(pt, bbox2) {
|
|
|
4327
4371
|
|
|
4328
4372
|
// src/IndoorMap/renderer/utils/findUnitOnPoint.ts
|
|
4329
4373
|
var findUnitOnPoint = (units, point2) => {
|
|
4330
|
-
|
|
4374
|
+
try {
|
|
4375
|
+
return units.find((unit) => booleanPointInPolygon(point2, polygon(unit.geometry.coordinates)));
|
|
4376
|
+
} catch (err) {
|
|
4377
|
+
return null;
|
|
4378
|
+
}
|
|
4331
4379
|
};
|
|
4332
4380
|
|
|
4333
4381
|
// src/IndoorMap/renderer/RendererManager.ts
|
|
@@ -4397,13 +4445,13 @@ var RendererManager = class extends EventTarget {
|
|
|
4397
4445
|
}
|
|
4398
4446
|
return bad;
|
|
4399
4447
|
}
|
|
4400
|
-
const ambientLight = new
|
|
4448
|
+
const ambientLight = new THREE4.AmbientLight(16777215, 0.3);
|
|
4401
4449
|
scene.add(ambientLight);
|
|
4402
4450
|
const dirColor = 16777215;
|
|
4403
|
-
const dllight = new
|
|
4451
|
+
const dllight = new THREE4.DirectionalLight(dirColor, 0.8);
|
|
4404
4452
|
dllight.position.set(0, -10, 20).normalize();
|
|
4405
4453
|
scene.add(dllight);
|
|
4406
|
-
const hemi = new
|
|
4454
|
+
const hemi = new THREE4.HemisphereLight(16777215, 4473924, 0.4);
|
|
4407
4455
|
scene.add(hemi);
|
|
4408
4456
|
_this.elementRenderer = new Element3DRenderer(map, options.elements);
|
|
4409
4457
|
_this.markerRenderer = new Marker3DRenderer(map, {}, threeLayer);
|
|
@@ -4486,7 +4534,7 @@ var RendererManager = class extends EventTarget {
|
|
|
4486
4534
|
return openings.find((o) => o.id === openingId);
|
|
4487
4535
|
}));
|
|
4488
4536
|
const innerElements = this.elementRenderer.createGeometry(unit);
|
|
4489
|
-
const wallElements =
|
|
4537
|
+
const wallElements = [];
|
|
4490
4538
|
if (innerElements || wallElements) {
|
|
4491
4539
|
const _innerElements = Array.isArray(innerElements) ? innerElements : [innerElements];
|
|
4492
4540
|
const _wallElements = Array.isArray(wallElements) ? wallElements : [wallElements];
|
|
@@ -4541,10 +4589,12 @@ var RendererManager = class extends EventTarget {
|
|
|
4541
4589
|
for (const label of groundLabels) {
|
|
4542
4590
|
const center2 = (0, import_center3.center)(polygon(label.geometry.coordinates)).geometry.coordinates;
|
|
4543
4591
|
const unit = findUnitOnPoint(units, center2);
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
|
|
4592
|
+
if (unit) {
|
|
4593
|
+
const element = this.elementRenderer.createGroundLabel(label, unit);
|
|
4594
|
+
if (element) {
|
|
4595
|
+
const _elements = Array.isArray(element) ? element : [element];
|
|
4596
|
+
this.addElementsToManager(label.id, _elements, label.properties.ordinal);
|
|
4597
|
+
}
|
|
4548
4598
|
}
|
|
4549
4599
|
}
|
|
4550
4600
|
if (this.options.type === "3D") {
|
|
@@ -4626,10 +4676,11 @@ var RendererManager = class extends EventTarget {
|
|
|
4626
4676
|
this.markerRenderer.hideMarkers(markers, ordinal);
|
|
4627
4677
|
}
|
|
4628
4678
|
};
|
|
4629
|
-
createMarker(coordinate, ordinal,
|
|
4630
|
-
const
|
|
4679
|
+
createMarker(type, coordinate, ordinal, textOrPath, options) {
|
|
4680
|
+
const meshes = type === "text" ? this.markerRenderer.createTextMarker(coordinate, textOrPath, options) : this.markerRenderer.createImageMarker(coordinate, textOrPath, options);
|
|
4631
4681
|
const markerId = `${this.markersMap.size + 1}`;
|
|
4632
|
-
|
|
4682
|
+
const markerMeshes = Array.isArray(meshes) ? meshes : [meshes];
|
|
4683
|
+
this._addMarkersToManager(markerId, markerMeshes, ordinal);
|
|
4633
4684
|
}
|
|
4634
4685
|
clearMarkers() {
|
|
4635
4686
|
for (const [markerId, marker] of this.markersMap) {
|
|
@@ -4769,6 +4820,7 @@ var IndoorMap = class extends EventTarget {
|
|
|
4769
4820
|
this.#dataClient = value;
|
|
4770
4821
|
if (!this.options.camera?.defaultView?.center) {
|
|
4771
4822
|
this.#dataClient.filterByType("venue").then((venues) => {
|
|
4823
|
+
this.#venues = venues;
|
|
4772
4824
|
const venueCenters = (0, import_center4.default)(featureCollection(venues));
|
|
4773
4825
|
const [x, y] = venueCenters.geometry.coordinates;
|
|
4774
4826
|
const center2 = new import_maptalks_gl.Coordinate(x, y);
|