How do I programmatically create freehand polylines?

1095
2
Jump to solution
09-24-2013 05:58 AM
MStayner
New Contributor III
How do I programmatically create freehand polylines?

I tried following what was done in this thread.

Here is my code:

var templatePicker = new esri.dijit.editing.TemplatePicker({           featureLayers: templateLayers,           rows: 'auto',           columns: 'auto',           style:'height:98%;width:98%;'         },'templatePickerDiv');                  templatePicker.startup();         var settings = {           templatePicker: templatePicker,           map: map,           layerInfos:layers,           toolbarVisible: false,           createOptions: {             polygonDrawTools:[esri.dijit.editing.Editor.CREATE_TOOL_FREEHAND_POLYGON],            polylineDrawTools:[esri.dijit.editing.Editor.CREATE_TOOL_FREEHAND_POLYLINE]             }         }            on(templatePicker, "SelectionChange", function() {    selectedTemplate = templatePicker.getSelected();    if (selectedTemplate) {     switch (selectedTemplate.featureLayer.geometryType) {      case "esriGeometryPoint":      alert("point");       drawToolbar.activate(esri.toolbars.Draw.POINT);       break;      case "esriGeometryPolyline":       alert("line");       selectedTemplate.template.drawingTool === 'esriFeatureEditToolFreehand';       break;      case "esriGeometryPolygon":       selectedTemplate.template.drawingTool === 'esriFeatureEditToolFreehand' ? drawToolbar.activate(esri.toolbars.Draw.FREEHAND_POLYGON) : drawToolbar.activate(esri.toolbars.Draw.POLYGON);       break;     }    }   }); 


The alert fires, which tells me I'm getting to the right place, but the line still uses the traditional draw.

This example is supposed to draw freehand, but it doesn't work for me either.  Does it work for you?
0 Kudos
1 Solution

Accepted Solutions
BenFousek
Occasional Contributor III
I think you have too many equal signs. 3 === is the match type and value operator. You're trying to set the drawing tool to a value.

Try:
selectedTemplate.template.drawingTool = 'esriFeatureEditToolFreehand';

View solution in original post

0 Kudos
2 Replies
BenFousek
Occasional Contributor III
I think you have too many equal signs. 3 === is the match type and value operator. You're trying to set the drawing tool to a value.

Try:
selectedTemplate.template.drawingTool = 'esriFeatureEditToolFreehand';
0 Kudos
MStayner
New Contributor III
Thanks Ben!  That did the trick. 

I copied that code from the Esri example.  I wonder why there are three ='s in that example.  Maybe that is why it doesn't work in that example.  Either way, you helped me. 

Thanks again!
0 Kudos