AW: [OpenLayers-Users] wrong displayed projection
Arnd Wippermann
arnd.wippermann at web.de
Fri Jan 27 09:06:42 EST 2012
Hi,
Your layer declarations are a bit out of order.
lyrWMS = new OpenLayers.Layer.WMS(title, url, paramsWMS, lyrOptions)
lyrMS = new OpenLayers.Layer.MapServer(title, url, paramsMS, lyrOptions)
Params are added to the server request, options are instructions for
OpenLayers.
paramsWMS = {
map:'/home/banm/maps/minimal.map',
layers:'0605',
format:'image/png',
transparent:true
}
WMS layers are explicit regarded as BaseLayers
if the param "transparent" and the option "isBaseLayer" is not set.
paramsMS = {
map:'/home/banm/maps/minimal.map',
layers:'0605',
map_imagetype:'png'
}
lyrOptions = {
isBaseLayer: false,
visibility:true,
opacity:1.0
}
Your Mapfile should hold some more informations.
In the layerblocks are the projection of the data not set.
PROJECTION
"init=epsg:4326"
END
In the metadata block you should set
wms_srs 'EPSG:4326 EPSG:900913'
to support a reprojection with MapServer for these projections.
You should do a WMS GetCapabilities Request for your services to get some
configuration informations like:
<!-- WARNING: Mandatory mapfile parameter '(at least one of) MAP.PROJECTION,
LAYER.PROJECTION or wms_srs metadata' was missing in this context. -->
Request:
http://biomaps.unideb.hu/cgi-bin/mapserv?map=/home/banm/maps/minimalp.map&Se
rvice=WMS&Request=GetCapabilities&Version=1.1.1
If you do these modifications, your postgis layer should also displayed at
the right position.
But you should declare it as OpenLayers.Layer.WMS.
Best luck
Arnd
-----Ursprüngliche Nachricht-----
Von: openlayers-users-bounces at lists.osgeo.org
[mailto:openlayers-users-bounces at lists.osgeo.org] Im Auftrag von Bán Miklós
Gesendet: Freitag, 27. Januar 2012 07:28
An: openlayers-users at lists.osgeo.org
Betreff: [OpenLayers-Users] wrong displayed projection
Dear all,
I have a problem with projections in wms layers, I have two wms layers from
mapserv and i have two data sources an shp and a postgis. I produced the
postgis table from the shp.
When I load these two layers in qgis, they are overlapping as I expected,
but if you check it here
(http://biomaps.unideb.hu/openlayers/mapserv_test.html) the postgis layer
center is 0,0 while the shp data layer is right.
Where is the error?
Thank you very much, Miklos
The related openlayers js (I willing to use google base layers...)
var options = {
projection: new OpenLayers.Projection("EPSG:900913"),
displayProjection: new OpenLayers.Projection("EPSG:4326"),
units: "m",
numZoomLevels: 20,
maxResolution: 156543.0339,
maxExtent: new OpenLayers.Bounds(-20037508, -20037508,
20037508, 20037508.34), };
map = new OpenLayers.Map( 'map',options);
layer2 = new OpenLayers.Layer.WMS( "shp",
"http://biomaps.unideb.hu/cgi-bin/mapserv",{
map:'/home/banm/maps/minimal.map',layers:'0605',
isBaseLayer: false,
visibility:true,
opacity:1.0,
format:'image/png',
//transparent:true,
});
layer2p = new OpenLayers.Layer.MapServer( "postgis",
"http://biomaps.unideb.hu/cgi-bin/mapserv", {
map: '/home/banm/maps/minimalp.map',
layers:'cuckoo_feszkek',
isBaseLayer: false,
visibility:true,
opacity:1.0,
format:'image/png',
transparent:true,
});
the shp mapfile:
MAP
NAME "QGIS-MAP"
SIZE 200 200
SYMBOLSET ./points.sym
DEBUG 0
SHAPEPATH "../SHP/"
PROJECTION
"init=epsg:4326"
END
WEB
IMAGEPATH '/tmp/'
IMAGEURL '/tmp/'
END
IMAGEQUALITY 95
IMAGETYPE agg
OUTPUTFORMAT
NAME agg
DRIVER AGG/PNG
IMAGEMODE RGB
END
LAYER
name "0605"
STATUS DEFAULT
DATA "feszkek.shp"
TYPE point
CLASS
SYMBOL "circle_filled"
color 123 70 23
SIZE 6
END #class
END
END
The postgis layer:
layer
name 'feszkek'
status default
type point
connectiontype postgis
connection "host=localhost dbname=** password=**
user=gisadmin" data "the_geom from feszkek"
class
SYMBOL "circle_filled"
color 12 70 23
SIZE 6
end
end
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Miklós Bán
Behavioural Ecology Research Group
Department of Evolutionary Zoology
http://vocs.unideb.hu/banm
University of Debrecen
H-4010 Debrecen, Egyetem tér 1.
Phone: +36 52 512-900 ext. 62356
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_______________________________________________
Users mailing list
Users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/openlayers-users
More information about the Users
mailing list