1

I have made a thematic map in QGIS and exported it to OpenLayers 3 format using QGIS2Web plugin containing 4 layers. I need to tweak the following things if possible:

  • I want to remove check boxes and include radio buttons for 3 layers
  • I want to fix the world map layer or at least use check box here so that this layer can be fixed.

This would be a great help as I have browsed through the net but cannot find any resource to do this tweaking.

1 Answer 1

3

Customising the display and behaviour of the ol3 layer switcher control isn't currently supported directly in QGIS2Web.

Once the map is exported you should be able to modify the code in layers.js so that radio buttons are displayed for your 3 layers. You need to add a type property to each of the 3 layer's properties object which a value of 'base'. This will cause the layer switcher to treat the layers as base layers.

For example I've got the following code for an overlay layer (formatted here for clarity):

var lyr_test1 = new ol.layer.Vector({
    source:jsonSource_test1, 
    style: style_test1,
    title: "test1"
});

This needs to be modified to add the type property like so:

var lyr_test1 = new ol.layer.Vector({
    type: 'base',
    source:jsonSource_test1, 
    style: style_test1,
    title: "test1"
});
2
  • @walkermatt When I add a base type to a layer it adds a radio button as expected and works as expected but the layer is not in the Base maps list (lower list). Is there anyway to get the layer to also show with the Base maps list?
    – GreyHippo
    Apr 8, 2016 at 20:50
  • @GreyHippo It should be possible to add the layer into the "Base maps" LayerGroup. If you can post a link to your map (or layers/layers.js) I'd be happy to take a look.
    – walkermatt
    Apr 12, 2016 at 12:33

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.