Add tiled wms with custom projection
This commit is contained in:
48
examples/wms-custom-proj.html
Normal file
48
examples/wms-custom-proj.html
Normal file
@@ -0,0 +1,48 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="chrome=1">
|
||||
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
|
||||
<link rel="stylesheet" href="style.css" type="text/css">
|
||||
<style type="text/css">
|
||||
html, body, #map {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
#text {
|
||||
position: absolute;
|
||||
top: 8px;
|
||||
right: 8px;
|
||||
z-index: 20000;
|
||||
background-color: white;
|
||||
padding: 0 0.5em 0.5em 0.5em;
|
||||
border-radius: 4px;
|
||||
}
|
||||
@media only screen and (max-width: 600px) {
|
||||
#text {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<title>wms example</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map">
|
||||
<div id="text">
|
||||
<h1 id="title">Tiled WMS with custom projection example</h1>
|
||||
<div id="shortdesc">Example of a tiled WMS layer using the projection EPSG:21781.</div>
|
||||
<div id="docs">
|
||||
<p>See the
|
||||
<a href="wms.js" target="_blank">wms-custom-proj.js source</a>
|
||||
to see how this is done.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="tags">wms, tile, tilelayer, projection</div>
|
||||
<script src="../externs/proj4js/lib/proj4js.js" type="text/javascript"></script>
|
||||
<script src="loader.js?id=wms-custom-proj" type="text/javascript"></script>
|
||||
</body>
|
||||
</html>
|
||||
39
examples/wms-custom-proj.js
Normal file
39
examples/wms-custom-proj.js
Normal file
@@ -0,0 +1,39 @@
|
||||
goog.require('goog.debug.Console');
|
||||
goog.require('goog.debug.Logger');
|
||||
goog.require('goog.debug.Logger.Level');
|
||||
goog.require('ol.Collection');
|
||||
goog.require('ol.Coordinate');
|
||||
goog.require('ol.Map');
|
||||
goog.require('ol.Projection');
|
||||
goog.require('ol.source.TiledWMS');
|
||||
|
||||
|
||||
if (goog.DEBUG) {
|
||||
goog.debug.Console.autoInstall();
|
||||
goog.debug.Logger.getLogger('ol').setLevel(goog.debug.Logger.Level.INFO);
|
||||
}
|
||||
|
||||
var extent = new ol.Extent(420000, 30000, 900000, 350000);
|
||||
|
||||
var epsg21781 = new ol.Projection('EPSG:21781',
|
||||
ol.ProjectionUnits.METERS,
|
||||
extent
|
||||
);
|
||||
|
||||
var layers = new ol.Collection([
|
||||
new ol.layer.TileLayer({
|
||||
source: new ol.source.TiledWMS({
|
||||
url: 'http://wms.geo.admin.ch/?',
|
||||
params: {'LAYERS': 'ch.swisstopo.pixelkarte-farbe-pk1000.noscale'},
|
||||
projection: epsg21781
|
||||
})
|
||||
})
|
||||
]);
|
||||
|
||||
var map = new ol.Map({
|
||||
center: new ol.Coordinate(600000, 200000),
|
||||
projection: epsg21781,
|
||||
layers: layers,
|
||||
target: 'map',
|
||||
zoom: 8
|
||||
});
|
||||
Reference in New Issue
Block a user