AW: [OpenLayers-Users] OSM and WMS problem using correct maxExtent, maxResolution and projection

Arnd Wippermann arnd.wippermann at web.de
Thu Sep 8 14:24:54 EDT 2011


Hi,

Don't restrict the map options, but zoom to a defined extent with

map.zoomToExtent(extentGermany);

function init(){

    var extentGermany = new
OpenLayers.Bounds(133400,5905800,2493900,7407700);

    var options = {
            controls:[], //create map without controls -> add them later
            projection: new OpenLayers.Projection("EPSG:900913"),
            displayProjection: new OpenLayers.Projection("EPSG:4326"),
            units: "m",
            numZoomLevels: 18,
            maxResolution: 156543.0339,
            maxExtent: new OpenLayers.Bounds(-20037508, -20037508, 20037508,
20037508.34)
        };
    map = new OpenLayers.Map('map', options);

    osm= new OpenLayers.Layer.OSM("Basis Open Street Map");
    var flaglayer = new OpenLayers.Layer.WMS("basic:gis_elemente",
        "http://geoserver.domain.com:80/geoserver/basic/wms",
        {    layers: 'basic:gis_elemente',
             transparent:true
        }
    );
    map.addLayers([osm,flaglayer]);

    map.addControl(new OpenLayers.Control.Navigation());
    map.addControl(new OpenLayers.Control.MousePosition());
    map.addControl(new OpenLayers.Control.LayerSwitcher());
    map.addControl(new OpenLayers.Control.PanZoomBar());

    map.zoomToExtent(extentGermany);
}
 
Delete the projection key in the WMS parameters. Projection is not a WMS
parameter. 
The WMS projection parameter "SRS" will be set by OpenLayers with the
map.projection.

Viele Grüße,
Arnd

-----Ursprüngliche Nachricht-----
Von: openlayers-users-bounces at lists.osgeo.org
[mailto:openlayers-users-bounces at lists.osgeo.org] Im Auftrag von Gabriele
Seitz
Gesendet: Donnerstag, 8. September 2011 18:03
An: users at openlayers.org
Betreff: [OpenLayers-Users] OSM and WMS problem using correct maxExtent,
maxResolution and projection

Hi,

i cannot get the features of my WMS onto the OSM-Map. THe nearest i can get
is this approach with the features laying in "Gulf of Guinea".
I need them in Germany, though.

Geoserver Layer-preview of WMS in firebug-DOM-tab shows: 
- maxExtent=left-bottom=(6.798,48.141) right-top=(13.705,54.325),
- maxResolution=0.02698046875,
- projection=EPSG:900913

OSM layer-Properties in Firebug -DOM information show:
- maxExtent=left-bottom=(-20037508.3392,-20037508.3392)
right-top=(20037508.3392,20037508.3392),
- maxResolution =156543.0339,
- projection=EPSG:900913

Code:

        function init(){
		var extent=new OpenLayers.Bounds(6,48,13,55);
		var options = {
			//controls: [],
			maxExtent: extent
			,maxRsolution: 0.02698046875
			,projection:"EPSG:900913"
		};
		map = new OpenLayers.Map('map', options); 

		var osm= new OpenLayers.Layer.OSM("Basis Open Street Map");
		var flaglayer = new OpenLayers.Layer.WMS(
			"basic:gis_elemente",
"http://geoserver.domain.com:80/geoserver/basic/wms",
			{
				layers: 'basic:gis_elemente',
				transparent:true,
				projection: "EPSG:900913"
			}
		);
		map.addLayers([ osm,flaglayer]); 
		
		map.addControl(
			new OpenLayers.Control.LayerSwitcher(
	
{'div':OpenLayers.Util.getElement('layerswitcher')}
			)
		);
		map.addControl(new OpenLayers.Control.MousePosition());
		map.zoomToExtent(extent);	
	}

How do I fit maxExtent and maxResolution to show OSM and WMS correctly? 

Thanks for answering.

Gabriele 	

--
View this message in context:
http://osgeo-org.1803224.n2.nabble.com/OSM-and-WMS-problem-using-correct-max
Extent-maxResolution-and-projection-tp6772420p6772420.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
Users mailing list
Users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/openlayers-users



More information about the Users mailing list