小编Dej*_*vic的帖子

即使使用 DragRotateAndZoom 交互,我的地图也不会随着 openlayers 6.2 和 angular 9 移动

我正在尝试创建地图,正如我在其他网站和示例中看到的那样,每个人都可以通过鼠标单击和拖动来移动他们的地图。但是我的地图根本不会移动,有人知道我做错了什么吗?

这些是我正在使用的 components.ts 和 component.html 文件。我按照https://openlayers.org/en/latest/doc/tutorials/bundle.html 上的说明操作,没有安装 Parcel,因为我使用的是 angular。

地图组件.ts

ngOnInit(): void {
  this.mapInit();
  }

   mapInit() {
   var mousePositionControl = new MousePosition({
         coordinateFormat: createStringXY(4),
         projection: 'EPSG:4326',
         // comment the following two lines to have the mouse position
         // be placed within the map.
         className: 'custom-mouse-position',
         target: document.getElementById('mouse-position'),
         undefinedHTML: ' '
       });

          var source = new OSM();
          var overviewMapControl = new OverviewMap({
            layers: [
              new TileLayer({
                source: source
              })
            ]
          });

          this.map = new Map({
          target: 'map',
          interactions: defaultInteractions().extend([
              new …
Run Code Online (Sandbox Code Playgroud)

angular9 openlayers-6

2
推荐指数
1
解决办法
896
查看次数

标签 统计

angular9 ×1

openlayers-6 ×1