@@ -67,6 +67,7 @@ import {TargetFeature} from '../util/vectortile_to_geojson';
6767import { loadIconset } from './load_iconset' ;
6868import { ImageId } from '../style-spec/expression/types/image_id' ;
6969import { ImageProvider } from '../render/image_provider' ;
70+ import IndoorManager from './indoor_manager' ;
7071
7172import type { PropertyValidatorOptions } from '../style-spec/validate/validate_property' ;
7273import type Tile from '../source/tile' ;
@@ -276,6 +277,7 @@ class Style extends Evented<MapEvents> {
276277 imageManager : ImageManager ;
277278 glyphManager : GlyphManager ;
278279 modelManager : ModelManager ;
280+ indoorManager : IndoorManager ;
279281 ambientLight : Lights < Ambient > | null | undefined ;
280282 directionalLight : Lights < Directional > | null | undefined ;
281283 light : Light ;
@@ -414,6 +416,8 @@ class Style extends Evented<MapEvents> {
414416
415417 this . _hasDataDrivenEmissive = false ;
416418
419+ this . indoorManager = new IndoorManager ( this ) ;
420+
417421 if ( options . dispatcher ) {
418422 this . dispatcher = options . dispatcher ;
419423 } else {
@@ -888,6 +892,7 @@ class Style extends Evented<MapEvents> {
888892 this . _loadImports ( json . imports , validate )
889893 . then ( ( ) => {
890894 this . _reloadImports ( ) ;
895+ this . _setupIndoor ( ) ;
891896 this . fire ( new Event ( isRootStyle ? 'style.load' : 'style.import.load' ) ) ;
892897 } )
893898 . catch ( ( e ) => {
@@ -897,6 +902,7 @@ class Style extends Evented<MapEvents> {
897902 } ) ;
898903 } else {
899904 this . _reloadImports ( ) ;
905+ this . _setupIndoor ( ) ;
900906 this . fire ( new Event ( isRootStyle ? 'style.load' : 'style.import.load' ) ) ;
901907 }
902908 } ;
@@ -2466,7 +2472,7 @@ class Style extends Evented<MapEvents> {
24662472 }
24672473
24682474 setIndoorData ( mapId : string , params : ActorMessages [ 'setIndoorData' ] [ 'params' ] ) {
2469- this . map . indoor . setIndoorData ( params ) ;
2475+ this . indoorManager . setIndoorData ( params ) ;
24702476 }
24712477
24722478 updateIndoorDependentLayers ( ) {
@@ -3220,6 +3226,7 @@ class Style extends Evented<MapEvents> {
32203226 fog : this . stylesheet . fog ,
32213227 snow : this . stylesheet . snow ,
32223228 rain : this . stylesheet . rain ,
3229+ indoor : this . stylesheet . indoor ,
32233230 center : this . stylesheet . center ,
32243231 'color-theme' : this . stylesheet [ 'color-theme' ] ,
32253232 zoom : this . stylesheet . zoom ,
@@ -4016,6 +4023,7 @@ class Style extends Evented<MapEvents> {
40164023 delete this . terrain ;
40174024 delete this . ambientLight ;
40184025 delete this . directionalLight ;
4026+ this . indoorManager . destroy ( ) ;
40194027
40204028 // Shared managers should be removed only on removing the root style
40214029 if ( this . isRootStyle ( ) ) {
@@ -4615,6 +4623,25 @@ class Style extends Evented<MapEvents> {
46154623 this . dispatcher . broadcast ( 'clearCaches' ) ;
46164624 }
46174625
4626+ _setupIndoor ( ) {
4627+ this . indoorManager . on ( 'buildings-appeared' , ( ) => {
4628+ this . map . _addIndoorControl ( ) ;
4629+ } ) ;
4630+
4631+ this . indoorManager . on ( 'buildings-disappeared' , ( ) => {
4632+ this . map . _removeIndoorControl ( ) ;
4633+ } ) ;
4634+
4635+ const updateUI = ( ) => {
4636+ this . indoorManager . _updateUI ( this . map . transform . zoom , this . map . transform . center , this . map . transform . getBounds ( ) ) ;
4637+ } ;
4638+
4639+ this . map . on ( 'move' , updateUI ) ;
4640+ this . map . on ( 'idle' , updateUI ) ;
4641+
4642+ updateUI ( ) ;
4643+ }
4644+
46184645 destroy ( ) {
46194646 this . _clearWorkerCaches ( ) ;
46204647 this . fragments . forEach ( fragment => {
0 commit comments