Drawing new features

Our feature editor can now be used for loading data and modifying features. Next up, we'll add a Draw interaction to allow people to draw new features and add them to our source.

First, import the Draw interaction (in main.js):

import Draw from 'ol/interaction/Draw';

Now, create a draw interaction configured to draw polygons and add them to our vector source:

  new Draw({
    type: 'Polygon',
    source: source,

The type property of the draw interaction controls what type of geometries are drawn. The value can be any of the GeoJSON geometry types.

With our draw interaction in place, we can now add new features to our vector source.

A new island nation in the Caribbean
A new island nation in the Caribbean

results matching ""

    No results matching ""