getFeatureInfo returning null from Azure maps WMS service

Aakash 60 Reputation points
2023-06-13T16:59:10.8966667+00:00

Hello,

I'm trying to load the following WMS service: https://gin.gw-info.net/service/gin/wms/mediator/gin_en?request=GetCapabilities&version=1.1.0&service=WMS

I would like to display the underlying features of this WMS service via popup upon mapclick. For this, I use the azure maps getFeatureInfo function. Unfortunately, I don't seem to be getting any features returned and printing out the result shows that this function call returns null. Below is my code using this service:

let options = { 								
url: '
bringIntoView: true,
debug: true,
opacity: 0.60
}
options.activeLayers = ['WaterWells']
let layer = new atlas.layer.OgcMapLayer(options);
map.layers.add(layer, 'transit');

function mapClick(e) { 								
	layer.getFeatureInfo(e.position).then(result => {
		if (result && result.features && result.features.length > 0) {
			popup.setOptions({
				content: atlas.PopupTemplate.applyTemplate(result.features[0].properties),
				position: e.position
			});
			
			popup.open(map);
		}
	})
}

I tried loading the same WMS service on QGIS software and there seems to be features available in this WMS service. I've attached a screenshot of the features loaded for WaterWells sublayer from the url.

I tried by changing the service version from 1.1.0 to 1.3.0 but the same issue persists.

I would really appreciate some help on this!

Best Regards,

Aakash
featuresLoaded

Azure Maps
Azure Maps
An Azure service that provides geospatial APIs to add maps, spatial analytics, and mobility solutions to apps.
832 questions
{count} votes

Accepted answer
  1. rbrundritt 20,836 Reputation points Microsoft Employee Moderator
    2023-06-14T20:03:16.1166667+00:00

    Looking into this service it can only return feature information as HTML, not as a raw WFS response. If you look at the GetCapabilities XML for the WMS service you linked to, you will see under GetFeatureInfo section that it only supports HTML formats. So, instead of using getFeatureInfo you should use the getFeatureInfoHtml function https://learn.microsoft.com/en-us/javascript/api/azure-maps-spatial-io/atlas.layer.ogcmaplayer?view=azure-maps-typescript-latest#azure-maps-spatial-io-atlas-layer-ogcmaplayer-getfeatureinfohtml

    Here is an example of how to modify your mapClick function:

    function mapClick(e) { 								
    	layer.getFeatureInfoHtml(e.position).then(result => {
    		if (result) {
    			popup.setOptions({
    				content: result,
    				position: e.position
    			});
    			
    			popup.open(map);
    		}
    	})
    }
    

    Unfortunately, while looking into this I found that there is a bug with the getFeatureInfoHtml function. I found the following workaround for this bug:

    layer.getCapabilities().then(cap => {
    	if (cap && !cap._canGetFeatureInfo && cap._canGetHtmlFeatureInfo){
    		cap._canGetFeatureInfo = true;
    	}
    });
    

    That said, I found that this service more often than not returned an empty HTML page.

    3 people found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Clemens Schotte 356 Reputation points Microsoft Employee
    2023-06-16T10:25:41.5266667+00:00

    Thank you for bringing this to our attention. I have notified our SDK team, and they will address the issue in the upcoming release by implementing a fix.

    2 people found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.