TransWikia.com

Open Layers get WMS Layer attributes without single click event

Geographic Information Systems Asked by Hilal Al-Rajhi on February 7, 2021

I am using javascript open layers v6.4.3 to load data from postgreSQL database. Here is my code to create feature layer and the click event to get identify feature:

roads3Layer = new ol.layer.Tile({
    source: new ol.source.TileWMS({
        url: "http://localhost:90/cgi-bin/mapserv.exe?map=d:/code/geoportal/geoportalWMS.map&",
        params: { "LAYERS": "Roads3", "TILED": true }
    })
});

navMap.addLayer(roads3Layer);

navMap.on('singleclick', function (evt) 
{
    var viewResolution = navMap.getView().getResolution();
    var url = roads3Layer.getSource().getFeatureInfoUrl
    (
        evt.coordinate, viewResolution, 'EPSG:3857',
        {
        'INFO_FORMAT': 'text/json',             
        'QUERY_LAYERS': 'Roads3, Regions'   
        }
    );
});

This works fine and identifies the feature without any problem using the click event.
My concern is that I need to get the attributes of roads3Layer without the click event. Something like this line:

var att = roads3Layer.getAttributes();

I need this because in my web application, I want to add the select by attribute functionality, where the user selects feature, then attributes loaded, then user selects one attribute and enter the search value.
I tried to find a url in the capabilities in my mapserver, but could not manage to find one.

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP