hi,

is there a possibility to trigger a wfs layer request without calling
setcenter? my current solution is running, but i want to avoid the
setcenter() with lat=0, lon=0 to trigger the calculation of the center
with wfs features.

<script type="text/javascript">
        var map;
        var geographic = new OpenLayers.Projection("EPSG:4326");
        var mercator = new OpenLayers.Projection("EPSG:900913");
        function loadMap() {
                var world = new OpenLayers.Bounds(-180, -89, 180, 89).transform(
                        geographic, mercator
                );

                var options = {
                        projection: mercator,
                        displayProjection: geographic,
                        units: "m",
                        numZoomLevels: 20,
                        maxExtent: world,
                        maxResolution: "auto"
                };

                // Create the map object
                map = new OpenLayers.Map('map', options);
                map.addControl(new OpenLayers.Control.LayerSwitcher());

                OpenLayers.loadURL("http://localhost:8080/.......";, null, null, 
loadSLD);
        }

        function loadSLD(req) {
                var format = new OpenLayers.Format.SLD();
                var sld = format.read(req.responseXML || req.responseText);
                var style = sld.namedLayers["main"].userStyles[0];

                // create Google Maps layer
                var gmap = new OpenLayers.Layer.Google(
                        "Google Maps", // the default
                        {'sphericalMercator': true, numZoomLevels: 20}
                );

                // create Google Satellite layer
                var gsat = new OpenLayers.Layer.Google(
                        "Google Maps Satellite",
                        {type: G_SATELLITE_MAP, 'sphericalMercator': true, 
numZoomLevels: 20}
                );

                // create WFS layer
                var wfslayer = new OpenLayers.Layer.Vector("WFS", {
                        styleMap: new OpenLayers.StyleMap(style),
                        strategies: [new OpenLayers.Strategy.BBOX()],
                        protocol: new OpenLayers.Protocol.WFS({
                                url:  "http://localhost:8080/........";,
                                featureType: "xy",
                                featureNS: "http://xy";,
                                srsName: "EPSG:900913",
                                version: "1.1.0"
                        })
                });

                // calculate the zoom and center
                wfslayer.events.register("loadend", wfslayer, function (e) {
                        var objectFeatures = this.features;
                        if ( objectFeatures.length != 0 ) {
                                var bounds = wfslayer.getDataExtent();
                                map.zoomToExtent(bounds);
                        }
                });

                map.addLayers([gmap, gsat, wfslayer]);

                // trigger wfs request
                map.setCenter(new OpenLayers.LonLat(0, 0));
        }
</script>
-- 
------------------------------------------------------------------------
Email:   k...@kybeidos.de
Telefon: +49 (0) 6221 - 616050
Fax:     +49 (0) 6221 - 616051
------------------------------------------------------------------------
KYBEIDOS Gesellschaft für Systeme zur Unternehmenssteuerung mbH
Moltkestraße 27
69120 Heidelberg

Handelsregister: Heidelberg HRB 5460
USt.Id-Nr.: DE182073772
Geschäftsführer: Stephan Frenzel, Dietmar Hantsch, Dr. Michael Wiedemann

_______________________________________________
Users mailing list
Users@openlayers.org
http://openlayers.org/mailman/listinfo/users

Reply via email to