@geogirafe/lib-geoportal 1.3.0-dev.3046054236 → 1.3.0-dev.3053452205
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 +3 -2
- package/api/apigeogirafeapp.js +3 -1
- package/assets/i18n/de.json +1 -0
- package/assets/i18n/en.json +1 -0
- package/assets/i18n/fr.json +1 -0
- package/assets/i18n/it.json +1 -0
- package/assets/icons/streetview-marker-mapillary.svg +1 -0
- package/components/layout/component.d.ts +5 -0
- package/components/map-grid/component.d.ts +4 -0
- package/components/map-grid/component.js +6 -0
- package/components/streetview/component.d.ts +9 -2
- package/components/streetview/component.js +20 -8
- package/components/streetview/google.js +1 -1
- package/components/streetview/mapillary.d.ts +8 -0
- package/components/streetview/mapillary.js +20 -0
- package/components/streetview/style.css +16 -0
- package/components/streetview/tools/googleprovider.js +9 -2
- package/components/streetview/tools/mapillaryprovider.d.ts +70 -0
- package/components/streetview/tools/mapillaryprovider.js +150 -0
- package/package.json +1 -1
- package/templates/iframe.html +1 -0
- package/templates/index.html +1 -0
- package/templates/mobile.html +1 -0
- package/templates/public/about.json +1 -1
- package/tools/app/geogirafeapp-mobile.js +2 -0
- package/tools/app/geogirafeapp.js +2 -0
- package/tools/configuration/girafeconfig.js +1 -8
- package/tools/configuration/streetviewconfig.d.ts +12 -1
- package/tools/configuration/streetviewconfig.js +26 -4
- package/tools/main.d.ts +2 -2
- package/tools/main.js +1 -1
- package/tools/state/layout.d.ts +5 -0
- package/tools/state/layout.js +2 -1
- package/tools/state/streetview.d.ts +1 -1
- package/tools/state/streetview.js +1 -1
package/README.md
CHANGED
|
@@ -263,8 +263,9 @@ Contribution guidelines are available here: [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
|
263
263
|
|
|
264
264
|
There are many ways to support GeoGirafe.
|
|
265
265
|
|
|
266
|
-
- You can use the following tag on your project to help promote GeoGirafe:
|
|
267
|
-
[](https://geogirafe.org)
|
|
266
|
+
- You can use the following tag on your project to help promote GeoGirafe: [](https://geogirafe.org)
|
|
267
|
+
code: `[](https://geogirafe.org)`
|
|
268
|
+
|
|
268
269
|
- If you are interested in providing financial assistance, please reach out to us at contact@geogirafe.org.
|
|
269
270
|
- If you have another idea how to support the project, we invite you to join us on the dedicaced discord server: https://discord.gg/kdrXjaqBbH.
|
|
270
271
|
|
package/api/apigeogirafeapp.js
CHANGED
|
@@ -5,6 +5,7 @@ import GirafeHTMLElement from '../base/GirafeHTMLElement.js';
|
|
|
5
5
|
import Map2dComponent from '../components/map-2d/component.js';
|
|
6
6
|
import Map3dComponent from '../components/map-3d/component.js';
|
|
7
7
|
import GoogleStreetViewComponent from '../components/streetview/google.js';
|
|
8
|
+
import MapillaryStreetViewComponent from '../components/streetview/mapillary.js';
|
|
8
9
|
import MapGridComponent from '../components/map-grid/component.js';
|
|
9
10
|
import { register } from 'ol/proj/proj4.js';
|
|
10
11
|
import GirafeApiContext from './apicontext.js';
|
|
@@ -40,7 +41,7 @@ export default class GeoGirafeApi extends GirafeHTMLElement {
|
|
|
40
41
|
:host{position:relative}girafe-map-grid,girafe-map-2d,girafe-map-3d{width:100%;height:100%;display:block;position:relative;overflow:hidden}girafe-basemap{display:block;position:absolute;bottom:.5rem;left:.5rem}girafe-search{width:50%;height:2.25rem;display:block;position:absolute;top:.5rem;left:.5rem;box-shadow:0 1px 4px #0000004d}girafe-selection-window{z-index:100;width:400px;height:240px;position:absolute;bottom:1rem;right:1rem}
|
|
41
42
|
</style>
|
|
42
43
|
<style>${this.customStyle}</style>
|
|
43
|
-
<girafe-map-grid><girafe-map-2d></girafe-map-2d><girafe-map-3d></girafe-map-3d><girafe-streetview-google></girafe-streetview-google></girafe-map-grid>
|
|
44
|
+
<girafe-map-grid><girafe-map-2d></girafe-map-2d><girafe-map-3d></girafe-map-3d><girafe-streetview-google></girafe-streetview-google><girafe-streetview-mapillary></girafe-streetview-mapillary></girafe-map-grid>
|
|
44
45
|
${this.htmlUnsafe(this.feedbackTemplateHtml ?? '')}`;
|
|
45
46
|
};
|
|
46
47
|
isInitialized = false;
|
|
@@ -110,6 +111,7 @@ ${this.htmlUnsafe(this.feedbackTemplateHtml ?? '')}`;
|
|
|
110
111
|
customElements.define('girafe-map-2d', Map2dComponent);
|
|
111
112
|
customElements.define('girafe-map-3d', Map3dComponent);
|
|
112
113
|
customElements.define('girafe-streetview-google', GoogleStreetViewComponent);
|
|
114
|
+
customElements.define('girafe-streetview-mapillary', MapillaryStreetViewComponent);
|
|
113
115
|
customElements.define('girafe-map-grid', MapGridComponent);
|
|
114
116
|
}
|
|
115
117
|
}
|
package/assets/i18n/de.json
CHANGED
|
@@ -328,6 +328,7 @@
|
|
|
328
328
|
"map": "Karte",
|
|
329
329
|
"Map orientation": "Kartenorientierung",
|
|
330
330
|
"map.geo.admin.ch": "map.geo.admin.ch",
|
|
331
|
+
"Mapillary": "Mapillary",
|
|
331
332
|
"Material": "Material",
|
|
332
333
|
"measure-information-full": "Vollständig",
|
|
333
334
|
"measure-information-mixed": "Unterschiedliche",
|
package/assets/i18n/en.json
CHANGED
package/assets/i18n/fr.json
CHANGED
|
@@ -328,6 +328,7 @@
|
|
|
328
328
|
"map": "Carte",
|
|
329
329
|
"Map orientation": "Orientation de la carte",
|
|
330
330
|
"map.geo.admin.ch": "map.geo.admin.ch",
|
|
331
|
+
"Mapillary": "Mapillary",
|
|
331
332
|
"Material": "Matériel",
|
|
332
333
|
"measure-information-full": "Complète",
|
|
333
334
|
"measure-information-mixed": "Mixte",
|
package/assets/i18n/it.json
CHANGED
|
@@ -328,6 +328,7 @@
|
|
|
328
328
|
"map": "Mappa",
|
|
329
329
|
"Map orientation": "Orientamento della mappa",
|
|
330
330
|
"map.geo.admin.ch": "map.geo.admin.ch",
|
|
331
|
+
"Mapillary": "Mapillary",
|
|
331
332
|
"Material": "Materiale",
|
|
332
333
|
"measure-information-full": "Completa",
|
|
333
334
|
"measure-information-mixed": "Misto",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48"><path fill="#05cb63" fill-opacity=".35" d="M24 24 10 4a24 24 0 0 1 28 0Z"/><circle cx="24" cy="24" r="6" fill="#05cb63" stroke="#fff" stroke-width="2"/></svg>
|
|
@@ -22,6 +22,11 @@ declare class LayoutComponent extends GirafeHTMLElement implements IGirafePanel
|
|
|
22
22
|
readonly tagName: "girafe-streetview-google";
|
|
23
23
|
readonly label: "Google Street View";
|
|
24
24
|
readonly provider: "google";
|
|
25
|
+
} | {
|
|
26
|
+
readonly id: "streetview-mapillary";
|
|
27
|
+
readonly tagName: "girafe-streetview-mapillary";
|
|
28
|
+
readonly label: "Mapillary";
|
|
29
|
+
readonly provider: "mapillary";
|
|
25
30
|
})[];
|
|
26
31
|
constructor();
|
|
27
32
|
private get layout();
|
|
@@ -36,6 +36,10 @@ declare class MapGridComponent extends GirafeHTMLElement {
|
|
|
36
36
|
/** The splitter that is currently dragged, if any. */
|
|
37
37
|
private draggedSplitter;
|
|
38
38
|
constructor();
|
|
39
|
+
/**
|
|
40
|
+
* The Grid contains the Maps, which need to be displayed in Fullscreen Mode.
|
|
41
|
+
*/
|
|
42
|
+
protected get isFullscreenComponent(): boolean;
|
|
39
43
|
private get layout();
|
|
40
44
|
private get grid();
|
|
41
45
|
protected connectedCallback(): void;
|
|
@@ -31,6 +31,12 @@ ${this.htmlUnsafe(this.feedbackTemplateHtml ?? '')}`;
|
|
|
31
31
|
constructor() {
|
|
32
32
|
super('map-grid');
|
|
33
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* The Grid contains the Maps, which need to be displayed in Fullscreen Mode.
|
|
36
|
+
*/
|
|
37
|
+
get isFullscreenComponent() {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
34
40
|
get layout() {
|
|
35
41
|
return this.state.layout;
|
|
36
42
|
}
|
|
@@ -15,6 +15,9 @@ export default abstract class StreetViewComponent extends GirafeHTMLElement {
|
|
|
15
15
|
template: () => import("uhtml").Hole;
|
|
16
16
|
loading: boolean;
|
|
17
17
|
hasFootage: boolean;
|
|
18
|
+
isFullscreen: boolean;
|
|
19
|
+
/** The Fullscreen API is not available everywhere: on iPhone, only videos can be displayed in fullscreen. */
|
|
20
|
+
readonly canBeFullscreen: boolean;
|
|
18
21
|
protected readonly provider: StreetViewProvider;
|
|
19
22
|
private adapter;
|
|
20
23
|
/** Promise of the currently running adapter creation, to prevent creating it twice. */
|
|
@@ -26,11 +29,11 @@ export default abstract class StreetViewComponent extends GirafeHTMLElement {
|
|
|
26
29
|
private readonly marker;
|
|
27
30
|
private readonly markerSource;
|
|
28
31
|
private readonly markerLayer;
|
|
29
|
-
protected constructor(provider: StreetViewProvider);
|
|
32
|
+
protected constructor(provider: StreetViewProvider, markerIconSrc: string);
|
|
30
33
|
private get olMap();
|
|
31
34
|
private get cellId();
|
|
32
35
|
private get isDisplayed();
|
|
33
|
-
|
|
36
|
+
protected get searchRadius(): number;
|
|
34
37
|
/** Creates the adapter of the provider, loading its module on demand. */
|
|
35
38
|
protected abstract createAdapter(): Promise<StreetViewProviderAdapter>;
|
|
36
39
|
/** The StreetView is displayed in a Cell of the Grid, like the Maps. */
|
|
@@ -45,6 +48,10 @@ export default abstract class StreetViewComponent extends GirafeHTMLElement {
|
|
|
45
48
|
*/
|
|
46
49
|
private onDisplayToggled;
|
|
47
50
|
private createAdapterOnce;
|
|
51
|
+
/** Displays the StreetView alone on the whole screen, or leaves the fullscreen when it is already displayed so. */
|
|
52
|
+
toggleFullscreen(): void;
|
|
53
|
+
/** The fullscreen can also be left with the keyboard (Esc), without the button. */
|
|
54
|
+
onFullscreenChanged(): void;
|
|
48
55
|
private onMapClick;
|
|
49
56
|
private showClosestFootage;
|
|
50
57
|
private onFootageChanged;
|
|
@@ -22,32 +22,32 @@ export default class StreetViewComponent extends GirafeHTMLElement {
|
|
|
22
22
|
return uHtml `<style>
|
|
23
23
|
.hidden{display:none!important}.gg-rotate90{transform:rotate(90deg)}.gg-rotate180{transform:rotate(180deg)}.gg-rotate270{transform:rotate(270deg)}img{filter:var(--svg-filter)}img.legend-image{filter:var(--svg-map-filter);background:var(--svg-legend-bkg)}div{scrollbar-width:thin}a,a:visited{color:var(--link-color)}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}@keyframes spin-wait{0%{transform:rotate(0)}7%{transform:rotate(360deg)}to{transform:rotate(360deg)}}.gg-spin{animation-name:spin;animation-duration:2s;animation-timing-function:linear;animation-iteration-count:infinite}.gg-spin-wait{animation-name:spin-wait;animation-duration:10s;animation-timing-function:linear;animation-iteration-count:infinite}::-webkit-scrollbar{width:5px}::-webkit-scrollbar-thumb{background:#999}button,input,select,textarea{font:inherit}.gg-button,.gg-select,.gg-input,.gg-textarea{background-color:var(--bkg-color);color:var(--text-color);border:var(--app-standard-border);box-sizing:border-box;cursor:pointer;border-radius:3px;outline:0;margin:0;padding:0 0 0 .5rem;display:inline-block}.gg-label{background-color:var(--bkg-color);color:var(--text-color);border:none;align-items:center;margin:0;padding:0;display:flex}.gg-button,.gg-select,.gg-input,.gg-label{min-height:calc(var(--app-standard-height) / 1.5)}.gg-textarea{max-height:initial;resize:vertical;height:6rem;padding:.5rem;line-height:1.3rem}.gg-input{cursor:text}.gg-checkbox{accent-color:var(--text-color);cursor:pointer;width:1.2rem}.gg-range{accent-color:var(--text-color)}.gg-button{padding:0 .5rem}.gg-button.active{border:solid 1px var(--text-color-grad1);background-color:var(--bkg-color-grad2)}.gg-button:disabled{background-color:var(--bkg-color-grad1);color:var(--text-color-grad2);cursor:not-allowed;border:none}.gg-button:disabled img{filter:opacity(.6)}.gg-input:disabled,.gg-select:disabled,.gg-textarea:disabled{background-color:var(--bkg-color-grad1);color:var(--text-color-grad2);cursor:not-allowed}.gg-button>img{vertical-align:middle}.gg-icon-button{color:var(--text-color);cursor:pointer;background-color:#0000;border:none;flex-direction:column;justify-content:center;align-items:center;padding:0;display:flex}.gg-icon{justify-content:center;align-items:center;display:flex}.gg-big,.gg-big-withtext{min-width:var(--app-standard-height);min-height:var(--app-standard-height);max-height:var(--app-standard-height)}.gg-big img,.gg-big-withtext img{width:calc(var(--app-standard-height) - 1.5rem);margin:0}.gg-big-withtext span{font-variant:small-caps;padding:0 1rem;font-size:.9rem}.gg-medium,.gg-medium-withtext{min-width:calc(var(--app-standard-height) / 1.2);min-height:calc(var(--app-standard-height) / 1.2);max-height:calc(var(--app-standard-height) / 1.2);flex-direction:row}.gg-medium img{width:calc(var(--app-standard-height) / 2.4);margin:0}.gg-medium-withtext img{width:calc(var(--app-standard-height) / 2.4);margin-left:.5rem}.gg-medium-withtext span{padding:0 1rem 0 .5rem;font-size:.9rem}.gg-small,.gg-small-withtext{min-width:calc(var(--app-standard-height) / 2);min-height:calc(var(--app-standard-height) / 2);max-height:calc(var(--app-standard-height) / 2);flex-direction:row}.gg-small img{width:calc(var(--app-standard-height) / 3);margin:0}.gg-small-withtext img{width:calc(var(--app-standard-height) / 3);margin-left:.5rem}.gg-small-withtext span{padding:0 .5rem 0 .3rem;font-size:.9rem}.gg-button:hover:not(:disabled),.gg-select:hover:not(:disabled),.gg-input:hover:not(:disabled),.gg-textarea:hover:not(:disabled),.gg-icon-button:hover:not(:disabled){background-color:var(--bkg-color-grad1)}.gg-opacity{opacity:.5}.gg-opacity:hover{opacity:1;background-color:#0000}.gg-tabs{cursor:pointer;grid-auto-flow:column;padding-bottom:1rem;font-size:1rem;display:grid}.gg-tab{border:none;border-bottom:var(--app-standard-border);cursor:pointer;color:var(--text-color);background:0 0;padding:.5rem}.gg-tab.active{border-bottom:solid 1px var(--text-color)}.girafe-button-big,.girafe-button-large,.girafe-button-small,.girafe-button-tiny{color:var(--text-color);background-color:#0000;border:none;flex-direction:column;display:flex}.girafe-button-big:hover,.girafe-button-large:hover,.girafe-button-small:hover,.girafe-button-tiny:hover{background-color:var(--bkg-color-grad1);cursor:pointer}.girafe-button-big.dark,.girafe-button-large.dark,.girafe-button-small.dark,.girafe-button-tiny.dark{background-color:var(--bkg-color);filter:invert()}.girafe-button-big{width:var(--app-standard-height);height:var(--app-standard-height);align-items:center;padding:1rem}.girafe-button-big img{overflow:hidden}.girafe-button-large{flex-direction:row}.girafe-button-large img{height:2rem;margin:.3rem}.girafe-button-large span{height:2rem;margin:.3rem;line-height:2rem}.girafe-button-small{min-width:calc(var(--app-standard-height) / 2);height:calc(var(--app-standard-height) / 2);align-items:center;padding:.5rem}.girafe-button-small img{overflow:hidden}.girafe-button-small span{text-align:left;text-overflow:ellipsis;width:100%;overflow:hidden}.girafe-button-tiny{align-items:center;width:1rem;height:1rem;padding:0}.girafe-button-tiny img{overflow:hidden}.girafe-onboarding-theme{background-color:var(--bkg-color)!important;color:var(--text-color)!important}.girafe-onboarding-theme button{background-color:var(--bkg-color)!important;color:var(--text-color)!important;text-shadow:none!important}.girafe-onboarding-theme button.driver-popover-close-btn{z-index:10000}.tippy-box{background-color:var(--bkg-color)!important;border:var(--app-standard-border)!important}.tippy-content{color:var(--text-color)!important}.tippy-arrow{color:var(--bkg-color)!important}.tippy-box[data-theme~=error]{background-color:var(--error-color);white-space:pre-line}div.tippy-box[data-theme=image-popup]{border:var(--app-standard-border)!important;& div.tippy-content{background-color:var(--bkg-color)!important;& img{max-width:20rem;max-height:20rem}}& div.tippy-arrow{color:var(--bkg-color)!important}}
|
|
24
24
|
</style><style>
|
|
25
|
-
#streetview{background-color:var(--bkg-color);width:100%;height:100%;position:relative;overflow:hidden}#viewer{position:absolute;inset:0}.overlay{text-align:center;color:var(--text-color);pointer-events:none;z-index:1;flex-direction:column;justify-content:center;align-items:center;gap:1rem;padding:1rem;font-weight:600;display:flex;position:absolute;inset:0}.no-data{color:#999;font-variant:small-caps;gap:.3rem;font-size:1rem;font-weight:400}.hidden{display:none}
|
|
25
|
+
#streetview{background-color:var(--bkg-color);width:100%;height:100%;position:relative;overflow:hidden}#viewer{position:absolute;inset:0}.overlay{text-align:center;color:var(--text-color);pointer-events:none;z-index:1;flex-direction:column;justify-content:center;align-items:center;gap:1rem;padding:1rem;font-weight:600;display:flex;position:absolute;inset:0}.no-data{color:#999;font-variant:small-caps;gap:.3rem;font-size:1rem;font-weight:400}.fullscreen-button{z-index:2;background-color:var(--bkg-color);border-radius:.25rem;width:2rem;height:2rem;position:absolute;top:.5rem;right:.5rem}.fullscreen-button>img{width:55%;height:auto}.hidden{display:none}
|
|
26
26
|
</style>
|
|
27
27
|
<style>${this.customStyle}</style>
|
|
28
|
-
<div id="streetview"><div id="viewer"></div><div class="${this.loading ? 'overlay' : 'overlay hidden'}"><img alt="loading-icon" src="icons/loading.svg" class="gg-spin"> <span i18n="Loading StreetView...">Loading StreetView...</span></div><div class="${!this.loading && !this.hasFootage ? 'overlay no-data' : 'overlay no-data hidden'}"><span i18n="Click on the map to display the StreetView at this location">Click on the map to display the StreetView at this location</span></div></div>
|
|
28
|
+
<div id="streetview" onfullscreenchange="${() => this.onFullscreenChanged()}"><div id="viewer"></div><div class="${this.loading ? 'overlay' : 'overlay hidden'}"><img alt="loading-icon" src="icons/loading.svg" class="gg-spin"> <span i18n="Loading StreetView...">Loading StreetView...</span></div><div class="${!this.loading && !this.hasFootage ? 'overlay no-data' : 'overlay no-data hidden'}"><span i18n="Click on the map to display the StreetView at this location">Click on the map to display the StreetView at this location</span></div><button tip="fullscreen-on" class="${this.canBeFullscreen && this.hasFootage && !this.isFullscreen ? 'gg-icon-button fullscreen-button' : 'gg-icon-button fullscreen-button hidden'}" onclick="${() => this.toggleFullscreen()}"><img alt="fullscreen-icon" src="icons/fullscreen.svg"></button> <button tip="fullscreen-off" class="${this.isFullscreen ? 'gg-icon-button fullscreen-button' : 'gg-icon-button fullscreen-button hidden'}" onclick="${() => this.toggleFullscreen()}"><img alt="fullscreen-exit-icon" src="icons/fullscreen-exit.svg"></button></div>
|
|
29
29
|
${this.htmlUnsafe(this.feedbackTemplateHtml ?? '')}`;
|
|
30
30
|
};
|
|
31
31
|
loading = false;
|
|
32
32
|
hasFootage = false;
|
|
33
|
+
isFullscreen = false;
|
|
34
|
+
/** The Fullscreen API is not available everywhere: on iPhone, only videos can be displayed in fullscreen. */
|
|
35
|
+
canBeFullscreen = document.fullscreenEnabled;
|
|
33
36
|
provider;
|
|
34
37
|
adapter = null;
|
|
35
38
|
/** Promise of the currently running adapter creation, to prevent creating it twice. */
|
|
36
39
|
adapterCreation = null;
|
|
37
40
|
/** The view of the footage displayed by the adapter, to tell the views coming from a shared state apart. */
|
|
38
41
|
displayedView = null;
|
|
39
|
-
markerIcon
|
|
40
|
-
src: 'icons/streetview-marker.svg',
|
|
41
|
-
anchor: [0.5, 0.5],
|
|
42
|
-
rotateWithView: true
|
|
43
|
-
});
|
|
42
|
+
markerIcon;
|
|
44
43
|
markerGeometry = new Point([0, 0]);
|
|
45
44
|
marker = new Feature(this.markerGeometry);
|
|
46
45
|
markerSource = new VectorSource();
|
|
47
46
|
markerLayer = new VectorLayer({ source: this.markerSource, zIndex: 2000 });
|
|
48
|
-
constructor(provider) {
|
|
47
|
+
constructor(provider, markerIconSrc) {
|
|
49
48
|
super(`streetview-${provider}`);
|
|
50
49
|
this.provider = provider;
|
|
50
|
+
this.markerIcon = new Icon({ src: markerIconSrc, anchor: [0.5, 0.5], rotateWithView: true });
|
|
51
51
|
this.marker.setStyle(new Style({ image: this.markerIcon }));
|
|
52
52
|
this.onMapClick = this.onMapClick.bind(this);
|
|
53
53
|
}
|
|
@@ -130,6 +130,18 @@ ${this.htmlUnsafe(this.feedbackTemplateHtml ?? '')}`;
|
|
|
130
130
|
})();
|
|
131
131
|
return this.adapterCreation;
|
|
132
132
|
}
|
|
133
|
+
/** Displays the StreetView alone on the whole screen, or leaves the fullscreen when it is already displayed so. */
|
|
134
|
+
toggleFullscreen() {
|
|
135
|
+
const fullscreenToggle = this.isFullscreen
|
|
136
|
+
? document.exitFullscreen()
|
|
137
|
+
: this.getById('streetview').requestFullscreen();
|
|
138
|
+
fullscreenToggle.catch((error) => console.error(error));
|
|
139
|
+
}
|
|
140
|
+
/** The fullscreen can also be left with the keyboard (Esc), without the button. */
|
|
141
|
+
onFullscreenChanged() {
|
|
142
|
+
this.isFullscreen = this.shadow.fullscreenElement !== null;
|
|
143
|
+
this.refreshRender();
|
|
144
|
+
}
|
|
133
145
|
onMapClick(event) {
|
|
134
146
|
if (!this.adapter || !this.isDisplayed || !this.canExecute('map.mouseclick')) {
|
|
135
147
|
return;
|
|
@@ -3,7 +3,7 @@ import StreetViewComponent from './component.js';
|
|
|
3
3
|
/** The StreetView displaying the footage of Google Street View. */
|
|
4
4
|
export default class GoogleStreetViewComponent extends StreetViewComponent {
|
|
5
5
|
constructor() {
|
|
6
|
-
super('google');
|
|
6
|
+
super('google', 'icons/streetview-marker.svg');
|
|
7
7
|
}
|
|
8
8
|
async createAdapter() {
|
|
9
9
|
const apiKey = this.context.configManager.Config.streetview?.google?.apiKey;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import StreetViewComponent from './component.js';
|
|
2
|
+
import type { StreetViewProviderAdapter } from './tools/provider.js';
|
|
3
|
+
/** The StreetView displaying the footage of Mapillary. */
|
|
4
|
+
export default class MapillaryStreetViewComponent extends StreetViewComponent {
|
|
5
|
+
constructor();
|
|
6
|
+
protected get searchRadius(): number;
|
|
7
|
+
protected createAdapter(): Promise<StreetViewProviderAdapter>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
import { MAPILLARY_MAX_SEARCH_RADIUS } from '../../tools/configuration/streetviewconfig.js';
|
|
3
|
+
import StreetViewComponent from './component.js';
|
|
4
|
+
/** The StreetView displaying the footage of Mapillary. */
|
|
5
|
+
export default class MapillaryStreetViewComponent extends StreetViewComponent {
|
|
6
|
+
constructor() {
|
|
7
|
+
super('mapillary', 'icons/streetview-marker-mapillary.svg');
|
|
8
|
+
}
|
|
9
|
+
get searchRadius() {
|
|
10
|
+
return this.context.configManager.Config.streetview?.mapillary?.searchRadius ?? MAPILLARY_MAX_SEARCH_RADIUS;
|
|
11
|
+
}
|
|
12
|
+
async createAdapter() {
|
|
13
|
+
const accessToken = this.context.configManager.Config.streetview?.mapillary?.accessToken;
|
|
14
|
+
if (!accessToken) {
|
|
15
|
+
throw new Error('The Mapillary StreetView cannot be displayed: streetview.mapillary.accessToken is not configured');
|
|
16
|
+
}
|
|
17
|
+
const { default: MapillaryStreetViewProvider } = await import('./tools/mapillaryprovider');
|
|
18
|
+
return new MapillaryStreetViewProvider(accessToken);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -36,6 +36,22 @@
|
|
|
36
36
|
gap: 0.3rem;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
.fullscreen-button {
|
|
40
|
+
position: absolute;
|
|
41
|
+
top: 0.5rem;
|
|
42
|
+
right: 0.5rem;
|
|
43
|
+
z-index: 2;
|
|
44
|
+
width: 2rem;
|
|
45
|
+
height: 2rem;
|
|
46
|
+
border-radius: 0.25rem;
|
|
47
|
+
background-color: var(--bkg-color);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.fullscreen-button > img {
|
|
51
|
+
width: 55%;
|
|
52
|
+
height: auto;
|
|
53
|
+
}
|
|
54
|
+
|
|
39
55
|
.hidden {
|
|
40
56
|
display: none;
|
|
41
57
|
}
|
|
@@ -22,7 +22,12 @@ function loadMapsApi(apiKey) {
|
|
|
22
22
|
});
|
|
23
23
|
script.src = `https://maps.googleapis.com/maps/api/js?${params}`;
|
|
24
24
|
script.async = true;
|
|
25
|
-
script.addEventListener('error', () =>
|
|
25
|
+
script.addEventListener('error', () => {
|
|
26
|
+
// Allows the StreetView Component to try again
|
|
27
|
+
mapsApiLoading = null;
|
|
28
|
+
script.remove();
|
|
29
|
+
reject(new Error('The Google Maps JavaScript API could not be loaded'));
|
|
30
|
+
});
|
|
26
31
|
document.head.appendChild(script);
|
|
27
32
|
});
|
|
28
33
|
return mapsApiLoading;
|
|
@@ -51,7 +56,9 @@ export default class GoogleStreetViewProvider {
|
|
|
51
56
|
this.service = new library.StreetViewService();
|
|
52
57
|
this.panorama = new library.StreetViewPanorama(target, {
|
|
53
58
|
visible: false,
|
|
54
|
-
pov: { heading: 0, pitch: 0 }
|
|
59
|
+
pov: { heading: 0, pitch: 0 },
|
|
60
|
+
// The StreetView Component provides the same fullscreen button for every provider
|
|
61
|
+
fullscreenControl: false
|
|
55
62
|
});
|
|
56
63
|
const notifyFootageChanged = () => {
|
|
57
64
|
const footage = this.getFootage();
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { Coordinate } from 'ol/coordinate.js';
|
|
2
|
+
import type { Footage, PointOfView, StreetViewProviderAdapter } from './provider.js';
|
|
3
|
+
type MapillaryImage = {
|
|
4
|
+
lngLat: {
|
|
5
|
+
lng: number;
|
|
6
|
+
lat: number;
|
|
7
|
+
};
|
|
8
|
+
computedCompassAngle: number;
|
|
9
|
+
cameraType: string;
|
|
10
|
+
};
|
|
11
|
+
type MapillaryViewer = {
|
|
12
|
+
on(type: 'image', handler: (event: {
|
|
13
|
+
image: MapillaryImage;
|
|
14
|
+
}) => void): void;
|
|
15
|
+
on(type: 'pov', handler: () => void): void;
|
|
16
|
+
moveTo(imageId: string): Promise<MapillaryImage>;
|
|
17
|
+
getPointOfView(): Promise<{
|
|
18
|
+
bearing: number;
|
|
19
|
+
tilt: number;
|
|
20
|
+
}>;
|
|
21
|
+
setCenter(center: number[]): void;
|
|
22
|
+
resize(): void;
|
|
23
|
+
};
|
|
24
|
+
type MapillaryJs = {
|
|
25
|
+
Viewer: new (options: {
|
|
26
|
+
accessToken: string;
|
|
27
|
+
container: HTMLElement;
|
|
28
|
+
component: {
|
|
29
|
+
cover: boolean;
|
|
30
|
+
};
|
|
31
|
+
}) => MapillaryViewer;
|
|
32
|
+
};
|
|
33
|
+
declare global {
|
|
34
|
+
interface Window {
|
|
35
|
+
mapillary?: MapillaryJs;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The center of the viewport, in the coordinates of a 360° image (from 0 to 1, from its top-left corner),
|
|
40
|
+
* for a direction of sight. The center of the image is in the direction it was taken (its compass angle).
|
|
41
|
+
*/
|
|
42
|
+
export declare function getSphericalImageCenter(pov: PointOfView, compassAngle: number): number[];
|
|
43
|
+
/**
|
|
44
|
+
* The Mapillary footage, displayed by a MapillaryJS Viewer.
|
|
45
|
+
* This module is the only place where MapillaryJS and the Mapillary API are used. It is loaded on demand
|
|
46
|
+
* by the StreetView Component, so that MapillaryJS stays out of the application as long as
|
|
47
|
+
* no Mapillary StreetView is displayed.
|
|
48
|
+
* The access token is visible to the user: it must be a client token.
|
|
49
|
+
*/
|
|
50
|
+
export default class MapillaryStreetViewProvider implements StreetViewProviderAdapter {
|
|
51
|
+
private readonly accessToken;
|
|
52
|
+
private target;
|
|
53
|
+
private viewer;
|
|
54
|
+
private image;
|
|
55
|
+
constructor(accessToken: string);
|
|
56
|
+
initialize(target: HTMLElement, onFootageChanged: (footage: Footage) => void): Promise<void>;
|
|
57
|
+
private getFootage;
|
|
58
|
+
/**
|
|
59
|
+
* The Mapillary API returns the "best" images within the radius, not the closest one:
|
|
60
|
+
* the closest one is chosen among them.
|
|
61
|
+
*/
|
|
62
|
+
private findClosestImageId;
|
|
63
|
+
/**
|
|
64
|
+
* The direction of sight can only be applied to 360° images:
|
|
65
|
+
* the other images are displayed in the direction they were taken.
|
|
66
|
+
*/
|
|
67
|
+
showClosestFootage(lonLat: Coordinate, radius: number, pov?: PointOfView): Promise<boolean>;
|
|
68
|
+
setVisible(visible: boolean): void;
|
|
69
|
+
}
|
|
70
|
+
export {};
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { getDistance } from 'ol/sphere.js';
|
|
2
|
+
const MAPILLARY_JS_URL = 'https://unpkg.com/mapillary-js@4.1.2/dist';
|
|
3
|
+
const MAPILLARY_JS_SCRIPT = {
|
|
4
|
+
url: `${MAPILLARY_JS_URL}/mapillary.js`,
|
|
5
|
+
integrity: 'sha384-1AlAxcgdzKreJ5f2K+t7SW3pEE0ek9u3lUwlZXX+v+FtEk1tWSg6DBVLb3ZKhpB+'
|
|
6
|
+
};
|
|
7
|
+
const MAPILLARY_JS_STYLESHEET = {
|
|
8
|
+
url: `${MAPILLARY_JS_URL}/mapillary.css`,
|
|
9
|
+
integrity: 'sha384-IamMZxz60pSNzUk3cW2nl3uYUdpiDoQpLJrBoAAezEE+QaOYCVA9rfi/8Cx0x15T'
|
|
10
|
+
};
|
|
11
|
+
const IMAGES_SEARCH_URL = 'https://graph.mapillary.com/images';
|
|
12
|
+
const MAX_SEARCHED_IMAGES = 100;
|
|
13
|
+
let mapillaryJsLoading = null;
|
|
14
|
+
/**
|
|
15
|
+
* Loads MapillaryJS once from the CDN, when the first Mapillary StreetView is displayed.
|
|
16
|
+
* The integrity of the script is checked, as it does not come from the application.
|
|
17
|
+
*/
|
|
18
|
+
function loadMapillaryJs() {
|
|
19
|
+
mapillaryJsLoading ??= new Promise((resolve, reject) => {
|
|
20
|
+
const script = document.createElement('script');
|
|
21
|
+
script.src = MAPILLARY_JS_SCRIPT.url;
|
|
22
|
+
script.integrity = MAPILLARY_JS_SCRIPT.integrity;
|
|
23
|
+
script.crossOrigin = 'anonymous';
|
|
24
|
+
script.async = true;
|
|
25
|
+
script.addEventListener('load', () => window.mapillary ? resolve(window.mapillary) : reject(new Error('MapillaryJS is not available')));
|
|
26
|
+
script.addEventListener('error', () => {
|
|
27
|
+
// Allows the StreetView Component to try again
|
|
28
|
+
mapillaryJsLoading = null;
|
|
29
|
+
script.remove();
|
|
30
|
+
reject(new Error('MapillaryJS could not be loaded'));
|
|
31
|
+
});
|
|
32
|
+
document.head.appendChild(script);
|
|
33
|
+
});
|
|
34
|
+
return mapillaryJsLoading;
|
|
35
|
+
}
|
|
36
|
+
/** The stylesheet is added next to the viewer, as the global styles do not reach the Shadow DOM of the Component. */
|
|
37
|
+
function addMapillaryJsStylesheet(target) {
|
|
38
|
+
const link = document.createElement('link');
|
|
39
|
+
link.rel = 'stylesheet';
|
|
40
|
+
link.href = MAPILLARY_JS_STYLESHEET.url;
|
|
41
|
+
link.integrity = MAPILLARY_JS_STYLESHEET.integrity;
|
|
42
|
+
link.crossOrigin = 'anonymous';
|
|
43
|
+
target.appendChild(link);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The center of the viewport, in the coordinates of a 360° image (from 0 to 1, from its top-left corner),
|
|
47
|
+
* for a direction of sight. The center of the image is in the direction it was taken (its compass angle).
|
|
48
|
+
*/
|
|
49
|
+
export function getSphericalImageCenter(pov, compassAngle) {
|
|
50
|
+
const x = (((0.5 + (pov.heading - compassAngle) / 360) % 1) + 1) % 1;
|
|
51
|
+
const y = 0.5 - pov.pitch / 180;
|
|
52
|
+
return [x, y];
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The Mapillary footage, displayed by a MapillaryJS Viewer.
|
|
56
|
+
* This module is the only place where MapillaryJS and the Mapillary API are used. It is loaded on demand
|
|
57
|
+
* by the StreetView Component, so that MapillaryJS stays out of the application as long as
|
|
58
|
+
* no Mapillary StreetView is displayed.
|
|
59
|
+
* The access token is visible to the user: it must be a client token.
|
|
60
|
+
*/
|
|
61
|
+
export default class MapillaryStreetViewProvider {
|
|
62
|
+
accessToken;
|
|
63
|
+
target;
|
|
64
|
+
viewer;
|
|
65
|
+
image = null;
|
|
66
|
+
constructor(accessToken) {
|
|
67
|
+
this.accessToken = accessToken;
|
|
68
|
+
}
|
|
69
|
+
async initialize(target, onFootageChanged) {
|
|
70
|
+
const mapillaryJs = await loadMapillaryJs();
|
|
71
|
+
addMapillaryJsStylesheet(target);
|
|
72
|
+
this.target = target;
|
|
73
|
+
this.setVisible(false);
|
|
74
|
+
// The cover asks for a click before displaying the footage: it is not needed, as the footage is chosen on the map
|
|
75
|
+
this.viewer = new mapillaryJs.Viewer({
|
|
76
|
+
accessToken: this.accessToken,
|
|
77
|
+
container: target,
|
|
78
|
+
component: { cover: false }
|
|
79
|
+
});
|
|
80
|
+
new ResizeObserver(() => this.viewer.resize()).observe(target);
|
|
81
|
+
const notifyFootageChanged = () => {
|
|
82
|
+
this.getFootage()
|
|
83
|
+
.then((footage) => footage && onFootageChanged(footage))
|
|
84
|
+
.catch((error) => console.error(error));
|
|
85
|
+
};
|
|
86
|
+
this.viewer.on('image', (event) => {
|
|
87
|
+
this.image = event.image;
|
|
88
|
+
notifyFootageChanged();
|
|
89
|
+
});
|
|
90
|
+
this.viewer.on('pov', notifyFootageChanged);
|
|
91
|
+
}
|
|
92
|
+
async getFootage() {
|
|
93
|
+
if (!this.image) {
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
const pov = await this.viewer.getPointOfView();
|
|
97
|
+
return { lonLat: [this.image.lngLat.lng, this.image.lngLat.lat], heading: pov.bearing, pitch: pov.tilt };
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* The Mapillary API returns the "best" images within the radius, not the closest one:
|
|
101
|
+
* the closest one is chosen among them.
|
|
102
|
+
*/
|
|
103
|
+
async findClosestImageId(lonLat, radius) {
|
|
104
|
+
const params = new URLSearchParams({
|
|
105
|
+
access_token: this.accessToken,
|
|
106
|
+
fields: 'id,geometry,computed_geometry',
|
|
107
|
+
lng: String(lonLat[0]),
|
|
108
|
+
lat: String(lonLat[1]),
|
|
109
|
+
radius: String(radius),
|
|
110
|
+
limit: String(MAX_SEARCHED_IMAGES)
|
|
111
|
+
});
|
|
112
|
+
const response = await fetch(`${IMAGES_SEARCH_URL}?${params}`);
|
|
113
|
+
if (!response.ok) {
|
|
114
|
+
throw new Error(`The Mapillary images could not be searched (HTTP ${response.status})`);
|
|
115
|
+
}
|
|
116
|
+
const { data } = (await response.json());
|
|
117
|
+
let closestId = null;
|
|
118
|
+
let closestDistance = Infinity;
|
|
119
|
+
for (const image of data) {
|
|
120
|
+
const distance = getDistance(lonLat, (image.computed_geometry ?? image.geometry).coordinates);
|
|
121
|
+
if (distance < closestDistance) {
|
|
122
|
+
closestId = image.id;
|
|
123
|
+
closestDistance = distance;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return closestId;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* The direction of sight can only be applied to 360° images:
|
|
130
|
+
* the other images are displayed in the direction they were taken.
|
|
131
|
+
*/
|
|
132
|
+
async showClosestFootage(lonLat, radius, pov) {
|
|
133
|
+
const imageId = await this.findClosestImageId(lonLat, radius);
|
|
134
|
+
if (!imageId) {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
const image = await this.viewer.moveTo(imageId);
|
|
138
|
+
this.image = image;
|
|
139
|
+
if (pov && image.cameraType === 'spherical') {
|
|
140
|
+
this.viewer.setCenter(getSphericalImageCenter(pov, image.computedCompassAngle));
|
|
141
|
+
}
|
|
142
|
+
this.setVisible(true);
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
145
|
+
setVisible(visible) {
|
|
146
|
+
if (this.target) {
|
|
147
|
+
this.target.style.visibility = visible && this.image !== null ? 'visible' : 'hidden';
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
package/package.json
CHANGED
package/templates/iframe.html
CHANGED
|
@@ -82,6 +82,7 @@
|
|
|
82
82
|
<girafe-map-2d></girafe-map-2d>
|
|
83
83
|
<girafe-map-3d></girafe-map-3d>
|
|
84
84
|
<girafe-streetview-google></girafe-streetview-google>
|
|
85
|
+
<girafe-streetview-mapillary></girafe-streetview-mapillary>
|
|
85
86
|
</girafe-map-grid>
|
|
86
87
|
<girafe-basemap></girafe-basemap>
|
|
87
88
|
<girafe-search id="search"></girafe-search>
|
package/templates/index.html
CHANGED
|
@@ -110,6 +110,7 @@
|
|
|
110
110
|
<girafe-map-2d></girafe-map-2d>
|
|
111
111
|
<girafe-map-3d></girafe-map-3d>
|
|
112
112
|
<girafe-streetview-google></girafe-streetview-google>
|
|
113
|
+
<girafe-streetview-mapillary></girafe-streetview-mapillary>
|
|
113
114
|
</girafe-map-grid>
|
|
114
115
|
<div class="info-area">
|
|
115
116
|
<girafe-basemap data-tour="basemap-selection"></girafe-basemap>
|
package/templates/mobile.html
CHANGED
|
@@ -97,6 +97,7 @@
|
|
|
97
97
|
<girafe-map-2d></girafe-map-2d>
|
|
98
98
|
<girafe-map-3d></girafe-map-3d>
|
|
99
99
|
<girafe-streetview-google></girafe-streetview-google>
|
|
100
|
+
<girafe-streetview-mapillary></girafe-streetview-mapillary>
|
|
100
101
|
</girafe-map-grid>
|
|
101
102
|
<girafe-infobox></girafe-infobox>
|
|
102
103
|
</div>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"1.3.0-dev.
|
|
1
|
+
{"version":"1.3.0-dev.3053452205", "build":"3053452205", "date":"11/11/2026"}
|
|
@@ -12,6 +12,7 @@ import Map2dComponent from '../../components/map-2d/component.js';
|
|
|
12
12
|
import DeprecatedMapComponent from '../../components/map-2d/deprecatedmapcomponent.js';
|
|
13
13
|
import Map3dComponent from '../../components/map-3d/component.js';
|
|
14
14
|
import GoogleStreetViewComponent from '../../components/streetview/google.js';
|
|
15
|
+
import MapillaryStreetViewComponent from '../../components/streetview/mapillary.js';
|
|
15
16
|
import MapGridComponent from '../../components/map-grid/component.js';
|
|
16
17
|
import MenuMobile3dButton from '../../components/menu-buttons-mobile/MenuMobile3dButton.js';
|
|
17
18
|
import MenuMobileDrawingButton from '../../components/menu-buttons-mobile/MenuMobileDrawingButton.js';
|
|
@@ -52,6 +53,7 @@ export default class GeoGirafeAppMobile extends GeoGirafeApp {
|
|
|
52
53
|
customElements.define('girafe-map-2d', Map2dComponent);
|
|
53
54
|
customElements.define('girafe-map-3d', Map3dComponent);
|
|
54
55
|
customElements.define('girafe-streetview-google', GoogleStreetViewComponent);
|
|
56
|
+
customElements.define('girafe-streetview-mapillary', MapillaryStreetViewComponent);
|
|
55
57
|
customElements.define('girafe-map-grid', MapGridComponent);
|
|
56
58
|
// Deprecated alias of <girafe-map-2d>, kept for the applications that were not migrated yet.
|
|
57
59
|
customElements.define('girafe-map', DeprecatedMapComponent);
|
|
@@ -21,6 +21,7 @@ import Map2dComponent from '../../components/map-2d/component.js';
|
|
|
21
21
|
import DeprecatedMapComponent from '../../components/map-2d/deprecatedmapcomponent.js';
|
|
22
22
|
import Map3dComponent from '../../components/map-3d/component.js';
|
|
23
23
|
import GoogleStreetViewComponent from '../../components/streetview/google.js';
|
|
24
|
+
import MapillaryStreetViewComponent from '../../components/streetview/mapillary.js';
|
|
24
25
|
import MapGridComponent from '../../components/map-grid/component.js';
|
|
25
26
|
import MenuButtonComponent from '../../components/menubutton/component.js';
|
|
26
27
|
import ModalsComponent from '../../components/modals/component.js';
|
|
@@ -126,6 +127,7 @@ export default class GeoGirafeApp {
|
|
|
126
127
|
customElements.define('girafe-map-2d', Map2dComponent);
|
|
127
128
|
customElements.define('girafe-map-3d', Map3dComponent);
|
|
128
129
|
customElements.define('girafe-streetview-google', GoogleStreetViewComponent);
|
|
130
|
+
customElements.define('girafe-streetview-mapillary', MapillaryStreetViewComponent);
|
|
129
131
|
customElements.define('girafe-map-grid', MapGridComponent);
|
|
130
132
|
// Deprecated alias of <girafe-map-2d>, kept for the applications that were not migrated yet.
|
|
131
133
|
customElements.define('girafe-map', DeprecatedMapComponent);
|
|
@@ -117,14 +117,7 @@ class GirafeConfig {
|
|
|
117
117
|
// We just display a warning in the console
|
|
118
118
|
console.warn(e);
|
|
119
119
|
}
|
|
120
|
-
|
|
121
|
-
this.streetview = initConfigStreetView(config);
|
|
122
|
-
}
|
|
123
|
-
catch (e) {
|
|
124
|
-
// The application can be started even if the StreetView is not correctly configured
|
|
125
|
-
// We just display a warning in the console
|
|
126
|
-
console.warn(e);
|
|
127
|
-
}
|
|
120
|
+
this.streetview = initConfigStreetView(config);
|
|
128
121
|
try {
|
|
129
122
|
this.news = this.initConfigNews(config);
|
|
130
123
|
}
|
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
import type { StreetViewProvider } from '../state/streetview.js';
|
|
2
2
|
/** Maximal distance, in meters, between a click on the map and the footage displayed for it. */
|
|
3
3
|
export declare const DEFAULT_STREETVIEW_SEARCH_RADIUS = 100;
|
|
4
|
+
/** The Mapillary API does not search the images further than this distance, in meters. */
|
|
5
|
+
export declare const MAPILLARY_MAX_SEARCH_RADIUS = 50;
|
|
6
|
+
export type MapillaryConfig = {
|
|
7
|
+
accessToken: string;
|
|
8
|
+
searchRadius: number;
|
|
9
|
+
};
|
|
4
10
|
export type StreetViewConfig = {
|
|
5
11
|
searchRadius: number;
|
|
6
12
|
google?: {
|
|
7
13
|
apiKey: string;
|
|
8
14
|
};
|
|
15
|
+
mapillary?: MapillaryConfig;
|
|
16
|
+
};
|
|
17
|
+
type StreetViewConfigInput = Partial<Omit<StreetViewConfig, 'mapillary'>> & {
|
|
18
|
+
mapillary?: Partial<MapillaryConfig>;
|
|
9
19
|
};
|
|
10
20
|
export declare function initConfigStreetView(config: {
|
|
11
|
-
streetview?:
|
|
21
|
+
streetview?: StreetViewConfigInput;
|
|
12
22
|
}): StreetViewConfig | undefined;
|
|
13
23
|
export declare function isStreetViewProviderConfigured(config: StreetViewConfig | undefined, provider: StreetViewProvider): boolean;
|
|
24
|
+
export {};
|
|
@@ -1,16 +1,38 @@
|
|
|
1
1
|
/** Maximal distance, in meters, between a click on the map and the footage displayed for it. */
|
|
2
2
|
export const DEFAULT_STREETVIEW_SEARCH_RADIUS = 100;
|
|
3
|
+
/** The Mapillary API does not search the images further than this distance, in meters. */
|
|
4
|
+
export const MAPILLARY_MAX_SEARCH_RADIUS = 50;
|
|
5
|
+
function initConfigMapillary(mapillary) {
|
|
6
|
+
if (!mapillary) {
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
if (!mapillary.accessToken) {
|
|
10
|
+
console.warn(`Configuration for streetview.mapillary requires an accessToken. See https://doc.geogirafe.org/docs/configuration#streetview`);
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
const searchRadius = mapillary.searchRadius ?? MAPILLARY_MAX_SEARCH_RADIUS;
|
|
14
|
+
if (searchRadius > MAPILLARY_MAX_SEARCH_RADIUS) {
|
|
15
|
+
console.warn(`Configuration for streetview.mapillary.searchRadius cannot exceed ${MAPILLARY_MAX_SEARCH_RADIUS} meters. See https://doc.geogirafe.org/docs/configuration#streetview`);
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
return { accessToken: mapillary.accessToken, searchRadius: searchRadius };
|
|
19
|
+
}
|
|
20
|
+
function initConfigGoogle(google) {
|
|
21
|
+
if (google && !google.apiKey) {
|
|
22
|
+
console.warn(`Configuration for streetview.google requires an apiKey. See https://doc.geogirafe.org/docs/configuration#streetview`);
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
return google;
|
|
26
|
+
}
|
|
3
27
|
export function initConfigStreetView(config) {
|
|
4
28
|
const streetview = config.streetview;
|
|
5
29
|
if (!streetview) {
|
|
6
30
|
return undefined;
|
|
7
31
|
}
|
|
8
|
-
if (streetview.google && !streetview.google.apiKey) {
|
|
9
|
-
throw new Error(`Configuration for streetview.google requires an apiKey. See https://doc.geogirafe.org/docs/configuration`);
|
|
10
|
-
}
|
|
11
32
|
return {
|
|
12
33
|
searchRadius: streetview.searchRadius ?? DEFAULT_STREETVIEW_SEARCH_RADIUS,
|
|
13
|
-
google: streetview.google
|
|
34
|
+
google: initConfigGoogle(streetview.google),
|
|
35
|
+
mapillary: initConfigMapillary(streetview.mapillary)
|
|
14
36
|
};
|
|
15
37
|
}
|
|
16
38
|
export function isStreetViewProviderConfigured(config, provider) {
|
package/tools/main.d.ts
CHANGED
|
@@ -13,8 +13,8 @@ export { default as ConfigManager } from './configuration/configmanager.js';
|
|
|
13
13
|
export type { HighlightMode, UserDataConfig } from './configuration/girafeconfig.js';
|
|
14
14
|
export { default as GirafeConfig } from './configuration/girafeconfig.js';
|
|
15
15
|
export { defaultNewsSanitizeConfig, defaultPermalinkSanitizeConfig, defaultQuerySanitizeConfig } from './configuration/sanitizeconfig-defaults.js';
|
|
16
|
-
export type { StreetViewConfig } from './configuration/streetviewconfig.js';
|
|
17
|
-
export { DEFAULT_STREETVIEW_SEARCH_RADIUS, initConfigStreetView, isStreetViewProviderConfigured } from './configuration/streetviewconfig.js';
|
|
16
|
+
export type { MapillaryConfig, StreetViewConfig } from './configuration/streetviewconfig.js';
|
|
17
|
+
export { DEFAULT_STREETVIEW_SEARCH_RADIUS, MAPILLARY_MAX_SEARCH_RADIUS, initConfigStreetView, isStreetViewProviderConfigured } from './configuration/streetviewconfig.js';
|
|
18
18
|
export { default as GirafeContext } from './context/context.js';
|
|
19
19
|
export { default as ContextInitializationHelper } from './context/contexthelper.js';
|
|
20
20
|
export type { default as IGirafeContext } from './context/icontext.js';
|
package/tools/main.js
CHANGED
|
@@ -12,7 +12,7 @@ export { default as PluginManager } from './auth/pluginmanager.js';
|
|
|
12
12
|
export { default as ConfigManager } from './configuration/configmanager.js';
|
|
13
13
|
export { default as GirafeConfig } from './configuration/girafeconfig.js';
|
|
14
14
|
export { defaultNewsSanitizeConfig, defaultPermalinkSanitizeConfig, defaultQuerySanitizeConfig } from './configuration/sanitizeconfig-defaults.js';
|
|
15
|
-
export { DEFAULT_STREETVIEW_SEARCH_RADIUS, initConfigStreetView, isStreetViewProviderConfigured } from './configuration/streetviewconfig.js';
|
|
15
|
+
export { DEFAULT_STREETVIEW_SEARCH_RADIUS, MAPILLARY_MAX_SEARCH_RADIUS, initConfigStreetView, isStreetViewProviderConfigured } from './configuration/streetviewconfig.js';
|
|
16
16
|
export { default as GirafeContext } from './context/context.js';
|
|
17
17
|
export { default as ContextInitializationHelper } from './context/contexthelper.js';
|
|
18
18
|
export { ContextMenu } from './drawing/contextmenu.js';
|
package/tools/state/layout.d.ts
CHANGED
|
@@ -44,6 +44,11 @@ export declare const AVAILABLE_CELL_COMPONENTS: readonly [{
|
|
|
44
44
|
readonly tagName: "girafe-streetview-google";
|
|
45
45
|
readonly label: "Google Street View";
|
|
46
46
|
readonly provider: "google";
|
|
47
|
+
}, {
|
|
48
|
+
readonly id: "streetview-mapillary";
|
|
49
|
+
readonly tagName: "girafe-streetview-mapillary";
|
|
50
|
+
readonly label: "Mapillary";
|
|
51
|
+
readonly provider: "mapillary";
|
|
47
52
|
}];
|
|
48
53
|
type CellComponentDefinition = (typeof AVAILABLE_CELL_COMPONENTS)[number];
|
|
49
54
|
export type CellComponent = CellComponentDefinition['id'];
|
package/tools/state/layout.js
CHANGED
|
@@ -31,7 +31,8 @@ export const MAX_CELL_SIZE = 85;
|
|
|
31
31
|
export const AVAILABLE_CELL_COMPONENTS = [
|
|
32
32
|
{ id: 'map-2d', tagName: 'girafe-map-2d', label: '2D Map' },
|
|
33
33
|
{ id: 'map-3d', tagName: 'girafe-map-3d', label: '3D Map' },
|
|
34
|
-
{ id: 'streetview-google', tagName: 'girafe-streetview-google', label: 'Google Street View', provider: 'google' }
|
|
34
|
+
{ id: 'streetview-google', tagName: 'girafe-streetview-google', label: 'Google Street View', provider: 'google' },
|
|
35
|
+
{ id: 'streetview-mapillary', tagName: 'girafe-streetview-mapillary', label: 'Mapillary', provider: 'mapillary' }
|
|
35
36
|
];
|
|
36
37
|
export function isLayoutType(value) {
|
|
37
38
|
return LAYOUT_TYPES.includes(value);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Coordinate } from 'ol/coordinate.js';
|
|
2
2
|
/** The services that can provide the footage displayed by a StreetView Component. */
|
|
3
|
-
export declare const STREETVIEW_PROVIDERS: readonly ["google"];
|
|
3
|
+
export declare const STREETVIEW_PROVIDERS: readonly ["google", "mapillary"];
|
|
4
4
|
export type StreetViewProvider = (typeof STREETVIEW_PROVIDERS)[number];
|
|
5
5
|
/** The footage displayed by a provider: where it was taken (in the map projection) and the direction of sight. */
|
|
6
6
|
export type StreetViewView = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** The services that can provide the footage displayed by a StreetView Component. */
|
|
2
|
-
export const STREETVIEW_PROVIDERS = ['google'];
|
|
2
|
+
export const STREETVIEW_PROVIDERS = ['google', 'mapillary'];
|
|
3
3
|
export function isStreetViewProvider(value) {
|
|
4
4
|
return STREETVIEW_PROVIDERS.includes(value);
|
|
5
5
|
}
|