OSM Map OpenLayers 5的问题:地图不会显示

时间:2019-05-29 08:27:24

标签: openlayers-5

Openlayers 5将不再显示OSM地图 我尝试从ol.source.OSM()添加,但显示了灰色地图。

  var map3 = new ol.Map({
      layers:  new ol.layer.Tile({
        source: new ol.source.OSM()
      }) ,
    target: 'map-id3',
    view: new ol.View({
      center:ol.proj.fromLonLat([10.74,34.77]),
      zoom:12
    }) 

  });

1 个答案:

答案 0 :(得分:0)

layers必须是数组

  layers: [ new ol.layer.Tile({
    source: new ol.source.OSM()
  }) ],