NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

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.

I hope someone can help me.:)

asked 05 Sep '11, 16:29

Sannifrosch's gravatar image

Sannifrosch
1111
accept rate: 0%

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

(05 Sep '11, 18:29) Sannifrosch

Your coordinates seem to be in spherical mercator (900913, EPSG 3857) but you need them in lat/lon. You have to transform them for the querystring. Openlayers offers functions for this.

permanent link

answered 07 Sep '11, 11:59

dieterdreist's gravatar image

dieterdreist
3.7k113567
accept rate: 3%

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×144
×122
×34
×14

question asked: 05 Sep '11, 16:29

question was seen: 14,282 times

last updated: 07 Sep '11, 11:59

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum