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.