gmahase

GeometryService Project

Discussion created by gmahase on May 28, 2010
Latest reply on May 28, 2010 by gmahase
I'm trying to do a basic sample of using the Geometry Service Project method, and I can't seem to get it working.  I know I'm probably just doing something stupid and can't spot it.  I've loaded the map and that's all working, I'll just post the code for the project.

            dojo.require("esri.map");

            function onProjectComplete(graphics)
            {
                console.log(graphics);            
            }
            
            function onError()
            {
                console.log("Error");
            }
            
            function doStuff()
            {
                console.log("dostuff");                
                var geoservice = new esri.tasks.GeometryService("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");
                var sourcewkid = new esri.SpatialReference({ "wkid": 2263 });
                var destwkid = new esri.SpatialReference({ "wkid": 4326 });
                var point = new esri.geometry.Point(975762, 171410, sourcewkid);
                console.log(sourcewkid, destwkid, point);
                try
                {
                    geoservice.project([point], destwkid, onProjectComplete, onError);
                }
                catch(err)
                {
                    console.log(err);
                }
                var infoTemplate = new esri.InfoTemplate("Test","test: ${test}");
                var attr = {"test":"test"};
                var sms = new esri.symbol.SimpleMarkerSymbol().setStyle(
                             esri.symbol.SimpleMarkerSymbol.STYLE_SQUARE).setColor(
                             new dojo.Color([255,0,0,0.5]));
                var test = new esri.Graphic(point, sms, attr, infoTemplate);
                map.graphics.add(test);
            }


I keep getting an error saying "TypeError: Cannot read property 'spatialReference' of undefined" in chrome.  And an error in Firefox firebug ""_63f[0].geometry is undefined".

Outcomes