2

I am new in Openlayers and web services in general, but until now I have managed to create a WMS (published by ArcGis to a server provided by uni) and connect it with Openlayers. Projection etc works properly but I don't know how to reach our WFS (e.g. GetFeatureInfo). I need it for applications like highlighing features from a search function, or mouse sensitive events. Any idea?

   function init() {

    var options = {
        projection: new OpenLayers.Projection("EPSG:3857"),
        units: "m",
        maxResolution: "auto",
        numZoomLevels: 22,
        maxExtent: new OpenLayers.Bounds(-3339584.723798, -30240971.958386,

                                          6679169.447596, 30240971.958386)
    };

    map = new OpenLayers.Map('map', options);

    var wms = new OpenLayers.Layer.WMS(
            "WMS", "http://mikro.bv.tu-berlin.de/arcgis/services/student_grp1/campus_prj/MapServer/WMSServer?",
                  {layers: '1,2,3,4,5,6,7', version:'1.3.0', crs: 'EPSG:3857', transparent:true, isBaseLayer: true});

    var gsat = new OpenLayers.Layer.Google(
            "Google Satellite", {type: google.maps.MapTypeId.SATELLITE, numZoomLevels: 22}
        );


    map.addLayer(gsat);
    map.addLayer(wms);

    map.addControl(new OpenLayers.Control.LayerSwitcher());

    map.setCenter(new OpenLayers.LonLat(13.326169, 52.512134).transform(
        new OpenLayers.Projection("EPSG:4326"),
        map.getProjectionObject()), 16); 
   }
1

In WMS request, if the layer is topp:tasmania_roads, then the FeatureType is tasmania_roads and FeatureNS is Namespace URI of topp. You can find the Namespace URI from workplace. For topp it is "http://www.openplans.org/topp". In My example below, the layer name in ris:trans_ln_8

var wfsroads = new OpenLayers.Layer.Vector("roadWFS", 
        {   strategies: [new OpenLayers.Strategy.BBOX()],
            //styleMap: new OpenLayers.StyleMap({   "default": new OpenLayers.Style(null, {rules: new OpenLayers.Rule()})}),
            protocol: new OpenLayers.Protocol.WFS({
                url:  host+port+"/geoserver/wfs",
                featureType: "trans_ln_8",
                featureNS: "http://geoserver/postgis",
                version: "1.1.0",
                srs:"EPSG:4326"
            }),
            displayInLayerSwitcher: false,
            visibility: false
        }
    );

This is the case in geoserver, if you are using ArcGIS server, you should probable look at OpenLayers.Layer.ArcGIS93Rest or OpenLayers.Layer.ArcIMS.

you can also look at OpenLayers.Protocol.WFS.fromWMSLayer, if you are successful in getting WMS layers.

| improve this answer | |
  • Thank for your answer. Unfortunately, I couldn't make it work like this. Turns out that the solution is more comlpicated, using Esri JSON. However, neither this works until now in my case. – user_3849 Apr 10 '13 at 13:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.