[OpenLayers-Users] Some question on WFS projected maps
Andrea Aime
aaime at openplans.org
Tue Jun 19 05:43:09 EDT 2007
Hi,
I'm trying to setup a WFS layer for WFS-T editing, but having a hard
time doing so.
The layer is projected, in EPSG:27700 projection. First of all, after
lots of trial and error (and I mean, lots!) I managed to have the WFS
layer display at all. The code looks more or less like:
---------------------------------------------------------------------
map = new OpenLayers.Map( $('map') );
OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3;
var bounds = new
OpenLayers.Bounds(518772.8833465263,233451.16243928167,569351.5567723501,278119.59184872644)
map.projection = "EPSG:27700";
map.maxExtent = bounds;
// add the wms layer (we need a base layer, no matter what)
var base = new OpenLayers.Layer.WMS(
"topp:mylayer", "http://localhost:8080/geoserver/wms",
{
height: '662', width: '800',
layers: 'topp:mylayer',
srs: 'EPSG:27700', format: 'image/png'
},
{
maxExtent: bounds, maxResolution: 200,
projection: "EPSG:27700"
}
);
map.addLayer(base);
// add the wfs layer
layer = new OpenLayers.Layer.WFS(
"topp:mylayer", "/geoserver/wfs",
{
typename: 'topp:mylayer',
featureNS: 'http://www.openplans.org/topp',
extractAttributes: false
},
{
geometry_column : 'GEOLOC',
projection: 'EPSG:27700',
maxResolution: 10,
maxExtent: bounds
}
);
map.addLayer(layer);
-------------------------------------------------------------------
There are some non obvious bits that kept me from getting the layer
displayed at all:
- geometry_column: this is a layer contained in a BDMS, and Geoserver
users the name of the db column for the geometry attribute, yet the
code defaults to "the_geom" if geometry column is not provided
(which is the default name for shapefiles in Geoserver)
- projection: ok, did not know I had to set it
- maxResolution: this is a projected map on a small area, if one
does not raise the maxResolution there is no way to have the layer
displayed. Yet, better not use the same value as WMS, since there
are too many geometries, and the WFS layer just kills Firefox as
a result. Using a max resolution 1/20 of the WMS layer I managed to
make the map display in reasonable times.
I hope these can help someone else trying to setup a WFS layer on a
projected CRS.
Now, the question. I've added a DrawFeature control to the map, but
no matter what, it does not work: it activates, but then I cannot see
the lines I'm trying to draw on the screen.
I guess there is a secret ingredient needed to make it work on
projected coordinates, but I don't know what it is.
Can anybody enlighten me? :)
Cheers
Andrea
More information about the Users
mailing list