Angular 图层在地图中不可见,但显示在控制台中

Angular 图层在地图中不可见,但显示在控制台中,angular,typescript,ionic-framework,openlayers,capacitor,Angular,Typescript,Ionic Framework,Openlayers,Capacitor,我正在开发一个带有Ionic、Capactor和OpenLayers的应用程序,但当我尝试在map中加载一个新层时,这个层并没有出现。我可以看到图层是使用控制台加载到地图中的,所有功能都显示在图层源中。我不知道发生了什么,因为在与Cordova相同的版本中,此函数可以工作 当用户点击复选框时,我尝试一个接一个地加载这些层,然后当地图加载时,我尝试以编程方式加载所有层 Map.page.html Datashare.service.ts /**活动选定层*/ activeLayer(层:层):

我正在开发一个带有Ionic、Capactor和OpenLayers的应用程序,但当我尝试在map中加载一个新层时,这个层并没有出现。我可以看到图层是使用控制台加载到地图中的,所有功能都显示在图层源中。我不知道发生了什么,因为在与Cordova相同的版本中,此函数可以工作

当用户点击复选框时,我尝试一个接一个地加载这些层,然后当地图加载时,我尝试以编程方式加载所有层


Map.page.html
Datashare.service.ts
/**活动选定层*/
activeLayer(层:层):无效{
返回this.activeLayerSubject.next(层)
}
ActiveLayerRobservable():可观察{
返回this.activeLayerSubject;
}

Openlayers.component.ts
/**可在浏览器中观察到活动层*/
this.activeLayerSubscription=this.datashare.activelayersobservable().subscribe(层=>{
这是装载层(层);
});
/**加载选定层*/
荷载层(层:层):无效{
如果(此.platform.is('cordova')){
这个.checkFileInDeviceStorage(层)。然后(结果=>{
层=层作为层;
如果(结果){
这个.readFileInDeviceStorage(layer.path)。然后(fileAsText=>{
this.createLayer(fileAsText,layer.name);
});
}否则{
这个.presentToast(“Não existe arquivo neste diretório:
”+layer.path); } }); } } /**在地图中创建图层*/ createLayer(fileAsText:string,name:string):无效{ 设newVectorSource=newVectorSource({}) 设newVectorLayer=新VectorLayer({ 来源:newVectorSource, zIndex:55, 可见:正确 }); newVectorLayer.set('name',name); let format=new KML({}); newVectorSource.addFeatures(format.readFeatures(fileAsText{ 功能投影:“EPSG:3857”, 数据投影:“EPSG:4626” })); this.map.addLayer(newVectorLayer); }

离子信息
安慰 使用
map.getLayers()

<ion-menu side="start" menuId="layersMenu" contentId="main" type="overlay">

    <ion-content color="primary" id="main">
        <div *ngFor="let layer of layers">
            <ion-item color="primary"> 
                <ion-label>{{layer.name}}</ion-label>
                <ion-checkbox color="dark" (ionChange)="toggleLayer(layer.id)" checked="{{layer.visibility}}"></ion-checkbox>
            </ion-item>
        </div>
    </ion-content>

</ion-menu>
Ionic:

   Ionic CLI                     : 6.12.4 (C:\Users\cliente\AppData\Roaming\npm\node_modules\@ionic\cli)
   Ionic Framework               : @ionic/angular 5.5.5
   @angular-devkit/build-angular : 0.1101.4
   @angular-devkit/schematics    : 11.1.4
   @angular/cli                  : 11.1.4
   @ionic/angular-toolkit        : 3.1.0

Capacitor:

   Capacitor CLI   : 2.4.7
   @capacitor/core : 2.4.7

Utility:

   cordova-res : not installed
   native-run  : not installed

System:

   NodeJS : v14.16.0 (C:\Program Files\nodejs\node.exe)
   npm    : 6.14.11
   OS     : Windows 10

OpenLayers:

   v6.5.0