Layers

Layers hold all the information displayed by the WorldWindow. Each WorldWindow has a layer list that contains all the layers to display in that WorldWindow. Each layer contains either imagery, shapes or decorations such as a compass. During rendering, layers are displayed in the order they’re defined in the layer list. (3D shapes within layers, however, are displayed in far-to-near order.)

The following code depicts six layers. The first two are image layers. The second two hold shapes. And the bottom two hold decorations.

// Create and add imagery layers.
wwd.addLayer(new WorldWind.BMNGLayer());
wwd.addLayer(new WorldWind.BingAerialWithLabelsLayer());

// Create and add layers for shapes, but don't add any shapes yet.
wwd.addLayer(new RenderableLayer());
wwd.addLayer(new RenderableLayer());

// Create and add a compass and view controls.
wwd.addLayer(new WorldWind.CompassLayer());
wwd.addLayer(new WorldWind.ViewControlsLayer(wwd));

// Update the display.
wwd.redraw();

Layer Properties

Layers have the following properties:

There are several types of layers. Each defines additional properties that you can use to control the layer’s behavior. See the API doc for the particular layer to discover those properties. The layer type you’re likely to use most is RenderableLayer, which you use to hold shapes. It’s described below. Apps typically create several of these.

Image Layers

Image layers hold imagery that is drawn on the surface of the globe. This is typically global-coverage imagery but need not be. Web WorldWind provides the following image layers:

The Bing imagery layers require an API key. The documentation details the steps necessary to specify your API key. You can create your own image layers using TiledImageLayer. The imagery need not span the entire globe.

Renderable Layer

You use the RenderableLayer class when you want to display shapes. The layer can hold any number of shapes. Apps typically use renderable layers to group shapes logically. To display a shape, you simply create it using its constructor and add it to a renderable layer:

var placemarkLayer = new WorldWind.RenderableLayer("Placemarks");
var placemark = new WorldWind.Placemark(new WorldWind.Position(latitude, longitude, altitude));

placemarkLayer.addRenderable(placemark);

Here the layer is given the display name “Placemarks”. You must also add the renderable layer to the WorldWindow’s layer list:

wwd.addLayer(placemarkLayer);

Renderable layers hold any kind of shape.

Utility Layers and Decorations

Besides image layers and renderable layers, WebWorldWind also includes preconfigured utility layers.

And some visual effects.

Layers in Action

Here’s a demonstration of different layers added to WorldWindow. We’ll utilize these layers in follow-on lessons.

Next Steps