Geoportal Extension for OpenLayers API Reference

Class: Drawing

ol.control.Drawing

Drawing Control.

new Drawing(options)

OpenLayers/Controls/Drawing.js, line 166
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.

markerSize String optional

Label for markerSize.

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.

Example
var drawing = new ol.control.Drawing({
  collapsed : false,
  draggable : true,
  layerswitcher : {
     title : "Dessins",
     description : "Mes dessins..."
  },
  markersList : [{
     src : "http://api.ign.fr/api/images/api/markers/marker_01.png",
     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;
     }
});

Extends

  • ol.control.Control

Members

collapsed

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

draggable

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

Methods

exportFeatures(){String}

OpenLayers/Controls/Drawing.js, line 373

Export features of current drawing layer (KML by default).

Returns:
representation of drawn features (KML, GPX or GeoJSON) or null if not possible.

getContainer(){DOMElement}

OpenLayers/Controls/Drawing.js, line 588

Get container

getExportFormat(){String}

OpenLayers/Controls/Drawing.js, line 502

getter for Export format.

Returns:
format

getExportName(){String}

OpenLayers/Controls/Drawing.js, line 466

getter for Export Name.

Returns:
name

getLayer(){Object}

OpenLayers/Controls/Drawing.js, line 579

Get vector layer

Returns:
- isocurve layer

setCollapsed(collapsed)

OpenLayers/Controls/Drawing.js, line 439

Collapse or display control main container

Name Type Description
collapsed Boolean

True to collapse control, False to display it

setExportFormat(format)

OpenLayers/Controls/Drawing.js, line 475

Setter for Export format (KML, GPX or GeoJSON).

Name Type Description
format String

Export format. By default, "KML".

setExportName(name)

OpenLayers/Controls/Drawing.js, line 457

Setter for Export Name.

Name Type Description
name String

Export Name. By default, "Croquis".

setLayer(vlayer)

OpenLayers/Controls/Drawing.js, line 511

Sets vector layer to hosts feature.

Name Type Description
vlayer ol.layer.Vector

vector layer

setMap(map)

OpenLayers/Controls/Drawing.js, line 321

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.