Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Need help with getfeatureinfo for OpenLayers/WMS

  • 12-04-2017 2:12pm
    #1
    Registered Users, Registered Users 2 Posts: 227 ✭✭


    Hi Folks, I am developing a GIS web-map and am hoping someone could help me with the getfeatureinfo method to call information from a WMS layer. I have the web-map working in that I can display various WMS/WFS layers. Behind the layers that are attribute tables and everything is hosted by GeoServer 2.8.2. I'm trying to figure out how to click on a feature on a WMS layer and call the attributes of that into a pop-up. I've looked at a load of examples on line but can't get any of them to work on my map.

    Here is the code for a map.js page. I have deleted the code for most of the layers for convenience sake. There is an attribute behind the DART station layer called stop_name.
    var map;
    
    function initMap() {
    
        //initialise variables
        var osmlayer;
        var point;
        var dlr_libraries_wfs;
    	var dlr_libraries_wms;
    	var dlr_townlands_wms;
    	var dlr_mtowers_wfs;
    	var dlr_mtowers_wms;
    	var dlr_DART_wfs;
    	var dlr_dart_wms
    	var dlr_war_memorial_wfs
    	var dlr_war_memorial_wms
    	var info;
    
        //create new map object
        map = new OpenLayers.Map("mymap");
    
        //create new OSM base layer
        osmlayer = new OpenLayers.Layer.OSM("Open Street Map");
    
        //create WMS layers
    
    	// DART Station Layer.
    	dlr_DART_wfs = new OpenLayers.Layer.Vector("DART Stations (WFS)",
            {
            strategies:[new OpenLayers.Strategy.BBOX()],
            protocol: new OpenLayers.Protocol.WFS(
                    {
                    version: "1.1.0",
                    url: "http://localhost:8080/geoserver/wfs",
                    featureType: "EastC_Darts",
                    featurePrefix: "egm715",
                    featureNS: "http://geoserver.org/egm715",
                    }
                ),
            visibility: false,
            }
        );
    
    	dlr_dart_wms = new OpenLayers.Layer.WMS("DLR DART Stations (WMS)", "http://localhost:8080/geoserver/egm715/wms",
            {
            layers: "egm715:EastC_Darts",
            transparent: true
            }, {
            projection: "EPSG:3857",
            opacity: 0.5,
            visibility: false
            }
        );
    	
    	
        //add layers to the map
        map.addLayers([osmlayer, dlr_libraries_wfs, dlr_libraries_wms, dlr_DART_wfs, dlr_dart_wms, dlr_war_memorial_wfs, dlr_war_memorial_wms ]);
    
        //add LayerSwitcher control object
        map.addControl(new OpenLayers.Control.LayerSwitcher());
    
    
        // define point as a new LonLat object and transfom
        point = new OpenLayers.LonLat(-6.1832, 53.2560); 
        point.transform("EPSG:4326", "EPSG:900913");
    	
    	
        //centre the map and set zoom level
        map.setCenter(point, 11.7);
    
    }
    
    I'm grateful to anyone who gets back to me with some help. Thanks.


Advertisement