Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 在初始载荷下隐藏传单角度贴图_Css_Angular_Typescript_Leaflet_Ngx Leaflet - Fatal编程技术网

Css 在初始载荷下隐藏传单角度贴图

Css 在初始载荷下隐藏传单角度贴图,css,angular,typescript,leaflet,ngx-leaflet,Css,Angular,Typescript,Leaflet,Ngx Leaflet,我有一个使用了以下css的地图。当页面加载时,我希望地图被隐藏,只有在按下按钮后才能加载 在控制台上,我使用了以下命令,它正在工作,它使地图隐藏起来 document.getElementsByClassName('DemoMap')[0]).style.height="0px"; 但是从类型脚本代码 (<HTMLElement>document.getElementsByClassName('DemoMap')[0]).style.height="0px"; 创

我有一个使用了以下css的地图。当页面加载时,我希望地图被隐藏,只有在按下按钮后才能加载

在控制台上,我使用了以下命令,它正在工作,它使地图隐藏起来

    document.getElementsByClassName('DemoMap')[0]).style.height="0px";
但是从类型脚本代码

    (<HTMLElement>document.getElementsByClassName('DemoMap')[0]).style.height="0px";
创建一个标志
isMapVisible=false

在标记中,使用
[style.display]
配置标记的状态:

<div
  style="height: 90vh;"
  [style.display]="isMapVisible ? 'block' : 'none'"
  leaflet
  [leafletOptions]="options"
></div>

<button (click)="showMap()">Show map</button>

.DemoMap {
  z-index: 1;
  position: absolute;
  width: calc(100% - 600px);
  height: calc(100% - 400px);
  top: 60px;
}
<div
  style="height: 90vh;"
  [style.display]="isMapVisible ? 'block' : 'none'"
  leaflet
  [leafletOptions]="options"
></div>

<button (click)="showMap()">Show map</button>
showMap() {
    this.isMapVisible = true;
}