Martijn de Milliano
Martijn de Milliano

Reputation: 3958

Empty OpenLayers canvas

I initialised an OpenLayers Map, but nothing gets drawn. The map div width and height is set. When I do inspect element, it shown that the canvas element inside the map div has "display: none". Also, none of the images I have in my layers are even loaded. What could be wrong?

I am using OpenLayers 4.

(No code shown because I will answer my own question, posting this for my future self and any others who spent hours fighting with this)

Upvotes: 0

Views: 1981

Answers (1)

Martijn de Milliano
Martijn de Milliano

Reputation: 3958

When the canvas is empty, this could be because the View is not properly initialised. See the documentation: http://openlayers.org/en/latest/apidoc/ol.View.html: center must be set, as well as one of zoom or resolution. If either of these is missing, no initialisation will be done.

Upvotes: 1

Related Questions