Select to view content in your preferred language

WMTSLayer WKID

956
2
10-29-2017 08:38 PM
AdamMaps84
New Contributor

Hi

I am trying a to add support of reading OGC services to a solution we are building, so the first guess is to use  "esri/layers/WMTSLayer" class. First thing noticed is that the service is not an actual service, rather it is a directory of image/tiled services. 
I encountered the following issues:
- the base map we are using "World_Imagery" has "102100" spatial reference wkid, while the #OGC service we are testing to use has spatial ref wkid "4326", which caused lot of JS errors from within the WMTSLayer api class

- i changed the scenario to use base map and OGC service with the same wkid, and the error disappeared and i can see both services on the map-view

Now I want to force limiting adding OGC services to the app unless the service has wkid identical to the base map's. The problem is that the WMTSLayer object that got filled after the layer is loaded has always wkid value of "4326", although I am using the service of wkid "3857" projection. Is there a way to get the correct WKID of the #WMTSLayer object?

0 Kudos
2 Replies
DavidBlanchard
Esri Contributor

I believe you should be able to do a GetCapabilities operation on the WMTS service just like you can with a WMS service. If so, just get that data ahead of time before creating the layer in the ArcGIS API. You could then check the returned XML for the appropriate projection data. Spatial references are usually prefixed with "EPSG".

GregoryBologna
Frequent Contributor

You can use esriRequest to get all the layers from capabilities meta.

require([
    "esri/request"
], function(esriRequest) {
    const capabilitiesUrl = "https://svc.someservice.com/Image/FBA1F622-5FF3-56B2-CBB2-777AD52F0EC9/wmts?request=GetCapabilities";

    // Fetch the WMTS capabilities
    esriRequest(capabilitiesUrl, { responseType: "text" })
        .then(function(response) {
            // Parse the XML response
            const parser = new DOMParser();
            const xmlDoc = parser.parseFromString(response.data, "application/xml");
            const layers = xmlDoc.getElementsByTagName("Layer");

            // Loop through each layer and extract details
            for (let i = 0; i < layers.length; i++) {
                const identifier = layers[i].getElementsByTagName("ows:Identifier")[0]?.textContent || "N/A";
                const title = layers[i].getElementsByTagName("ows:Title")[0]?.textContent || "N/A";
                const abstractText = layers[i].getElementsByTagName("ows:Abstract")[0]?.textContent || "N/A";

                console.log(`Layer Identifier: ${identifier}, Title: ${title}, Abstract: ${abstractText}`);
            }
        })
        .catch(function(err) {
            console.error("Error fetching WMTS capabilities: ", err);
        });
});

 

0 Kudos