initDraw: function() { this._tb = new Draw(this.map); // I DRAW A POLYGON this._tb.activate(Draw.POLYGON); this._tb.on("draw-end", lang.hitch(this, this.addToMap)); }, addToMap: function(evt) { // some stuff this._tb.deactivate(); var symbol = new SimpleFillSymbol(config.geometryStyles.geofencePolygon); // MY GEOMETRY == MY POLYGON var geometry = evt.geometry; var graphic = new Graphic(geometry, symbol); this.geofenceGraphicsLayer.add(graphic); // MY CHECK. Is always alerting, shouldn't do that. :( if (geometry.isSelfIntersecting) { alert("Is Self Intersecting"); } else { // do something... } },
{"type":"polygon","rings":[[[2343355.197916185,6843378.9380211625],[2343591.077808191,6843221.286650303],[2343284.7325307247,6843149.029771992],[2343355.197916185,6843378.9380211625]]],"_ring":0,"spatialReference":{"wkid":102100},"_centroid":null,"_extent":{"xmin":2343284.7325307247,"ymin":6843149.029771992,"xmax":2343591.077808191,"ymax":6843378.9380211625,"spatialReference":{"wkid":102100}},"_partwise":null}
Solved! Go to Solution.
var polygon = new esri.geometry.Polygon({"type":"polygon","rings":[[[2343355.197916185,6843378.9380211625],[2343591.077808191,6843221.286650303],[2343284.7325307247,6843149.029771992],[2343355.197916185,6843378.9380211625]]],"_ring":0,"spatialReference":{"wkid":102100},"_centroid":null,"_extent":{"xmin":2343284.7325307247,"ymin":6843149.029771992,"xmax":2343591.077808191,"ymax":6843378.9380211625,"spatialReference":{"wkid":102100}},"_partwise":null}); polygon.isSelfIntersecting();//returns false;
var polygon = new esri.geometry.Polygon({"type":"polygon","rings":[[[2343355.197916185,6843378.9380211625],[2343591.077808191,6843221.286650303],[2343284.7325307247,6843149.029771992],[2343355.197916185,6843378.9380211625]]],"_ring":0,"spatialReference":{"wkid":102100},"_centroid":null,"_extent":{"xmin":2343284.7325307247,"ymin":6843149.029771992,"xmax":2343591.077808191,"ymax":6843378.9380211625,"spatialReference":{"wkid":102100}},"_partwise":null}); polygon.isSelfIntersecting();//returns false;
I noticed you missed the parentheses at the end of the function isSelfIntersecting(), which means it checks if the function exists or not. If so, it returns the code of the function.