ol-ext/examples/layer/map.wmscapabilities.html
2020-10-21 11:42:10 +02:00

147 lines
6.0 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<!--
Copyright (c) 2015-2020 Jean-Marc VIGLINO,
released under CeCILL-B (french BSD like) licence: http://www.cecill.info/
-->
<title>ol-ext: WMS Capabilities control</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="DBPedia layer for OL3" />
<meta name="keywords" content="openlayers, control, source, WMS, getCapabilities, capabilites" />
<!-- jQuery -->
<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.0.min.js"></script>
<!-- Openlayers -->
<link rel="stylesheet" href="https://openlayers.org/en/latest/css/ol.css" />
<script type="text/javascript" src="https://openlayers.org/en/latest/build/ol.js"></script>
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL,Object.assign"></script>
<!-- ol-ext -->
<link rel="stylesheet" href="../../dist/ol-ext.css" />
<script type="text/javascript" src="../../dist/ol-ext.js"></script>
<!-- Proj4 -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.3.14/proj4.js"></script>
<link rel="stylesheet" href="../style.css" />
<style>
.ol-wmscapabilities ul {
padding: 0;
}
</style>
</head>
<body >
<a href="https://github.com/Viglino/ol-ext" class="icss-github-corner"><i></i></a>
<a href="../../index.html">
<h1>ol-ext: WMS Capabilities control</h1>
</a>
<div class="info">
<b>ol/control/WMSCapabilities</b> is a control to load WMS layers on ol maps.
<br/>
It displays a dialog to select the service you want to add using getCapabilities on this service.
<br/>
Some services may not respond correctly because of
<a href="https://en.wikipedia.org/wiki/Cross-origin_resource_sharing">CORS policies</a>
and you may have to use a proxy to access the getCapabilities...
<br/>
Listen to the <i>load</i> event to get the selected layer or options to create it.
</div>
<!-- DIV pour la carte -->
<div id="map" style="width:600px; height:400px;"></div>
<div class="options">
<ul>
<li>
url:
<input id="url" type="text" value="http://geoservices.brgm.fr/geologie" />
<button onclick="cap.showDialog($('#url').val())">search</button>
</li>
<li>
Services :
<button onclick="cap.showDialog('https://geoservices.brgm.fr/geologie'); ">BRGM</button>
<button onclick="cap.showDialog('http://services.sandre.eaufrance.fr/geo/eth_FXX');">Sandre</button>
</li>
</ul>
</div>
<div id="select" class="options" >Select an item.</div>
<script type="text/javascript">
// http services load on http
if (location.protocol === 'https:' && !/^localhost/.test(location.host)) {
location.href = window.location.href.replace(/^https:/,'http:');
}
// Define proj4 2154
proj4.defs("EPSG:2154","+proj=lcc +lat_1=49 +lat_2=44 +lat_0=46.5 +lon_0=3 +x_0=700000 +y_0=6600000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs");
if (ol.proj.proj4 && ol.proj.proj4.register) ol.proj.proj4.register(proj4);
// The map
var map = new ol.Map({
target: 'map',
view: new ol.View ({
zoom: 15,
center: [261204.43490751847, 6250258.191535994]
}),
interactions: ol.interaction.defaults(),
layers: [ new ol.layer.Tile({ name:"OSM", source: new ol.source.OSM() })]
});
map.addControl(new ol.control.LayerSwitcher({
trash: true,
extent: true,
collapsed: false
}));
map.addControl(new ol.control.Permalink({ visible: false, localStorage: true }));
map.addControl(new ol.control.Attribution());
var cap = new ol.control.WMSCapabilities({
// target: $('.options').get(0),
target: document.body,
srs: ['EPSG:2154'],
cors: true,
services: {
BRGM: 'https://geoservices.brgm.fr/geologie',
Sandre: 'http://services.sandre.eaufrance.fr/geo/eth_FXX',
Cartorisque: 'https://mapsref.brgm.fr/wxs/refcom-env/refign',
'Swiss Topo': 'https://wms.geo.admin.ch/',
'IFREMER*': 'http://tds0.ifremer.fr/thredds/wms/CORIOLIS-GLOBAL-NRTOA-OBS_TIME_SERIE?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&LAYERS=PSAL&CRS=EPSG%3A3857',
Géorisque: 'https://mapsref.brgm.fr/wxs/georisques/risques',
BDRisques: 'https://mapsref.brgm.fr/wxs/risques/bdrisques',
Risques: 'https://geoservices.brgm.fr/risques',
'Natura 2000*': 'http://ws.carmencarto.fr/WMS/119/fxx_inpn?language=fre&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&LAYERS=Zones_de_protection_speciale&CRS=EPSG%3A3857',
// https://www.cigalsace.org/portail/fr/page/723/flux-donnees -->
Cigalsace: 'https://www.cigalsace.org/geoserver/cigal/ows',
'CG93-raster': 'https://geoportail93.fr/cgi-bin/mapserv?map=SIGD/raster.map',
'CG93-fond': 'https://geoportail93.fr/cgi-bin/mapserv?map=SIGD/fond_SIGD.map',
'CG94*': 'https://geo.valdemarne.fr/viewer/index.php?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&LAYERS=parcelles&CRS=EPSG%3A2154',
GeoFoncier:'https://api.geofoncier.fr/referentielsoge/ogc/wxs',
// http://www.geolittoral.equipement.gouv.fr/rubrique.php3?id_rubrique=39 -->
// 'GeoLittoral*': 'http://geolittoral.application.equipement.gouv.fr/wms/metropole',
// http://www.sogefi-sig.com/sogefi-diffuse-des-donnees-en-wms/ -->
SOGEFI: 'http://ws.sogefi-web.com/wms',
// http://inspire-geoportal.ec.europa.eu/discovery/ -->
'Photos anciennes litto': 'http://www.ifremer.fr/services/photos_anciennes',
Geobretagne: 'https://geobretagne.fr/geoserver/dir_ouest/wms',
'Venise*': 'http://cigno.atlantedellalaguna.it/geoserver/ows?SERVICE=WMS&VERSION=1.3.0&FORMAT=image%2Fpng&LAYERS=carta_base',
Geoportail: 'https://wxs.ign.fr/choisirgeoportail/geoportail/r/wms'
},
trace: true
});
map.addControl(cap);
var print = new ol.control.Print();
map.addControl(print);
print.on('print', function(e) { console.log(e); })
cap.on('load', function(e) {
map.addLayer(e.layer)
})
</script>
</body>
</html>