Select to view content in your preferred language

'jimu/dijit/DrawBox' Documentation?

8519
11
Jump to solution
06-07-2016 04:12 PM
MarcusHarner
Regular Contributor

I am trying to add a drawing capability to a widget.  I looked to the Draw widget as an example.  The widget uses 'jimu/dijit/DrawBox'.   I can not find documentation for this dijit in the API reference.

Does anyone know if there is additional API documentation?

Thank you

-Marcus Harner

Tags (1)
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Marcus,

  That eror just means that you have a dijit/widget in your widgets template that you have not defined in your Widget.js file. If you attach your Widget.html I can take a look for you.

View solution in original post

0 Kudos
11 Replies
RobertScheitlin__GISP
MVP Emeritus

Marcus,

  There is no documentation for most of the internal jimu dijits. The DrawBox is a very simple dijit as far as exposed methods and properties. If you look at the Draw widget or or custom widgets like the eSearch you will see that using the DrawBox is not hard at all. Let me know if you have any specific questions.

MarcusHarner
Regular Contributor

Hello Robert,

Specifically, and trying to follow the example of the Draw widget:

To Widget.html, I add the div

div data-dojo-attach-point="drawBox" data-dojo-type="jimu/dijit/DrawBox" data-dojo-props='types:["point","polyline","polygon"],showClear:false' style="margin-top:5px;"></div>

To Widget.js I add
'jimu/dijit/DrawBox' reference in define([],

In the postCreate are simply these lines:

this.inherited(arguments);

this.drawBox.setMap(this.map);

When I test it in Chrome, it breaks with this error

"TypeError: this.drawBox.setMap is not a function(…) "TypeError: this.drawBox.setMap is not a function..."

Is there a way to see the exposed methods and properties?  Coming from Silverlight, and without documentation WAB widget development is at least an order of magnitude slower I am finding.

Thanks for any insight!  

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Marcus,

To Widget.js I add

'jimu/dijit/DrawBox' reference in define([],

Did you also add the DrawBox parameter to the defines parameters list. In the AMD word you have defines and then each define has a parameter that coincides with it.

0 Kudos
MarcusHarner
Regular Contributor

Hello Robert,

I only added 'jimu/dijit/DrawBox' into define([],

The Draw widget that I ma using for an example does not have a corresponding 'DrawBox' in  function().

It is like

define([...'jimu/dijit/DrawBox',...

],

fuction(...){

...});

where '...' is text that is not seemling related to the DrawBox

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Marcus,

  You are correct. If you are not creating the dijit in code then you do not need the matching parameter in your JS file.

Can I see your whole Widget.js to see if there is some other issue?

0 Kudos
MarcusHarner
Regular Contributor

Hi Robert,

Surely!

I attached the Widget.js file as Widget.txt.

In Widget.html I have this div

<div data-dojo-attach-point="drawBox" data-dojo-type="jimu/dijit/DrawBox" data-dojo-props='types:["point","polyline","polygon"],showClear:false' style="margin-top:5px;"></div>

That I think is references in the Widget.js from the Draw widget example.

The Widget is doing much more than just drawing, so there is a plethora of unreferenced functions still to be populated.

The postCreate: seems to be where it is failing.

Any ideas would be greatly appreciated.

-Marcus

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Marcus,

So you had a couple of issues, the main one was you did not have jimu/BaseWidget in your requires but it was in your declare array, and you did not have _WidgetsInTemplateMixin in your declare array. Also you should always have 'dojo/_base/declare', 'dijit/_WidgetsInTemplateMixin', 'jimu/BaseWidget' as the very first items in your define/require array. I had to make up some of the other files that you did not provide (so I had to guess as some of this), but here is your widget at least displaying in WAB.

0 Kudos
MarcusHarner
Regular Contributor

Thanks so much for your help Robert!

I revised my Widget.js with your revisions.

Now I get the message:

"Error: dijit._WidgetsInTemplateMixin: parser returned unfilled promise (probably waiting for module auto-load), unsupported by _WidgetsInTemplateMixin.   Must pre-load all supporting widgets before instantiation."

I can not find any documentation about this issue either.  It is a small simple app that I am porting over.  It might be faster to just write it from scratch.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Marcus,

  That eror just means that you have a dijit/widget in your widgets template that you have not defined in your Widget.js file. If you attach your Widget.html I can take a look for you.

0 Kudos