首页 > 解决方案 > 画布高度不断增加 Arcgis/core

问题描述

我在使用 Arcgis/core 4.18 时遇到问题。我的地图画布高度不断增加。我正在使用 Arcgis/Core 和 Angular 11。

这是我的代码

app.component.html

<html>
  <head>
  </head>
  <body>
      <div id="viewDiv"></div>
  </body>
</html>
 

应用组件.css

#viewDiv {
    padding: 0;
    margin: 0;
    height: 100%;
    width: 100%;
  }
 

应用组件.ts

import { Component,OnInit} from '@angular/core';
import MapView from '@arcgis/core/views/MapView'; 
import config from '@arcgis/core/config';
import Map from '@arcgis/core/Map';
@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent  {
  constructor() {
   }

  ngOnInit() {
    this.initMap();
  }

  initMap(){
    config.assetsPath = './assets';
    const map = new Map({
      basemap: "arcgis-topographic" //Basemap layer service
    });
    // Create a MapView instance (for 2D viewing) and reference the map instance
    const view = new MapView({
      map: map,
      center: [-118.80500, 34.02700], //Longitude, latitude
      zoom: 13,
      container: "viewDiv"
  });
    view.when(() => console.log('view ready'));
  }

}

安装 npm arcgis/core

标签: arcgis

解决方案


推荐阅读