toggle - 找不到名称 'ol'

标签 toggle openlayers openlayers-3 angular-openlayers

我第一次在开放层(角度 4)上工作。 在ts中安装并导入文件后。

这些是导入的文件

  import Map from 'ol/Map.js';
  import View from 'ol/View.js';
  import TileLayer from 'ol/layer/Tile.js';
  import OSM from 'ol/source/OSM.js';
  import TileWMS from 'ol/source/TileWMS.js';

  new ol.Map({

我收到此错误 找不到名字“ol”。

最佳答案

new ol.Map({ 应该是 new Map({,参见 the simple map example in the documentation

  import Map from 'ol/Map.js';
  import View from 'ol/View.js';
  import TileLayer from 'ol/layer/Tile.js';
  import OSM from 'ol/source/OSM.js';


  var map = new Map({
    layers: [
      new TileLayer({
        source: new OSM()
      })
    ],
    target: 'map',
    view: new View({
      center: [0, 0],
      zoom: 2
    })
  });

关于toggle - 找不到名称 'ol',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51915140/

相关文章:

javascript - 要切换更多元素,但我只想切换我单击的元素

openlayers - 移动 OpenLayers map 时功能模糊

javascript - OpenLayers 3 中的图层切换

openlayers - 请求太大或无效的 BBOX

javascript - 具有多个矢量图层的 OpenLayers map 使整个页面在 chrome 中闪烁

geocoding - 用openlayers搜索地址

javascript - 在 OL3 中强制渲染 ImageCanvas 层?

java - 单击 JList 中的项目时如何切换它们?

iphone - 从不工作的 UIButton 创建切换?

Javascript 切换图像和 div