AW: [OpenLayers-Users] OpenLayers/Leaflet+MapServer (WMS) -coordinate-problem

Arnd Wippermann arnd.wippermann at web.de
Tue Sep 6 16:30:48 EDT 2011


Hi,

Most likely you have initialized your map without map options.

map = new OpenLayers.Map("map");

Then the map projection is EPSG:4326 by default, also the OSM layer
(baselayer) is displayed with projection EPSG:900913.

It seems, that the querystring by OpenLayers takes the projection from the
map and the coordinates from the baselayer.

To be sure about projections it is always the best way to initialize the map
with options like

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)
};
var map = new OpenLayers.Map('map', options);
 
Regards,
Arnd

-----Ursprüngliche Nachricht-----
Von: openlayers-users-bounces at lists.osgeo.org
[mailto:openlayers-users-bounces at lists.osgeo.org] Im Auftrag von
biff21 at gmx.de
Gesendet: Dienstag, 6. September 2011 12:21
An: openlayers-users at lists.osgeo.org
Betreff: [OpenLayers-Users] OpenLayers/Leaflet+MapServer (WMS)
-coordinate-problem

Hello community,

I got a bad problem with coordinates. I tried to setup a raw MapServer WMS
with OpenLayers frontend. My aim is to show measurement data from a database
as a single tile with OpenLayers.

Some facts: OpenLayers: - Background-Map: OSM (new OpenLayers.Layer.OSM();)
- requesting my MapServer WMS (new OpenLayers.Layer.WMS) with
Single-Tile-Mode

MapServer: - Raw WMS - means I'm fetching the querystring by myself and
trying to apply it to the map - No mapfile used - all settings in
map-generating file itself

My problem is, that OpenLayers creates a querystring like that...

LAYERS->basic
FORMAT->image/png
PROJECTION->EPSG:4326
UNITS->m
SERVICE->WMS
VERSION->1.1.1
REQUEST->GetMap
STYLES->
EXCEPTIONS->application/vnd.ogc.se_inimage
BBOX->-11231962.682325,-2416633.0858313,19763558.029875,12161436.946106
WIDTH->1584
HEIGHT->745

...and mapserver has a method to set the bounding box from OpenLayers...

$Map->setExtent(lat1,lon1,lat2,lon2);

but the coordinates have a different format. OpenLayers provides coordinates
in UTM(?) while setExtent expects decimal values as I often saw them in
example scripts.

My question is: How can I create a map which fits perfectly with the OSM
map, but without using a mapfile and tilemode since I need singletile-mode?
I couldn't figure out to set the bounding box correctly or even convert the
coordinates. Additionally I suppose that something is wrong with my
projections.

BTW using leaflet causes the same problem. Coordinates look like
bbox->1878516.4071364915,5635549.221409475,2504688.5428486555,6261721.357121
64 while setExtent() needs decimal values (lat/lon)

I hope someone can help me.:)
--
Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir belohnen Sie mit
bis zu 50,- Euro! https://freundschaftswerbung.gmx.de
_______________________________________________
Users mailing list
Users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/openlayers-users



More information about the Users mailing list