diff --git a/index.js b/index.js index 2a978d0..e119432 100644 --- a/index.js +++ b/index.js @@ -21,10 +21,10 @@ async function main() { globalThis.map = map; // Add two Dutch basemap options for the Dutch example. - await addPDOKTileLayer(map, "grijs"); - await addPDOKTileLayer(map, "pastel"); + await addPDOKTileLayer(map, "grijs", true); + await addPDOKTileLayer(map, "pastel", false); // Add a global basemap for people who edit with data outside the Netherlands. - addOSMBaseLayer(map); + addOSMBaseLayer(map, false); addPopupToLayer(map); diff --git a/scripts/basemaps.js b/scripts/basemaps.js index 0922cf8..702b601 100644 --- a/scripts/basemaps.js +++ b/scripts/basemaps.js @@ -11,18 +11,19 @@ import { addOpenLayersTransformation } from "./openlayers-proj4.js"; // URL https://service.pdok.nl//brt/achtergrondkaart/wmts/v2_0?request=GetCapabilities&service=WMTS // Source tileMatrixSet=EPSG:28992&crs=EPSG:28992&layers=pastel&styles=default&format=image/png&url=https://service.pdok.nl//brt/achtergrondkaart/wmts/v2_0?request%3DGetCapabilities%26service%3DWMTS -export function addOSMBaseLayer(map) { +export function addOSMBaseLayer(map, startVisible = true) { const tileLayer = new ol.layer.Tile({ title: "OSM", type: "base", source: new ol.source.OSM(), + visible: startVisible, }); map.addLayer(tileLayer); return tileLayer; } -export async function addPDOKTileLayer(map, wmtsLayerId) { +export async function addPDOKTileLayer(map, wmtsLayerId, startVisible = true) { const wmtsServiceURL = "https://service.pdok.nl/brt/achtergrondkaart/wmts/v2_0?request=GetCapabilities&service=WMTS"; @@ -76,6 +77,7 @@ export async function addPDOKTileLayer(map, wmtsLayerId) { const tileLayer = new ol.layer.Tile({ source: new ol.source.WMTS(wmtsOptions), + visible: startVisible, }); tileLayer.set("name", "PDOK - BRT " + wmtsLayerId);