Skip to content

Instantly share code, notes, and snippets.

@nmandery
Last active April 4, 2018 12:54
Show Gist options
  • Save nmandery/aee82bdc8ffe5bcc70916dca40100dfa to your computer and use it in GitHub Desktop.
Save nmandery/aee82bdc8ffe5bcc70916dca40100dfa to your computer and use it in GitHub Desktop.
EOC Flood using WFS
<div id="map" class="map" style="width: 100%; height: 100%; position:fixed"></div>
var vectorSource = new ol.source.Vector({
format: new ol.format.GeoJSON(),
url: function(extent) {
return (
"https://geoservice.dlr.de/eoc/zki/service/wfs?service=WFS&" +
"version=1.1.0&request=GetFeature&typename=riesgos_workshop:flood&" +
"outputFormat=application/json&srsname=EPSG:3857&" +
"bbox=" +
extent.join(",") +
",EPSG:3857"
);
},
strategy: ol.loadingstrategy.bbox
});
var vector = new ol.layer.Vector({
source: vectorSource,
style: new ol.style.Style({
stroke: new ol.style.Stroke({
color: "rgba(0, 0, 255, 1.0)",
width: 2
})
})
});
var bg = new ol.layer.Tile({
visible: true,
opacity: 1.0,
title: "EOC Base Overlay",
source: new ol.source.WMTS({
attributions: [
new ol.Attribution({
html:
'| Baseoverlay: Data © <a href="http://openstreetmap.org">OpenStreetMap contributors</a> and <a href="../about#basemaps">others</a>, Rendering © <a href="http://www.dlr.de/eoc">DLR/EOC</a>'
})
],
url: "https://tiles.geoservice.dlr.de/service/wmts",
// crossOrigin: 'Anonymous',
layer: "eoc:baseoverlay",
matrixSet: "EPSG:3857",
format: "image/png",
projection: ol.proj.get("EPSG:3857"),
tileGrid: new ol.tilegrid.WMTS({
extent: [-20037508.3428, -20037508.3428, 20037508.3428, 20037508.3428],
origin: [-20037508.3428, 20037508.3428],
resolutions: [
156543.03392811998,
78271.51696419998,
39135.758481959994,
19567.879241008,
9783.939620504,
4891.969810252,
2445.984905126,
1222.9924525644,
611.4962262807999,
305.74811314039994,
152.87405657047998,
76.43702828523999,
38.21851414248,
19.109257071295996,
9.554628535647998,
4.777314267823999,
2.3886571339119995
],
matrixIds: [
"EPSG:3857:0",
"EPSG:3857:1",
"EPSG:3857:2",
"EPSG:3857:3",
"EPSG:3857:4",
"EPSG:3857:5",
"EPSG:3857:6",
"EPSG:3857:7",
"EPSG:3857:8",
"EPSG:3857:9",
"EPSG:3857:10",
"EPSG:3857:11",
"EPSG:3857:12",
"EPSG:3857:13",
"EPSG:3857:14",
"EPSG:3857:15",
"EPSG:3857:16"
],
tileSize: [256, 256]
}),
wrapX: true
})
});
var map = new ol.Map({
layers: [bg, vector],
target: document.getElementById("map"),
view: new ol.View({
center: [-7201856.245971127, -1992342.4195436193],
maxZoom: 19,
zoom: 3
})
});
<script src="https://openlayers.org/en/v4.6.5/build/ol.js"></script>
<link href="https://openlayers.org/en/v4.6.5/css/ol.css" rel="stylesheet" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment