Geoportal Extension for OpenLayers API Reference

Class: Drawing


Drawing Control.

new Drawing(options)

OpenLayers/Controls/Drawing.js, line 158
Name Type Description
options Object

options for function call.

Name Type Default Description
collapsed Boolean true optional

Specify if Drawing control should be collapsed at startup. Default is true.

draggable Boolean false optional

Specify if widget is draggable

layer Object {} optional

Openlayers layer that will hosts created features. If none, an empty vector layer will be created.

popup Object {} optional

Popup informations

Name Type Default Description
display Boolean true optional

Specify if popup is displayed when create a drawing

function function optional

Function to display popup informations if you want to cutomise it. You may also provide your own function with params : {geomType / feature / saveFunc(message) / closeFunc()}. This function must return the DOM object of the popup content.

layerDescription Object {} optional

Layer informations to be displayed in LayerSwitcher widget (only if a LayerSwitcher is also added to the map)

Name Type Default Description
title String "Croquis" optional

Layer title to be displayed in LayerSwitcher

description String "Mon croquis" optional

Layer description to be displayed in LayerSwitcher

tools Object

Tools to display in the drawing toolbox. All by default.

Name Type Default Description
points Boolean true optional

Display points drawing tool

lines Boolean true optional

Display lines drawing tool

polygons Boolean true optional

Display polygons drawing tool

holes Boolean false optional

Display polygons with holes drawing tool

text Boolean true optional

Display text drawing tool

remove Boolean true optional

Display feature removing tool

display Boolean true optional

Display style editing tool

tooltip Boolean true optional

Display text editing tool

edit Boolean true optional

Display editing tool

export Boolean true optional

Display exporting tool

measure Boolean false optional

Display measure drawing into popup info

labels String optional

Labels for Control

Name Type Description
control String optional

Label for Control

points String optional

Label for points drawing tool

lines String optional

Label for lines drawing tool

polygons String optional

Label for polygons drawing tool

holes String optional

Label for polygons with holes drawing tool

text String optional

Label for text drawing tool

edit String optional

Label for editing tool

display String optional

Label for style editing tool

tooltip String optional

Label for text editing tool

remove String optional

Label for feature removing tool

export String optional

Label for exporting tool.

exportTitle String optional

Title for exporting tool.

applyToObject String optional

Label for apply to object button.

saveDescription String optional

Label for save description button.

setAsDefault String optional

Label for set as default style button.

strokeColor String optional

Label for stroke color.

strokeWidth String optional

Label for stroke width.

fillColor String optional

Label for fill color.

fillOpacity String optional

Label for fillOpacity.

markersList Array.<Object> [{"src" : "data:image/png;base64,xxxx", "anchor" : [0.5,1]}] optional

List of markers src to be used for points with their anchor offsets See OpenLayers params for anchor offset options.

defaultStyles Object

Default styles applying to geometries (labels, lines and polygons).

Name Type Default Description
textFillColor String "#000000" optional

Text fill color for labels (RGB hex value).

textStrokeColor String "#FFFFFF" optional

Text surrounding color for labels (RGB hex value).

strokeColor String "#ffcc33" optional

Stroke color (RGB hex value).

strokeWidth Number 2 optional

Stroke width in pixels.

polyStrokeColor String "#ffcc33" optional

Stroke color (RGB hex value) for polygons.

polyStrokeWidth Number 2 optional

Stroke width in pixels for polygons.

polyFillColor String "#ffffff" optional

Polygons fill color (RGB hex value).

polyFillOpacity Number 0.2 optional

Polygon fill opacity (alpha value between 0:transparent and 1:opaque).

cursorStyle Object

cursor (circle) style when drawing or editing.

Name Type Default Description
fillColor String "rgba(0, 153, 255, 1)" optional

Cursor fill color.

strokeColor String "#FFF" optional

Cursor stroke color.

strokeWidth String 1 optional

Cursor surrounding stroke width.

radius String 6 optional

Cursor radius.

var drawing = new ol.control.Drawing({
  collapsed : false,
  draggable : true,
  layerswitcher : {
     title : "Dessins",
     description : "Mes dessins..."
  markersList : [{
     src : "",
     anchor : [0.5, 1]
  defaultStyles : {},
  cursorStyle : {},
  tools : {
     points : true,
     lines : true,
     polygons :true,
     holes : true,
     text : false,
     remove : true,
     display : true,
     tooltip : true,
     export : true,
     measure : true
  popup : {
     display : true,
     function : function (params) {
         var container = document.createElement("div");
         // - params.geomType;
         // - params.feature;
         // Les 2 fonctions ferment la popup avec ou sans sauvegarde des informations
         // dans les properties de la feature (key : description)
         // - params.saveFunc(message);
         // - params.closeFunc();
         return container;


  • ol.control.Control



{Boolean} specify if Drawing control is collapsed (true) or not (false)


{Boolean} specify if Drawing control is draggable (true) or not (false)



OpenLayers/Controls/Drawing.js, line 349

Export features of current drawing layer in KML.

KML representation of drawn features or null if not possible.


OpenLayers/Controls/Drawing.js, line 416

getter for Export Name.



OpenLayers/Controls/Drawing.js, line 389

Collapse or display control main container

Name Type Description
collapsed Boolean

True to collapse control, False to display it


OpenLayers/Controls/Drawing.js, line 407

Setter for Export Name.

Name Type Description
name String

Export Name. By default, "Croquis".


OpenLayers/Controls/Drawing.js, line 685

Sets vector layer to hosts feature.

Name Type Description
vlayer ol.layer.Vector

vector layer


OpenLayers/Controls/Drawing.js, line 297

Overload of ol.control.Control.setMap() method, called when control is added to or removed from map.

Name Type Description
map Object

ol.Map object.