[Users] Problem showing WMS in Mercator projection
Erwin Sevens
esevens at ovam.be
Tue Feb 15 10:59:27 CET 2011
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/eb1fa682/attachment-0001.htm
More information about the Users
mailing list