WorldWind Android

Surface Image

This example adds two surface images to the basic globe:

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.
    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 = "";
        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");

        // Position the viewer so that the Surface Images are visible when the activity is created.

        return wwd;