Cannot read property 'type' of undefined

2037
2
04-08-2019 07:49 AM
puguheko
New Contributor

I have an undefined problem with geometry.type, where I use symbol points, polylines and polygons for drawings and then export them into shapefiles.

var symbol;
if ( evt.geometry.type === "point") {
symbol = new Graphic(evt.geometry);
this.pointGraphics.add(symbol);
symbol = this.markerSymbol;
} else if ( evt.geometry.type === "polyline") {
symbol = new Graphic(evt.geometry);
this.polylineGraphics.add(symbol);
symbol = this.lineSymbol;
} else if ( evt.geometry.type === "polygon") {
symbol = new Graphic(evt.geometry, null, {
ren: 1
});
this.polygonGraphics.add(symbol);
symbol = this.fillSymbol;
}

this.connectMapClick();
this.map.graphics.add(new Graphic(evt.geometry, symbol));

I use cmv.io and dojo.toolkit for the script.

Tags (4)
0 Kudos
2 Replies
TimMcGee1
Occasional Contributor III

It looks like you are creating a custom widget based on the Draw widget included with CMV. In order to assist troubleshooting your custom code, I recommend that you create a GitHub repo containing the complete custom widget along with an example configuration that demonstrates the issue.

Instead of developing your own export methods, you may want to consider implementing my Export widget https://github.com/tmcgee/cmv-widgets#export which will handle the export to shapefile along with numerous other spatial and non-spatial formats. Passing the desired features for export to that widget is just a few lines of custom code. If you post an issue about the Export widget within my cmv-widgets repo, I can assist you there.

0 Kudos
puguheko
New Contributor

thank you, i'll try to do that.

https://github.com/tmcgee/cmv-widgets/issues/207

I found the way in the form of ESRI, not converted into CMV:

https://github.com/aspetkov/cmv-widgets/tree/master/JS2Shapefile

0 Kudos