@osm-editor-kit/street-imagery-react 0.1.0-alpha.3 → 0.1.0-alpha.6
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 +113 -0
- package/dist/MapillaryPanel-N45NQY4C.js +2 -0
- package/dist/PanoramaxPanel-MFI4L67Z.js +2 -0
- package/dist/StreetLevelImagerySelectionOverlay.d.ts +20 -3
- package/dist/StreetLevelImagerySourcesAndLayers.d.ts +14 -1
- package/dist/StreetLevelImageryViewCone.d.ts +11 -1
- package/dist/StreetLevelImageryViewer.d.ts +15 -1
- package/dist/chunk-53RA4OSJ.js +304 -0
- package/dist/chunk-EQ2JKLGT.js +311 -0
- package/dist/chunk-HA4GJWHI.js +120 -0
- package/dist/hooks/useAllProviderMapFeatures.d.ts +0 -4
- package/dist/i18n/PhotoDate.d.ts +16 -0
- package/dist/i18n/StreetImageryLocaleProvider.d.ts +21 -0
- package/dist/i18n/messages.d.ts +35 -0
- package/dist/index.d.ts +15 -2
- package/dist/index.js +984 -117
- package/dist/mapillary/MapillaryFeatureBar.d.ts +13 -0
- package/dist/mapillary/useMapillaryFeatures.d.ts +36 -0
- package/dist/openers/LocationPickOnMap.d.ts +10 -0
- package/dist/openers/useLocationPickStore.d.ts +9 -0
- package/dist/panels/MapillaryPanel.d.ts +19 -1
- package/dist/panels/PanoramaxPanel.d.ts +8 -1
- package/dist/panels/mapillaryLookAt.d.ts +41 -0
- package/dist/panels/panoramaxLimitPanning.d.ts +54 -0
- package/dist/panels/panoramaxPhotoFromMetadata.d.ts +8 -0
- package/dist/photo-details/PhotoDetailsDialog.d.ts +21 -0
- package/dist/photo-details/index.d.ts +6 -0
- package/dist/photo-details/labels.d.ts +33 -0
- package/dist/photo-details.js +235 -0
- package/dist/viewpoints/FloatingPhotoViewer.d.ts +54 -0
- package/dist/viewpoints/ViewpointLayer.d.ts +17 -0
- package/dist/viewpoints/useViewSuggestions.d.ts +23 -0
- package/dist/viewpoints/useViewpointSessionStore.d.ts +32 -0
- package/dist/viewpoints/viewDirectionLabels.d.ts +4 -0
- package/package.json +11 -3
- package/dist/MapillaryPanel-QX6NESX7.js +0 -2
- package/dist/PanoramaxPanel-J6ANR6LB.js +0 -2
- package/dist/chunk-BS6LPDMY.js +0 -143
- package/dist/chunk-ZH3TPW4D.js +0 -165
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@osm-editor-kit/street-imagery-react",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.6",
|
|
4
4
|
"description": "React MapLibre layers and photo viewers for street-level imagery providers.",
|
|
5
5
|
"homepage": "https://github.com/osmberlin/street-space-editor/tree/main/packages/street-imagery-react",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,6 +19,10 @@
|
|
|
19
19
|
"types": "./dist/index.d.ts",
|
|
20
20
|
"import": "./dist/index.js"
|
|
21
21
|
},
|
|
22
|
+
"./photo-details": {
|
|
23
|
+
"types": "./dist/photo-details/index.d.ts",
|
|
24
|
+
"import": "./dist/photo-details.js"
|
|
25
|
+
},
|
|
22
26
|
"./package.json": "./package.json"
|
|
23
27
|
},
|
|
24
28
|
"publishConfig": {
|
|
@@ -45,13 +49,13 @@
|
|
|
45
49
|
"maplibre-gl": "^6.7.0",
|
|
46
50
|
"react": "^19.1.1",
|
|
47
51
|
"react-dom": "^19.1.1",
|
|
48
|
-
"react-map-gl": "^8.
|
|
52
|
+
"react-map-gl": "^8.1.3",
|
|
49
53
|
"tsup": "^8.5.1",
|
|
50
54
|
"typescript": "^7.0.0",
|
|
51
55
|
"zustand": "^5.0.7"
|
|
52
56
|
},
|
|
53
57
|
"peerDependencies": {
|
|
54
|
-
"@osm-editor-kit/street-imagery": "^0.1.0-alpha.
|
|
58
|
+
"@osm-editor-kit/street-imagery": "^0.1.0-alpha.5",
|
|
55
59
|
"@panoramax/web-viewer": "^5",
|
|
56
60
|
"@tanstack/react-query": "^5",
|
|
57
61
|
"mapillary-js": "^4",
|
|
@@ -66,6 +70,10 @@
|
|
|
66
70
|
"types": "./dist/index.d.ts",
|
|
67
71
|
"import": "./dist/index.js"
|
|
68
72
|
},
|
|
73
|
+
"./photo-details": {
|
|
74
|
+
"types": "./dist/photo-details/index.d.ts",
|
|
75
|
+
"import": "./dist/photo-details.js"
|
|
76
|
+
},
|
|
69
77
|
"./package.json": "./package.json"
|
|
70
78
|
}
|
|
71
79
|
}
|
package/dist/chunk-BS6LPDMY.js
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import { useViewerActions } from './chunk-25UGGXIE.js';
|
|
2
|
-
import { getStreetImageryConfig } from '@osm-editor-kit/street-imagery';
|
|
3
|
-
import 'mapillary-js/dist/mapillary.css';
|
|
4
|
-
import { Viewer } from 'mapillary-js';
|
|
5
|
-
import { useRef, useEffect } from 'react';
|
|
6
|
-
import { jsx } from 'react/jsx-runtime';
|
|
7
|
-
|
|
8
|
-
var MapillaryPanel = ({
|
|
9
|
-
photo,
|
|
10
|
-
onPhotoSelected,
|
|
11
|
-
onEaseMapToPoint
|
|
12
|
-
}) => {
|
|
13
|
-
const containerRef = useRef(null);
|
|
14
|
-
const viewerRef = useRef(null);
|
|
15
|
-
const navigableRef = useRef(false);
|
|
16
|
-
const pendingImageIdRef = useRef(null);
|
|
17
|
-
const lastViewerPhotoIdRef = useRef(null);
|
|
18
|
-
const bearingRafRef = useRef(null);
|
|
19
|
-
const pendingBearingRef = useRef(null);
|
|
20
|
-
const actions = useViewerActions();
|
|
21
|
-
const initialPhotoIdRef = useRef(photo.photoId);
|
|
22
|
-
useEffect(
|
|
23
|
-
function resetViewerStoreOnProviderChange() {
|
|
24
|
-
return () => {
|
|
25
|
-
actions.reset();
|
|
26
|
-
};
|
|
27
|
-
},
|
|
28
|
-
[actions, photo.providerId]
|
|
29
|
-
);
|
|
30
|
-
useEffect(
|
|
31
|
-
function mountMapillaryViewer() {
|
|
32
|
-
const container = containerRef.current;
|
|
33
|
-
if (!container) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
const viewer = new Viewer({
|
|
37
|
-
accessToken: getStreetImageryConfig().mapillaryToken,
|
|
38
|
-
container,
|
|
39
|
-
imageId: initialPhotoIdRef.current,
|
|
40
|
-
component: {
|
|
41
|
-
cover: false,
|
|
42
|
-
sequence: { visible: true }
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
viewerRef.current = viewer;
|
|
46
|
-
lastViewerPhotoIdRef.current = initialPhotoIdRef.current;
|
|
47
|
-
const flushPendingMove = () => {
|
|
48
|
-
const pendingId = pendingImageIdRef.current;
|
|
49
|
-
if (!pendingId) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
pendingImageIdRef.current = null;
|
|
53
|
-
void viewer.moveTo(pendingId).catch(() => {
|
|
54
|
-
});
|
|
55
|
-
};
|
|
56
|
-
const onNavigable = (event) => {
|
|
57
|
-
navigableRef.current = event.navigable;
|
|
58
|
-
if (event.navigable) {
|
|
59
|
-
flushPendingMove();
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
const onImage = (event) => {
|
|
63
|
-
const { image } = event;
|
|
64
|
-
lastViewerPhotoIdRef.current = image.id;
|
|
65
|
-
onPhotoSelected({
|
|
66
|
-
provider: "mapillary",
|
|
67
|
-
sequenceId: image.sequenceId,
|
|
68
|
-
photoId: image.id
|
|
69
|
-
});
|
|
70
|
-
const position = image.lngLat ?? image.originalLngLat;
|
|
71
|
-
if (!position) {
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
actions.setPov({ lngLat: [position.lng, position.lat] });
|
|
75
|
-
onEaseMapToPoint(position.lng, position.lat);
|
|
76
|
-
};
|
|
77
|
-
const flushBearing = () => {
|
|
78
|
-
bearingRafRef.current = null;
|
|
79
|
-
if (pendingBearingRef.current != null) {
|
|
80
|
-
actions.setPov({ bearing: pendingBearingRef.current });
|
|
81
|
-
pendingBearingRef.current = null;
|
|
82
|
-
}
|
|
83
|
-
void viewer.getFieldOfView().then((fov) => {
|
|
84
|
-
actions.setPov({ hfov: fov });
|
|
85
|
-
}).catch(() => {
|
|
86
|
-
});
|
|
87
|
-
};
|
|
88
|
-
const onBearing = (event) => {
|
|
89
|
-
pendingBearingRef.current = event.bearing;
|
|
90
|
-
if (bearingRafRef.current == null) {
|
|
91
|
-
bearingRafRef.current = requestAnimationFrame(flushBearing);
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
viewer.on("navigable", onNavigable);
|
|
95
|
-
viewer.on("image", onImage);
|
|
96
|
-
viewer.on("bearing", onBearing);
|
|
97
|
-
const resizeObserver = new ResizeObserver(() => {
|
|
98
|
-
viewer.resize();
|
|
99
|
-
});
|
|
100
|
-
resizeObserver.observe(container);
|
|
101
|
-
return () => {
|
|
102
|
-
if (bearingRafRef.current != null) {
|
|
103
|
-
cancelAnimationFrame(bearingRafRef.current);
|
|
104
|
-
bearingRafRef.current = null;
|
|
105
|
-
}
|
|
106
|
-
resizeObserver.disconnect();
|
|
107
|
-
viewer.off("navigable", onNavigable);
|
|
108
|
-
viewer.off("image", onImage);
|
|
109
|
-
viewer.off("bearing", onBearing);
|
|
110
|
-
viewer.remove();
|
|
111
|
-
viewerRef.current = null;
|
|
112
|
-
};
|
|
113
|
-
},
|
|
114
|
-
[actions, onEaseMapToPoint, onPhotoSelected]
|
|
115
|
-
);
|
|
116
|
-
useEffect(
|
|
117
|
-
function syncExternalPhotoSelection() {
|
|
118
|
-
const viewer = viewerRef.current;
|
|
119
|
-
if (!viewer || photo.photoId === lastViewerPhotoIdRef.current) {
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
actions.reset();
|
|
123
|
-
lastViewerPhotoIdRef.current = photo.photoId;
|
|
124
|
-
if (navigableRef.current) {
|
|
125
|
-
void viewer.moveTo(photo.photoId).catch(() => {
|
|
126
|
-
});
|
|
127
|
-
} else {
|
|
128
|
-
pendingImageIdRef.current = photo.photoId;
|
|
129
|
-
}
|
|
130
|
-
},
|
|
131
|
-
[actions, photo.photoId]
|
|
132
|
-
);
|
|
133
|
-
return /* @__PURE__ */ jsx(
|
|
134
|
-
"div",
|
|
135
|
-
{
|
|
136
|
-
ref: containerRef,
|
|
137
|
-
className: "min-h-48 overflow-hidden rounded-lg border border-slate-200 bg-slate-900",
|
|
138
|
-
style: { aspectRatio: "4 / 3" }
|
|
139
|
-
}
|
|
140
|
-
);
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
export { MapillaryPanel };
|
package/dist/chunk-ZH3TPW4D.js
DELETED
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import { useViewerActions } from './chunk-25UGGXIE.js';
|
|
2
|
-
import '@panoramax/web-viewer';
|
|
3
|
-
import { getStreetImageryConfig } from '@osm-editor-kit/street-imagery';
|
|
4
|
-
import { useRef, useEffect } from 'react';
|
|
5
|
-
import { jsx } from 'react/jsx-runtime';
|
|
6
|
-
|
|
7
|
-
var panoramaxApiEndpoint = () => `${getStreetImageryConfig().panoramaxApiBase}/api`;
|
|
8
|
-
var normalizeBearing = (degrees) => (degrees % 360 + 360) % 360;
|
|
9
|
-
var PanoramaxPanel = ({
|
|
10
|
-
photo,
|
|
11
|
-
onPhotoSelected,
|
|
12
|
-
onEaseMapToPoint
|
|
13
|
-
}) => {
|
|
14
|
-
const containerRef = useRef(null);
|
|
15
|
-
const viewerRef = useRef(null);
|
|
16
|
-
const lastViewerPhotoIdRef = useRef(null);
|
|
17
|
-
const readyRef = useRef(false);
|
|
18
|
-
const pendingSelectRef = useRef(null);
|
|
19
|
-
const photoRef = useRef(photo);
|
|
20
|
-
const bearingRafRef = useRef(null);
|
|
21
|
-
const pendingBearingRef = useRef(null);
|
|
22
|
-
const pendingHfovRef = useRef(null);
|
|
23
|
-
const actions = useViewerActions();
|
|
24
|
-
useEffect(
|
|
25
|
-
function syncPhotoRef() {
|
|
26
|
-
photoRef.current = photo;
|
|
27
|
-
},
|
|
28
|
-
[photo]
|
|
29
|
-
);
|
|
30
|
-
useEffect(
|
|
31
|
-
function resetViewerStoreOnProviderChange() {
|
|
32
|
-
return () => {
|
|
33
|
-
actions.reset();
|
|
34
|
-
};
|
|
35
|
-
},
|
|
36
|
-
[actions, photo.providerId]
|
|
37
|
-
);
|
|
38
|
-
useEffect(
|
|
39
|
-
function mountPanoramaxViewer() {
|
|
40
|
-
const viewer = viewerRef.current;
|
|
41
|
-
const container = containerRef.current;
|
|
42
|
-
if (!viewer || !container) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
lastViewerPhotoIdRef.current = photoRef.current.photoId;
|
|
46
|
-
const flushBearing = () => {
|
|
47
|
-
bearingRafRef.current = null;
|
|
48
|
-
if (pendingBearingRef.current != null) {
|
|
49
|
-
actions.setPov({ bearing: pendingBearingRef.current });
|
|
50
|
-
pendingBearingRef.current = null;
|
|
51
|
-
}
|
|
52
|
-
if (pendingHfovRef.current != null) {
|
|
53
|
-
actions.setPov({ hfov: pendingHfovRef.current });
|
|
54
|
-
pendingHfovRef.current = null;
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
const onSelect = (event) => {
|
|
58
|
-
const { seqId, picId } = event.detail;
|
|
59
|
-
if (!picId) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
lastViewerPhotoIdRef.current = picId;
|
|
63
|
-
const currentPhoto = photoRef.current;
|
|
64
|
-
const sequenceId = seqId ?? (picId === currentPhoto.photoId && currentPhoto.sequenceId ? currentPhoto.sequenceId : `photo:${picId}`);
|
|
65
|
-
onPhotoSelected({
|
|
66
|
-
provider: "panoramax",
|
|
67
|
-
sequenceId,
|
|
68
|
-
photoId: picId
|
|
69
|
-
});
|
|
70
|
-
};
|
|
71
|
-
const onPictureLoaded = (event) => {
|
|
72
|
-
const detail = event.detail;
|
|
73
|
-
if (detail.lon == null || detail.lat == null) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
actions.setPov({ lngLat: [detail.lon, detail.lat] });
|
|
77
|
-
if (detail.x != null) {
|
|
78
|
-
actions.setPov({ bearing: normalizeBearing(detail.x) });
|
|
79
|
-
}
|
|
80
|
-
const psv = viewer.psv;
|
|
81
|
-
if (psv && detail.z != null) {
|
|
82
|
-
actions.setPov({ hfov: psv.dataHelper.zoomLevelToFov(detail.z) });
|
|
83
|
-
}
|
|
84
|
-
onEaseMapToPoint(detail.lon, detail.lat);
|
|
85
|
-
};
|
|
86
|
-
const onViewRotated = (event) => {
|
|
87
|
-
const detail = event.detail;
|
|
88
|
-
pendingBearingRef.current = normalizeBearing(detail.x);
|
|
89
|
-
const psv = viewer.psv;
|
|
90
|
-
if (psv && detail.z != null) {
|
|
91
|
-
pendingHfovRef.current = psv.dataHelper.zoomLevelToFov(detail.z);
|
|
92
|
-
}
|
|
93
|
-
if (bearingRafRef.current == null) {
|
|
94
|
-
bearingRafRef.current = requestAnimationFrame(flushBearing);
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
viewer.addEventListener("select", onSelect);
|
|
98
|
-
viewer.addEventListener("psv:picture-loaded", onPictureLoaded);
|
|
99
|
-
viewer.addEventListener("psv:view-rotated", onViewRotated);
|
|
100
|
-
const resizeObserver = new ResizeObserver(() => {
|
|
101
|
-
viewer.psv?.resize();
|
|
102
|
-
});
|
|
103
|
-
resizeObserver.observe(container);
|
|
104
|
-
readyRef.current = true;
|
|
105
|
-
const pending = pendingSelectRef.current;
|
|
106
|
-
if (pending) {
|
|
107
|
-
pendingSelectRef.current = null;
|
|
108
|
-
if (typeof viewer.select === "function") {
|
|
109
|
-
viewer.select(pending.sequenceId ?? null, pending.photoId);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
return () => {
|
|
113
|
-
readyRef.current = false;
|
|
114
|
-
if (bearingRafRef.current != null) {
|
|
115
|
-
cancelAnimationFrame(bearingRafRef.current);
|
|
116
|
-
bearingRafRef.current = null;
|
|
117
|
-
}
|
|
118
|
-
resizeObserver.disconnect();
|
|
119
|
-
viewer.removeEventListener("select", onSelect);
|
|
120
|
-
viewer.removeEventListener("psv:picture-loaded", onPictureLoaded);
|
|
121
|
-
viewer.removeEventListener("psv:view-rotated", onViewRotated);
|
|
122
|
-
};
|
|
123
|
-
},
|
|
124
|
-
[actions, onEaseMapToPoint, onPhotoSelected]
|
|
125
|
-
);
|
|
126
|
-
useEffect(
|
|
127
|
-
function syncExternalPhotoSelection() {
|
|
128
|
-
const viewer = viewerRef.current;
|
|
129
|
-
if (!viewer || photo.photoId === lastViewerPhotoIdRef.current) {
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
actions.reset();
|
|
133
|
-
lastViewerPhotoIdRef.current = photo.photoId;
|
|
134
|
-
if (!readyRef.current) {
|
|
135
|
-
pendingSelectRef.current = { sequenceId: photo.sequenceId, photoId: photo.photoId };
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
if (typeof viewer.select === "function") {
|
|
139
|
-
viewer.select(photo.sequenceId ?? null, photo.photoId);
|
|
140
|
-
}
|
|
141
|
-
},
|
|
142
|
-
[actions, photo.photoId, photo.sequenceId]
|
|
143
|
-
);
|
|
144
|
-
return /* @__PURE__ */ jsx(
|
|
145
|
-
"div",
|
|
146
|
-
{
|
|
147
|
-
ref: containerRef,
|
|
148
|
-
className: "min-h-48 overflow-hidden rounded-lg border border-slate-200 bg-slate-900",
|
|
149
|
-
style: { aspectRatio: "4 / 3" },
|
|
150
|
-
children: /* @__PURE__ */ jsx(
|
|
151
|
-
"pnx-photo-viewer",
|
|
152
|
-
{
|
|
153
|
-
ref: viewerRef,
|
|
154
|
-
className: "block h-full w-full",
|
|
155
|
-
endpoint: panoramaxApiEndpoint(),
|
|
156
|
-
"url-parameters": "false",
|
|
157
|
-
picture: photo.photoId,
|
|
158
|
-
sequence: photo.sequenceId ?? void 0
|
|
159
|
-
}
|
|
160
|
-
)
|
|
161
|
-
}
|
|
162
|
-
);
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
export { PanoramaxPanel };
|