Select to view content in your preferred language

Cannot call method 'trim' of undefined when trying to draw a graphic on the map

1142
4
Jump to solution
03-13-2014 12:38 AM
ChristianDebono
Emerging Contributor
I am trying to add a free hand polygon to my map, but it is giving me the error "Cannot call method 'trim' of undefined". Have followed the samples but still no luck on getting it working. The code can be found below.

 function initSelectToolbar(event) {               selectionToolbar = new Draw(event.map);               var selectQuery = new Query();                on(selectionToolbar, "DrawEnd", function (geometry) {                   selectionToolbar.deactivate();                   selectQuery.geometry = geometry;                   featureLayer.selectFeatures(selectQuery,               FeatureLayer.SELECTION_NEW);                    var symbol;                   selectionToolbar.deactivate();                   map.showZoomSlider();                   symbol = new SimpleFillSymbol("none", new SimpleLineSymbol("dashdot", new Color([255, 0, 0]), 2), new Color([255, 255, 0, 0.25]));                   alert(geometry.type);                   var graphic = new Graphic(geometry, symbol);                   map.graphics.add(graphic);               });                         }


Thanks for the help.
0 Kudos
1 Solution

Accepted Solutions
JohnGravois
Deactivated User
i took the liberty of mashing up your own code with the original sample to show the tool getting invoked automatically when the page loads.  hope it helps

http://jsfiddle.net/jagravois/R83wR/

if not, please put together your own simplified sample.  i'd be happy to take a look.

View solution in original post

0 Kudos
4 Replies
JohnGravois
Deactivated User
hi Christian,

have you seen this sample?
0 Kudos
JohnGravois
Deactivated User
i took the liberty of mashing up your own code with the original sample to show the tool getting invoked automatically when the page loads.  hope it helps

http://jsfiddle.net/jagravois/R83wR/

if not, please put together your own simplified sample.  i'd be happy to take a look.
0 Kudos
ChristianDebono
Emerging Contributor
Thanks for your help, I looked at your code and it worked perfectly
0 Kudos
JohnGravois
Deactivated User
awesome Christian.  if you've got everything you need, please consider marking this thread as 'answered'
0 Kudos