How to add layerswitcher in ol 6.
import 'ol/ol.css';
import {Map, View} from 'ol';
import TileLayer from 'ol/layer/Tile';
import OSM from 'ol/source/OSM';
import XYZ from 'ol/source/XYZ';
const map = new Map({
target: 'map',
layers: [
new TileLayer({
title: 'District',
type: 'base',
source: new XYZ({
url: "http://127.0.0.1:8080/tms/1.0.0/district/distgrid" + "/{z}/{x}/{-y}.png" ,
})
}),
new TileLayer({
title: 'Landmark',
source: new XYZ({
url: "http://127.0.0.1:8080/tms/1.0.0/Landmark/landmarkgrid" + "/{z}/{x}/{-y}.png" ,
})
}),
new TileLayer({
title: 'Road',
source: new XYZ({
url: "http://127.0.0.1:8080/tms/1.0.0/road/roadgrid" + "/{z}/{x}/{-y}.png" ,
})
})
],
view: new View({
center: [0, 0],
zoom: 1
})
});
I tried the above code but I getting error ol.control.LayerSwitcher is not a constructor. I followed this example http://raw.githack.com/walkermatt/ol-layerswitcher/master/examples/layerswitcher.html