@@ -54,6 +54,30 @@ const waitFor = async function waitFor(maxWait, sleepStep, f){
54
54
return waitingTime ;
55
55
} ;
56
56
57
+ const definedCustomElements = ( ) => {
58
+ window . customElements . define ( 'lizmap-geolocation' , Geolocation ) ;
59
+ window . customElements . define ( 'lizmap-geolocation-survey' , GeolocationSurvey ) ;
60
+ window . customElements . define ( 'lizmap-features-table' , FeaturesTable ) ;
61
+ window . customElements . define ( 'lizmap-selection-tool' , SelectionTool ) ;
62
+ window . customElements . define ( 'lizmap-selection-invert' , SelectionInvert ) ;
63
+ window . customElements . define ( 'lizmap-snapping' , Snapping ) ;
64
+ window . customElements . define ( 'lizmap-scaleline' , Scaleline ) ;
65
+ window . customElements . define ( 'lizmap-mouse-position' , MousePosition ) ;
66
+ window . customElements . define ( 'lizmap-digitizing' , Digitizing ) ;
67
+ window . customElements . define ( 'lizmap-overviewmap' , OverviewMap ) ;
68
+ window . customElements . define ( 'lizmap-feature-toolbar' , FeatureToolbar ) ;
69
+ window . customElements . define ( 'lizmap-reverse-geom' , ReverseGeom ) ;
70
+ window . customElements . define ( 'lizmap-paste-geom' , PasteGeom ) ;
71
+ window . customElements . define ( 'lizmap-action-selector' , ActionSelector ) ;
72
+ window . customElements . define ( 'lizmap-print' , Print ) ;
73
+ window . customElements . define ( 'lizmap-fullscreen' , FullScreen ) ;
74
+ window . customElements . define ( 'lizmap-base-layers' , BaseLayers ) ;
75
+ window . customElements . define ( 'lizmap-treeview' , Treeview ) ;
76
+ window . customElements . define ( 'lizmap-navbar' , NavBar ) ;
77
+ window . customElements . define ( 'lizmap-tooltip' , Tooltip ) ;
78
+ window . customElements . define ( 'lizmap-message' , Message ) ;
79
+ }
80
+
57
81
/**
58
82
* Init Lizmap application
59
83
* This function is called when the Lizmap application is ready to be initialized.
@@ -74,27 +98,14 @@ const initLizmapApp = () => {
74
98
75
99
} ,
76
100
uicreated : ( ) => {
77
- window . customElements . define ( 'lizmap-geolocation' , Geolocation ) ;
78
- window . customElements . define ( 'lizmap-geolocation-survey' , GeolocationSurvey ) ;
79
- window . customElements . define ( 'lizmap-features-table' , FeaturesTable ) ;
80
- window . customElements . define ( 'lizmap-selection-tool' , SelectionTool ) ;
81
- window . customElements . define ( 'lizmap-selection-invert' , SelectionInvert ) ;
82
- window . customElements . define ( 'lizmap-snapping' , Snapping ) ;
83
- window . customElements . define ( 'lizmap-scaleline' , Scaleline ) ;
84
- window . customElements . define ( 'lizmap-mouse-position' , MousePosition ) ;
85
- window . customElements . define ( 'lizmap-digitizing' , Digitizing ) ;
86
- window . customElements . define ( 'lizmap-overviewmap' , OverviewMap ) ;
87
- window . customElements . define ( 'lizmap-feature-toolbar' , FeatureToolbar ) ;
88
- window . customElements . define ( 'lizmap-reverse-geom' , ReverseGeom ) ;
89
- window . customElements . define ( 'lizmap-paste-geom' , PasteGeom ) ;
90
- window . customElements . define ( 'lizmap-action-selector' , ActionSelector ) ;
91
- window . customElements . define ( 'lizmap-print' , Print ) ;
92
- window . customElements . define ( 'lizmap-fullscreen' , FullScreen ) ;
93
- window . customElements . define ( 'lizmap-base-layers' , BaseLayers ) ;
94
- window . customElements . define ( 'lizmap-treeview' , Treeview ) ;
95
- window . customElements . define ( 'lizmap-navbar' , NavBar ) ;
96
- window . customElements . define ( 'lizmap-tooltip' , Tooltip ) ;
97
- window . customElements . define ( 'lizmap-message' , Message ) ;
101
+ if ( lizMap . mainLizmap . legend !== undefined ) {
102
+ definedCustomElements ( ) ;
103
+ } else {
104
+ lizMap . mainEventDispatcher . addListener (
105
+ definedCustomElements ,
106
+ 'lizmap.modules.initialized'
107
+ ) ;
108
+ }
98
109
}
99
110
} ) ;
100
111
0 commit comments