Azure maps OGC Map layer Capabilities support

Pine, Michael 21 Reputation points
2020-11-04T21:07:09.09+00:00

Hi,

we are adding some map layers onto Azure maps using the OGC Map Layer and I have all the sample code working on a local project.

We have some in house built map layers that produce asset tiles for our infrastructure and I've spent a few days now trying to work out why the tiles are not being produced and it seems to be down to when the request is sent off for the tile that the azure maps service is not honouring the capabilities defined by the source service, specifically the "Styles" parameter is being lower cased to "default" instead of the reported "Default", this unfortunately causes the XML response "Styles value is not defined" if I take that same URL and replace the Styles=default with Styles=Default the map tile is produced as expected.

I can't seem to find any configuration options that will effect the url generation, so I am also going to open a support ticket but I was wondering if anyone has seen this behaviour as this basically means I will probably need to request the service that has been built to be modified to be case in sensitive as I have seen the sample WMS services work ok with the lower case default but I haven't seen their capabilities and what they report.

thanks
Michael

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

Accepted answer
  1. rbrundritt 18,686 Reputation points Microsoft Employee
    2020-11-04T22:33:48.157+00:00

    I dug into this issue and found a bug in the spatial io module. I've reported it to the dev team, but not sure when it will be fixed in production. That said, I've come up with a simple workaround to unblock you. You can add an option when loading the map to transform requests before they are made. Adding the following to the map options when loading the map will look for this service, and change "default" to "Default". I tested it out with the service you provided and it seemed to work.

    transformRequest: function (url, requestType) {
        //Look for requests to the water service that is for an image
        if (url.indexOf('webmap.southeastwater.com.au/WMSWater') > -1) {
            //Using regular expression to replace in case there are multiple styles in the URL.
            return { url: url.replace(/default/gi, 'Default') };
        }
    
        return { url: url };
    }
    
    1 person found this answer helpful.

6 additional answers

Sort by: Most helpful
  1. rbrundritt 18,686 Reputation points Microsoft Employee
    2020-11-04T21:38:26.757+00:00

    You can set the "styles" using setOptions. For example:

    layer.setOptions({
        styles: 'Default'
    })
    

    See if that works. If not, take a look at the capabilities XML and see what the styles area listed in there. Its possible that the XML has a lower case "default" which could be the issue. You can also use the getCapabilities function and look at the response. The sublayers will have a list of supported styles extracted from the XML capabilities.

    Note, if there is no style defined in the capabilities, the OgcMapLayer fallback to "default" which is the standard used in most WMS/WMTS services.

    If this doesn't work, are you using WMS or WMTS? Is the service publicly accessible? Do you know what the serving platform is; MapServer, GeoServer... and the version.

    1 person found this answer helpful.

  2. rbrundritt 18,686 Reputation points Microsoft Employee
    2020-11-04T22:50:45.763+00:00

    I'm not sure, when I try and load this using localhost it works fine, I haven't tried hosting it anywhere else. It is possible that their may be a CORs related issue, however if that was the issue, the get capabilities call would have failed. Try panning and zooming around a bit and see if you see any of the data appear.

    Try setting the "debug" option of the OgcMapLayer to true. In order to support all the different variations of OGC WMS/WMTS services and it does a lot of testing of URL's until if figures out what works best. This is hidden by default but insights can be seen in the console when debug is set to true.

    Here is the complete code sample I used to get this working:

        var map, layer;
    
        function GetMap() {
            //Initialize a map instance.
            map = new atlas.Map('myMap', {
                center: [145.275505, -38.2],
                zoom: 11,
                view: 'Auto',
    
                authOptions: {
                    authType: 'subscriptionKey',
                    subscriptionKey: '<Your Azure Maps Key>'
                },
                transformRequest: function (url, requestType) {
                    //Look for requests to the water service that is for an image
                    if (url.indexOf('webmap.southeastwater.com.au/WMSWater') > -1) {
                        console.log(url)
                        //Using regular expression to replace in case there are multiple styles.
                        return { url: url.replace(/default/gi, 'Default') };
                    }
    
                    return { url: url };
                }
            });
    
            //Wait until the map resources are ready.
            map.events.add('ready', function () {
                //Create an instance of the OGC map layer and add it to the map. In this case below the transit data (roads).
                layer = new atlas.layer.OgcMapLayer({
                    url: 'https://webmap.southeastwater.com.au/WMSWater/Service.svc/get?request=GetCapabilities&service=WMS'
                });
                map.layers.add(layer);
            });
        }
    
    1 person found this answer helpful.
    0 comments No comments

  3. Khurram Rahim 1,841 Reputation points
    2020-11-04T21:11:40.43+00:00

  4. Pine, Michael 21 Reputation points
    2020-11-04T21:55:21.187+00:00
    0 comments No comments

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.