O'Reilly logo

OpenLayers Cookbook by Antonio Santiago Perez

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Avoiding the need of a base layer

There can be situations where you don't want a base layer and only want a bunch of layers to work on.

Imagine an online GIS editor where users can add and remove layers but they are not obligated to have an always visible one.

This recipe shows how we can easily avoid the requirement of setting a base layer within the map.

Avoiding the need of a base layer

How to do it...

  1. As always, create a DOM element to render the map:
    <div id="ch1_avoid_baselayer" style="width: 100%; height: 100%;"></div>
  2. Now create a new OpenLayers.Map instance and set the allOverlays property to true:
    // Create the map using the specified DOM element var map = new OpenLayers.Map("ch1_avoid_baselayer", ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required