Skip to main content

Draw Tool Add-on

Draw tool allows us to draw on a map. Below are tools available,

  1. LineString tool
  2. Polygon tool
  3. Marker tool
  4. Delete

Example setup

View a working demo and follow the steps below to create your own

<link href="https://maps-sdk.trimblemaps.com/addon/trimblemaps-draw-1.0.2.css" rel="stylesheet">
<!-- Draw tool addon reference css -->
<script src="https://maps-sdk.trimblemaps.com/addon/trimblemaps-draw-1.0.2.js"></script>
<!-- Draw tool addon reference js -->
TrimbleMaps.APIKey = "YOUR_ACCESS_TOKEN";

var map = (window.map = new TrimbleMaps.Map({
  container: "map",
  style: TrimbleMaps.Common.Style.TRANSPORTATION,
  zoom: 12.5,
  center: [-77.01866, 38.888],
  region: TrimbleMaps.Common.Region.NA,
}));

var Draw = new TrimbleMapsControl.Draw({
  // Include other optional customization options
});

// Map#addControl takes an optional second argument to set the position of the control.
// If no position is specified the control defaults to `top-right`.
map.addControl(Draw, "top-left");

Customization Options

Parameter Type/Values Description
displayControlsDefault
Boolean
Default: true
The default value for controls. For example, if you would like all controls to be off by default, and specify an allowed list with controls, use displayControlsDefault: false
controls
Object
Hide or show individual controls. Each property’s name is a control, and value is a boolean indicating whether the control is on or off. Available control names are point, line_string, polygon, trash. By default, all controls are on. To change that default, use displayControlsDefault.
boxSelect
Boolean
Whether or not to enable box selection of features with shift+click+drag. If false, shift+click+drag zooms into an area.
clickBuffer
Number
Number of pixels around any feature or vertex (in every direction) that will respond to a click.
touchBuffer
Number
Number of pixels around any feature of vertex (in every direction) that will respond to a touch.

API Documentation

View Draw Tool API Documentation

Last updated June 15, 2023.