[OpenLayers-Users] Problem with getting variables from geometry
Armin Retterath
armin.retterath at bkg.bund.de
Wed Sep 5 11:13:20 EDT 2007
Hello List,
I ve problems with getting coordinates from the geometry object which is
derived from a wfs object.
Here's the example:
function init(){
var options = {
maxExtent: new OpenLayers.Bounds(2500000, 5300000, 2700000,5700000 ),
projection: "EPSG:31466",
maxResolution: 5000,
units: "meters"
};
var offset = 1000;
OpenLayers.ProxyHost = "http://localhost/cgi-bin/proxy.cgi?url=";
map = new OpenLayers.Map( 'map',options );
layer = new OpenLayers.Layer.WMS( "Atkis
Rheinland-Pfalz","http://www.gdi-rp-dienste2.rlp.de/cgi-bin/mapserv4102.fcgi?map=/data/umn/navigation_atkis_ldi.map&",
{layers: "landesgrenze,gewaesser_dlm250_fl,Gemeinden85000"});
layer2 = new OpenLayers.Layer.WFS( "departm",
"http://www.gdi-rp-dienste.rlp.de/cgi-bin/mapserv50b4?map=/data/umn/behoerden/behoerden_wfs.map&",
{ typename: "verwaltungen", maxfeatures: 10,featureid: "verwaltungen.200"});
map.addLayers([layer,layer2]);
map.setCenter(new OpenLayers.LonLat(lon, lat), zoom);
map.addControl(new OpenLayers.Control.LayerSwitcher());
valuex = layer2.features[0].geometry.x;
valuey = layer2.features[0].geometry.y;
minx = valuex - offset;
miny = valuey - offset;
maxx = valuex + offset;
maxy = valuey + offset;
var bbox = new OpenLayers.Bounds(minx, miny ,maxx ,maxy);
map.zoomToExtent(bbox);
}
The map should render the wms and the wfs point object, which is done well.
Next thing, is to zoom to an arbitrary extent around the point object. With
firebug I controlled the values of the objects.
layer2.features[0].geometry.x is an float as it should be. When setting an
firebug breakpoint at "valuex = layer2.features[0].geometry.x;" the script
stops and ol shows the things I expected. After step in, the variables are
set correctly to the values (valuex and valuey).
If I remove the breakpoint, the values would not be set to the floating
numbers in layer2.features[0].geometry.x/y.
I'm new to javascript, maybe I forgot or don't know something?!
Is there a method for getting the values which must be used instead?
Another problem is, that alerts don't work? Why this?
Thanx
Armin
--
Armin Retterath
Tel.: +49 69 63 33 - 326
e-mail: armin.retterath at bkg.bund.de
More information about the Users
mailing list