O'Reilly logo

OpenLayers 2.10 by Erik Hazzard

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

Time for Action – changing the Renderers array

Let's use the Canvas renderer and see what our map looks like.

  1. Make a copy of the previous example. We'll just be changing one line of the code.
  2. The only thing we'll need to do is set the renderers property when instantiating the vector layer. By default, it is set as ['SVG', 'VML', 'Canvas']. Let's make Canvas the default renderer. Replace your vector layer instantiation code with:
    var vector_layer = new OpenLayers.Layer.Vector('Basic Vector Layer', { 
        renderers: ['Canvas', 'SVG', 'VML'] 
    });
  3. Open up the map and draw some points. It may look similar, but you will probably notice that the lines don't look as sharp as they do when using the SVG renderer. If you use Firebug to inspect the map element, you'll ...

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