Creating a custom renderer
When working with vector layers, styling is a great feature which offers us a lot of possibilities: fill color and opacity, stroke color, labels and text colors, and so on. But, what if we need more?
Every OpenLayers.Layer.Vector
instance contains a renderer that is responsible to render the layer's features (such as points, paths, and polygons) on the map using the best technologies available in the browser. These can be the HTML5 Canvas element (http://en.wikipedia.org/wiki/Canvas_element) available in many modern browsers (such as Firefox or Chrome), SVG (http://en.wikipedia.org/wiki/Scalable_Vector_Graphics), or VML (http://en.wikipedia.org/wiki/Vector_Markup_Language).
When OpenLayers.Layer.Vector
is initialized, OpenLayers looks for the best available rendering engine and creates an instance of OpenLayers.Renderer
that will render the features on the map.
The goal of this recipe is to show how we can create a new renderer to improve the visualization of the...