Skip to content

Instantly share code, notes, and snippets.

@DavidSpriggs
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DavidSpriggs/0df4ea2e4b007d74f7ac to your computer and use it in GitHub Desktop.
Save DavidSpriggs/0df4ea2e4b007d74f7ac to your computer and use it in GitHub Desktop.
Adding two widgets to one title pane
drawmeasure: {
include: true,
id: 'drawandmeasurement',
widgetType: 'titlePane',
widgetClass: 'gis/dijit/DrawAndMeasurement',
title: 'Darw and Measurement',
open: false,
position: 4,
options: {
map: true,
mapClickMode: true,
defaultAreaUnit: units.SQUARE_MILES,
defaultLengthUnit: units.MILES
}
}
define([
'dojo/_base/declare',
'dijit/_WidgetBase',
'esri/dijit/Measurement',
'gis/dijit/Draw',
'dojo/aspect',
'dojo/_base/lang',
'dojo/dom-construct',
'dijit/TitlePane'
], function(declare, _WidgetBase, Measurement, Draw, aspect, lang, domConstruct, TitlePane) {
return declare([_WidgetBase], {
declaredClass: 'gis.digit.DrawAndMeasurement',
postCreate: function() {
this.inherited(arguments);
this.mTp = new TitlePane({
title: 'Measurement',
open: false
}).placeAt(this.domNode);
this.mTp.startup();
this.measure = new Measurement({
map: this.map,
defaultAreaUnit: this.defaultAreaUnit,
defaultLengthUnit: this.defaultLengthUnit
}, domConstruct.create('div')).placeAt(this.mTp.containerNode);
this.measure.startup();
aspect.before(this.measure, 'measureArea', lang.hitch(this, 'setMapClickMode', 'measure'));
aspect.before(this.measure, 'measureDistance', lang.hitch(this, 'setMapClickMode', 'measure'));
aspect.before(this.measure, 'measureLocation', lang.hitch(this, 'setMapClickMode', 'measure'));
aspect.after(this.measure, 'closeTool', lang.hitch(this, 'setMapClickMode', this.mapClickMode.defaultMode));
this.dTp = new TitlePane({
title: 'Draw',
open: false
}).placeAt(this.domNode);
this.dTp.startup();
// add draw
this.draw = new Draw({
map: this.map,
mapClickMode: this.mapClickMode
}, domConstruct.create('div')).placeAt(this.dTp.containerNode);
},
setMapClickMode: function(mode) {
this.mapClickMode.current = mode;
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment