AnsweredAssumed Answered

Draw class' "draw.create('rectangle')" doesn't draw rectangle in ArcGIS JS lib v4.7 and above

Question asked by christian.schuetz_SAPHANAGCoE on Nov 12, 2018
Latest reply on Dec 14, 2018 by KGhime-esristaff

Hi everyone,

I have a problem with using the Draw class for drawing a rectangle on the map after changing the ArcGIS JS lib version from 4.6 to anything higher.

Attached there is a file called "Draw_recangle_working_lib_v4.6.html", which contains a slightly modified version of the code from the official example (ArcGIS API for JavaScript Sandbox ) for how to use the "Draw" class. There, using the lib version 4.6, the draw widget successfully is being used to draw a rectangle.

The second file, "Draw_recangle_notworking_lib_v4.7.html", contains the exact same code except for the ArcGIS JS lib version that is used - there, v4.7 is included. Instead of drawing a rectangle, a line is being drawn. This is true for any lib version higher than 4.6.

Unfortunately, I did not find any official example of how to use the Draw class for drawing a rectangle (instead of a "polygon"). I also only found that from 4.6 to 4.7, there was a breaking change being introduced regarding the Draw class where the graphic property was removed from the "draw-complete" event. However, this property is not explicitly being used in the attached code.

I don't encounter similar problems when using this class for drawing polygons or points.

So, my question is whether in order to use "draw.create('rectangle')", my code has to be adjusted since it is now supposed to work differently. One possibility would be to replace the Draw class with the SketchViewModel class but that would probably require larger effort than maybe adjusting the existing code a bit to make it work as expected again.

Best regards