Search code examples
openlayers-5

Problem with OSM Map OpenLayers 5 : the map won't show


The OSM map won't show anymore with Openlayers 5 I tried to added from ol.source.OSM() but a grey map shown.

  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
    }) 

  });

Solution

  • layers must be an array

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