Fork me on GitHub

WMTS Layer

This tutorial adds a hillshade WMTS layer to the basic globe example.

WmtsLayerFragment.java

The WmtsLayerFragment class extends the BasicGlobeFragment and overrides the createWorldWindow method. Here we use WorldWind’s LayerFactory to display the contents of a remote OGC Web Map Tile Service (WMTS). LayerFactory asynchronously negotiates with the WMTS endpoint to configure a WorldWind layer, then notifies the application when it’s done.

package gov.nasa.worldwindx;
...
public class WmtsLayerFragment extends BasicGlobeFragment {

    /**
     * Creates a new WorldWindow (GLSurfaceView) object with a WMTS Layer
     *
     * @return The WorldWindow object containing the globe.
     */
    @Override
    public WorldWindow createWorldWindow() {
        // Let the super class (BasicGlobeFragment) do the creation
        WorldWindow wwd = super.createWorldWindow();

        // Create a layer factory, WorldWind's general component for creating layers
        // from complex data sources.
        LayerFactory layerFactory = new LayerFactory();

        // Create an OGC Web Map Tile Service (WMTS) layer to display Global Hillshade based on GMTED2010
        layerFactory.createFromWmts(
            "https://tiles.geoservice.dlr.de/service/wmts", // WMTS server URL
            "hillshade",                                    // WMTS layer identifier
            new LayerFactory.Callback() {
                @Override
                public void creationSucceeded(LayerFactory factory, Layer layer) {
                    // Add the finished WMTS layer to the WorldWindow.
                    getWorldWindow().getLayers().addLayer(layer);
                    Log.i("gov.nasa.worldwind", "WMTS layer creation succeeded");
                }

                @Override
                public void creationFailed(LayerFactory factory, Layer layer, Throwable ex) {
                    // Something went wrong connecting to the WMTS server.
                    Log.e("gov.nasa.worldwind", "WMTS layer creation failed", ex);
                }
            }
        );

        return wwd;
    }
}


Server maintenance notice

Dear WorldWind Community,

The geospatial data services that feed WorldWind clients by default with data are undergoing maintenance. Outages between 2 to 4 hours per server may occur during the month of April 2023.

As always, if you have any inquiries or concerns, please contact us at:

arc-worldwind@mail.nasa.gov