[Users] Problem showing WMS in Mercator projection
Morper-Busch, Lucia
Lucia.Morper-Busch at sbg.ac.at
Tue Feb 15 13:58:28 CET 2011
Hi Erwin,
my source code looks like this:
var proj4326 = new OpenLayers.Projection("EPSG:4326");
var projmerc = new OpenLayers.Projection("EPSG:900913");
map = new OpenLayers.Map({
projection: projmerc,
displayProjection: proj4326,
units: "m",
numZoomLevels: 19,
maxResolution: 156543.0339,
maxExtent: new OpenLayers.Bounds(-20037508, -20037508,
20037508, 20037508.34),
controls: []
});
var lonlatEurope = new OpenLayers.LonLat(12.0849609375, 47.79839667295524);
lonlatEurope.transform(proj4326, projmerc);
var osm = new OpenLayers.Layer.OSM.Mapnik("OSM Mapnik", {
transparent: true
},{
visibility: true
}
)
layers.push(osm);
//Layer is in WGS 84 projection
layers.push(new OpenLayers.Layer.WMS("ThermoMap Countries", geoserverURL, {
layers: "ThermoMap:ThermoMap_Partners_Countries",
transparent: true,
format: 'image/png'
}, {
singleTile: true,
isBaseLayer: false,
visibility: false
}
));
map.addLayers(layers);
map.setCenter(lonlatEurope, 4, true, true);
Best regards
Lucia
Dipl.-Geogr. Lucia Morper-Busch | Researcher
University of Salzburg | Centre for Geoinformatics - Z_GIS
Schillerstr.30 | Techno-Z, Block 15, 3rd floor | 5020 Salzburg, Austria
Phone +43 (0)662 8044 5298 | Fax +43 (0)662 8044 5260
> Z_GIS…experts for the spatial view <http://www.zgis.at/research>
Von: users-bounces at geoext.org [mailto:users-bounces at geoext.org] Im Auftrag von Erwin Sevens
Gesendet: Dienstag, 15. Februar 2011 10:59
An: users at geoext.org
Betreff: [Users] Problem showing WMS in Mercator projection
Hi,
I am trying to combine WMS-layers with the Openstreet Map as background.
The WMS-layers disapear as soon as I zoom in.
When working in geographic projection, I manage to get the WMS to show on a background layer.
I know it is possible as in the opengeo suite, it is possible to do it. Unfortunately, I cannot see how they did it.
I have added two simple examples with layers available on the net and the javascripts refering to the online sources.
Can somebody explain me what I do wrong?
A working simple example with the default projection:
====================================
<html>
<head>
<title> A working GeoExt Map </title>
<script src="http://extjs.cachefly.net/ext-3.2.1/adapter/ext/ext-base.js" type="text/javascript"></script>
<script src="http://extjs.cachefly.net/ext-3.2.1/ext-all.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="http://extjs.cachefly.net/ext-3.2.1/resources/css/ext-all.css"></link>
<script src="http://openlayers.org/api/OpenLayers.js" type="text/javascript"></script>
<script src="http://api.geoext.org/1.0/script/GeoExt.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="http://api.geoext.org/1.0/resources/css/geoext-all-debug.css"></link>
<script type="text/javascript">
Ext.onReady(function() {
var map = new OpenLayers.Map({allOverlays: true});
var kansas = new OpenLayers.LonLat(-99, 39);
var usa = new OpenLayers.Layer.WMS(
"usa", "http://demo.opengeo.org/geoserver/wms",
{
height: '330',
width: '680',
layers: 'nurc:Img_Sample',
styles: '',
srs: 'EPSG:4326',
format: 'image/png'
},
{singleTile: true, ratio: 1}
);
var layer = new OpenLayers.Layer.WMS(
"USA pop",
"http://demo.opengeo.org/geoserver/wms",
{layers: "topp:states"},
{opacity: 0.5}
);
map.addLayer(usa);
map.addLayer(layer);
new GeoExt.MapPanel({
renderTo: 'gxmap',
height: 400,
width: 600,
map: map,
center: kansas,
zoom: 4,
title: 'A working GeoExt Map, default projection'
});
});
</script>
</head>
<body>
<div id="gxmap"></div>
</body>
</html>
============================================
the not working example with mercator projection
============================================
<html>
<head>
<title> A WMS failing GeoExt Map </title>
<script src="http://extjs.cachefly.net/ext-3.2.1/adapter/ext/ext-base.js" type="text/javascript"></script>
<script src="http://extjs.cachefly.net/ext-3.2.1/ext-all.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="http://extjs.cachefly.net/ext-3.2.1/resources/css/ext-all.css"></link>
<script src="http://openlayers.org/api/OpenLayers.js" type="text/javascript"></script>
<script src="http://api.geoext.org/1.0/script/GeoExt.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="http://api.geoext.org/1.0/resources/css/geoext-all-debug.css"></link>
<script type="text/javascript">
Ext.onReady(function() {
var geographic = new OpenLayers.Projection("EPSG:4326");
var mercator = new OpenLayers.Projection("EPSG:900913");
var map = new OpenLayers.Map({allOverlays: true,
projection: "EPSG:900913",
units: "m"
});
var kansas = new OpenLayers.LonLat(-99, 39).transform(geographic, mercator);
var osm = new OpenLayers.Layer.OSM();
var layer = new OpenLayers.Layer.WMS(
"USA pop",
"http://demo.opengeo.org/geoserver/wms",
{layers: "topp:states"},
{opacity: 0.5}
);
map.addLayer(osm);
map.addLayer(layer);
new GeoExt.MapPanel({
renderTo: 'gxmap',
height: 400,
width: 600,
map: map,
center: kansas,
zoom: 4,
title: 'A WMS failing GeoExt Map, Mercator projection'
});
});
</script>
</head>
<body>
<div id="gxmap"></div>
</body>
</html>
Erwin Sevens | OVAM
http://www.ovam.be
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20110215/26e91e67/attachment-0001.htm
More information about the Users
mailing list