Fork me on GitHub

Surface Image

This example adds two surface images to the basic globe:

  • A remote image showing Mount Etna erupting on July 13th, 2001.
  • The NASA ‘Meatball’ logo.

SurfaceImageFragment.java

The SurfaceImageFragment class extends the BasicGlobeFragment and overrides the createWorldWindow method. Here we create two SurfaceImage objects and add them to a RenderableLayer, and then we add the layer to the globe.

public class SurfaceImageFragment extends BasicGlobeFragment {

    /**
     * Creates a new WorldWindow with an additional RenderableLayer containing two SurfaceImages.
     */
    @Override
    public WorldWindow createWorldWindow() {
        // Let the super class (BasicGlobeFragment) do the creation
        WorldWindow wwd = super.createWorldWindow();

        // Configure a Surface Image to display an Android resource showing the NASA logo.
        Sector sector = new Sector(37.46, 15.5, 0.5, 0.6);
        int resourceId = R.drawable.nasa_logo;
        SurfaceImage surfaceImageResource = new SurfaceImage(sector, ImageSource.fromResource(resourceId));

        // Configure a Surface Image to display a remote image showing Mount Etna erupting on July 13th, 2001.
        sector = new Sector(37.46543388598137, 14.60128369746704, 0.45360804083528, 0.75704283995502);
        String urlString = "https://worldwind.arc.nasa.gov/android/tutorials/data/etna.jpg";
        SurfaceImage surfaceImageUrl = new SurfaceImage(sector, ImageSource.fromUrl(urlString));

        // Add a WorldWindow layer that displays the Surface Image, just before the Atmosphere layer.
        RenderableLayer layer = new RenderableLayer("Surface Image");
        layer.addRenderable(surfaceImageResource);
        layer.addRenderable(surfaceImageUrl);
        wwd.getLayers().addLayer(layer);

        // Position the viewer so that the Surface Images are visible when the activity is created.
        wwd.getNavigator().setLatitude(37.46543388598137);
        wwd.getNavigator().setLongitude(14.97980511744455);
        wwd.getNavigator().setAltitude(4.0e5);

        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