I generated an OpenLayers map project using the qgis2web plugin. I would like to add the new Vector layer using the WKT polygon geometry. In the following code geomLine is WKT Polygon. Nevermind, when the definied vector layer is added to the map and I switch it on the layer looks strange. The whole extent of the layer has the white background despite of I didn't specify "background" parameter of the layer.

I've already checked the following with no success: I. Other type of geometry (point, line) and other format (geoJSON) - features are displayed on map, but still with the white background II. I set "background" parameter of layer to another color, but it doesn't make any effect (i see specified color as the background during feature loading, but then but after that background becomes white)

var feature = new ol.format.WKT().readFeature(geomLine.replace("SRID=4326;", "")
, {
      dataProjection: 'EPSG:4326',
      featureProjection: 'EPSG:3857',

var uldkVectorSource = new ol.source.Vector({
    features: [feature],

var uldkLayer = new ol.layer.Vector({
  source: uldkVectorSource,
  title: 'Działka ' + search,
  opacity: 0.5

map.getView().fit(uldkVectorSource.getExtent(), { padding: [90, 90, 90, 90] });
const currentZoom = Math.round(map.getView().getZoom());


Map looks like this: enter image description here

When the new layer is switching on: enter image description here

When i set the opacity layer to 0.5: enter image description here

Do you have an idea where to look for the reason? I would like to display only feature without any background color.

1 Answer 1


check your target-map div. Have you applied any background style? or have you applied

.ol-layer > canvas {
background: white !important;

in style tag under head tag, if so, then remove that particular style. your problem will be solved.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.