Use an ImageLayer in wms-custom-proj example
This commit is contained in:
@@ -10,7 +10,9 @@ goog.require('ol.Projection');
|
|||||||
goog.require('ol.ProjectionUnits');
|
goog.require('ol.ProjectionUnits');
|
||||||
goog.require('ol.RendererHints');
|
goog.require('ol.RendererHints');
|
||||||
goog.require('ol.View2D');
|
goog.require('ol.View2D');
|
||||||
|
goog.require('ol.layer.ImageLayer');
|
||||||
goog.require('ol.layer.TileLayer');
|
goog.require('ol.layer.TileLayer');
|
||||||
|
goog.require('ol.source.SingleImageWMS');
|
||||||
goog.require('ol.source.TiledWMS');
|
goog.require('ol.source.TiledWMS');
|
||||||
|
|
||||||
|
|
||||||
@@ -24,6 +26,17 @@ var epsg21781 = new ol.Projection('EPSG:21781', ol.ProjectionUnits.METERS,
|
|||||||
new ol.Extent(485869.5728, 76443.1884, 837076.5648, 299941.7864));
|
new ol.Extent(485869.5728, 76443.1884, 837076.5648, 299941.7864));
|
||||||
ol.Projection.addProjection(epsg21781);
|
ol.Projection.addProjection(epsg21781);
|
||||||
|
|
||||||
|
// We give the single image source a set of resolutions. This prevents the
|
||||||
|
// source from requesting images of arbitrary resolutions.
|
||||||
|
var projectionExtent = epsg21781.getExtent();
|
||||||
|
var maxResolution = Math.max(
|
||||||
|
projectionExtent.maxX - projectionExtent.minX,
|
||||||
|
projectionExtent.maxY - projectionExtent.minY) / 256;
|
||||||
|
var resolutions = new Array(10);
|
||||||
|
for (var i = 0; i < 10; ++i) {
|
||||||
|
resolutions[i] = maxResolution / Math.pow(2.0, i);
|
||||||
|
}
|
||||||
|
|
||||||
var extent = new ol.Extent(420000, 30000, 900000, 350000);
|
var extent = new ol.Extent(420000, 30000, 900000, 350000);
|
||||||
var layers = new ol.Collection([
|
var layers = new ol.Collection([
|
||||||
new ol.layer.TileLayer({
|
new ol.layer.TileLayer({
|
||||||
@@ -41,8 +54,8 @@ var layers = new ol.Collection([
|
|||||||
extent: extent
|
extent: extent
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
new ol.layer.TileLayer({
|
new ol.layer.ImageLayer({
|
||||||
source: new ol.source.TiledWMS({
|
source: new ol.source.SingleImageWMS({
|
||||||
url: 'http://wms.geo.admin.ch/',
|
url: 'http://wms.geo.admin.ch/',
|
||||||
attributions: [new ol.Attribution(
|
attributions: [new ol.Attribution(
|
||||||
'© ' +
|
'© ' +
|
||||||
@@ -50,7 +63,7 @@ var layers = new ol.Collection([
|
|||||||
'National parks / geo.admin.ch</a>')],
|
'National parks / geo.admin.ch</a>')],
|
||||||
params: {'LAYERS': 'ch.bafu.schutzgebiete-paerke_nationaler_bedeutung'},
|
params: {'LAYERS': 'ch.bafu.schutzgebiete-paerke_nationaler_bedeutung'},
|
||||||
projection: epsg21781,
|
projection: epsg21781,
|
||||||
extent: extent
|
resolutions: resolutions
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
|
|||||||
Reference in New Issue
Block a user