<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Project function fails - Cannot read property 'spatialReference' of undefined in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/project-function-fails-cannot-read-property/m-p/579927#M54111</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am getting some weird results from params.outSR. I modified the outSR to include BOTH the wkid and wkt for good measure and then logged the result as follows:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;params.outSR = new esri.SpatialReference({wkid:102709,wkt:'PROJCS["NAD_1983_StatePlane_Nevada_West_FIPS_2703_Feet",GEOGCS["GCS_North_American_1983",DATUM["D_North_American_1983",SPHEROID["GRS_1980",6378137,298.257222101]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",2624666.666666666],PARAMETER["False_Northing",13123333.33333333],PARAMETER["Central_Meridian",-118.5833333333333],PARAMETER["Scale_Factor",0.9999],PARAMETER["Latitude_Of_Origin",34.75],UNIT["Foot_US",0.30480060960121924]]'});
console.log(params.outSR);&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is the log return that I get from this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Object {wkid: 102709, wkt: "PROJCS["NAD_1983_StatePlane_Nevada_West_FIPS_2703_�?�igin",34.75],UNIT["Foot_US",0.30480060960121924]]", wkid: null, wkt: null, _info: Object�?�}&lt;BR /&gt;wkid: 102709&lt;BR /&gt;wkt: "PROJCS["NAD_1983_StatePlane_Nevada_West_FIPS_2703_Feet",GEOGCS["GCS_North_American_1983",DATUM["D_North_American_1983",SPHEROID["GRS_1980",6378137,298.257222101]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",2624666.666666666],PARAMETER["False_Northing",13123333.33333333],PARAMETER["Central_Meridian",-118.5833333333333],PARAMETER["Scale_Factor",0.9999],PARAMETER["Latitude_Of_Origin",34.75],UNIT["Foot_US",0.30480060960121924]]"&lt;BR /&gt;__proto__: Object&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Notice that there are wkid and wkt values that are correctly populated, BUT then there are two more wkid and wkt values that are set to null. What gives? Maybe this is the spatial reference that is not being correctly populated, but why?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 00:56:27 GMT</pubDate>
    <dc:creator>MatthewLawton</dc:creator>
    <dc:date>2021-12-12T00:56:27Z</dc:date>
    <item>
      <title>Project function fails - Cannot read property 'spatialReference' of undefined</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/project-function-fails-cannot-read-property/m-p/579924#M54108</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This has been giving me fits. Why doesn't this work?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;function showCoordinatesNew(evt) {
 var mp = esri.geometry.webMercatorToGeographic(evt.mapPoint);
 console.log(mp.x+","+mp.y); //&amp;lt;-- returns correct geographic coordinates
 console.log(mp.spatialReference.wkid); //&amp;lt;-- returns wkid 4326
 var params = new esri.tasks.ProjectParameters();
 params.geometries = mp;
 //setting output Spatial Reference to Nevada State Plane West Zone NAD83
 params.outSR = new esri.SpatialReference({wkid: 102709});
 //execute project function, callback will be picked up by onProjectComplete
 gsvc.project(params); //&amp;lt;-- fails with Uncaught TypeError: Cannot read property 'spatialReference' of undefined
}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
function onProjectComplete(geometries) {
 //project function never gets this far.
 var mp = geometries[0];
 console.log("Returned Coordinates: " + mp.x + "," + mp.y);
 convertSP(mp.x,mp.y);
}

function onError(message) {
 alert(message);
}&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is the full error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Uncaught TypeError: Cannot read property 'spatialReference' of undefined serverapi.arcgisonline.com:34&lt;BR /&gt;dojo.declare.toJson serverapi.arcgisonline.com:34&lt;BR /&gt;dojo.declare.project serverapi.arcgisonline.com:34&lt;BR /&gt;showCoordinatesNew QuickMap32.js:192&lt;BR /&gt;_4ff.(anonymous function)._504 serverapi.arcgisonline.com:15&lt;BR /&gt;_599._fire serverapi.arcgisonline.com:34&lt;BR /&gt;_599._onMouseMoveHandler serverapi.arcgisonline.com:34&lt;BR /&gt;(anonymous function)&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:56:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/project-function-fails-cannot-read-property/m-p/579924#M54108</guid>
      <dc:creator>MatthewLawton</dc:creator>
      <dc:date>2021-12-12T00:56:25Z</dc:date>
    </item>
    <item>
      <title>Re: Project function fails - Cannot read property 'spatialReference' of undefined</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/project-function-fails-cannot-read-property/m-p/579925#M54109</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It's expecting an array of geometries; try this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;params.geometries = [mp];&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Mar 2013 15:02:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/project-function-fails-cannot-read-property/m-p/579925#M54109</guid>
      <dc:creator>JohnGrayson</dc:creator>
      <dc:date>2013-03-06T15:02:26Z</dc:date>
    </item>
    <item>
      <title>Re: Project function fails - Cannot read property 'spatialReference' of undefined</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/project-function-fails-cannot-read-property/m-p/579926#M54110</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Your result, sir:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Error {code: 400, message: "JSON syntax error", details: Array[1], log: undefined, _ssl: undefined}&lt;BR /&gt;_ssl: undefined&lt;BR /&gt;code: 400&lt;BR /&gt;details: Array[1]&lt;BR /&gt;get stack: function () { [native code] }&lt;BR /&gt;log: undefined&lt;BR /&gt;message: "JSON syntax error"&lt;BR /&gt;set stack: function () { [native code] }&lt;BR /&gt;__proto__: d&lt;BR /&gt; serverapi.arcgisonline.com:15&lt;BR /&gt;(anonymous function) serverapi.arcgisonline.com:15&lt;BR /&gt;reject.errback serverapi.arcgisonline.com:15&lt;BR /&gt;dojo.declare._errorHandler serverapi.arcgisonline.com:34&lt;BR /&gt;(anonymous function) serverapi.arcgisonline.com:15&lt;BR /&gt;dfd._pendingDfd.esri.request.error serverapi.arcgisonline.com:34&lt;BR /&gt;(anonymous function) serverapi.arcgisonline.com:34&lt;BR /&gt;_1c6 serverapi.arcgisonline.com:15&lt;BR /&gt;_1c4 serverapi.arcgisonline.com:15&lt;BR /&gt;reject.errback serverapi.arcgisonline.com:15&lt;BR /&gt;_1c6 serverapi.arcgisonline.com:15&lt;BR /&gt;_1c4 serverapi.arcgisonline.com:15&lt;BR /&gt;reject.errback serverapi.arcgisonline.com:15&lt;BR /&gt;_1c6 serverapi.arcgisonline.com:15&lt;BR /&gt;_1c4 serverapi.arcgisonline.com:15&lt;BR /&gt;reject.errback serverapi.arcgisonline.com:15&lt;BR /&gt;(anonymous function) serverapi.arcgisonline.com:34&lt;BR /&gt;_1c6 serverapi.arcgisonline.com:15&lt;BR /&gt;_1c4 serverapi.arcgisonline.com:15&lt;BR /&gt;reject.errback serverapi.arcgisonline.com:15&lt;BR /&gt;_1c6 serverapi.arcgisonline.com:15&lt;BR /&gt;_1c4 serverapi.arcgisonline.com:15&lt;BR /&gt;resolve.callback serverapi.arcgisonline.com:15&lt;BR /&gt;_1c6 serverapi.arcgisonline.com:15&lt;BR /&gt;_1c4 serverapi.arcgisonline.com:15&lt;BR /&gt;resolve.callback serverapi.arcgisonline.com:15&lt;BR /&gt;_1c6 serverapi.arcgisonline.com:15&lt;BR /&gt;_1c4 serverapi.arcgisonline.com:15&lt;BR /&gt;resolve.callback serverapi.arcgisonline.com:15&lt;BR /&gt;_1c6 serverapi.arcgisonline.com:15&lt;BR /&gt;_1c4 serverapi.arcgisonline.com:15&lt;BR /&gt;resolve.callback serverapi.arcgisonline.com:15&lt;BR /&gt;_437 serverapi.arcgisonline.com:15&lt;BR /&gt;func serverapi.arcgisonline.com:15&lt;BR /&gt;_430&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Mar 2013 15:13:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/project-function-fails-cannot-read-property/m-p/579926#M54110</guid>
      <dc:creator>MatthewLawton</dc:creator>
      <dc:date>2013-03-06T15:13:03Z</dc:date>
    </item>
    <item>
      <title>Re: Project function fails - Cannot read property 'spatialReference' of undefined</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/project-function-fails-cannot-read-property/m-p/579927#M54111</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am getting some weird results from params.outSR. I modified the outSR to include BOTH the wkid and wkt for good measure and then logged the result as follows:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;params.outSR = new esri.SpatialReference({wkid:102709,wkt:'PROJCS["NAD_1983_StatePlane_Nevada_West_FIPS_2703_Feet",GEOGCS["GCS_North_American_1983",DATUM["D_North_American_1983",SPHEROID["GRS_1980",6378137,298.257222101]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",2624666.666666666],PARAMETER["False_Northing",13123333.33333333],PARAMETER["Central_Meridian",-118.5833333333333],PARAMETER["Scale_Factor",0.9999],PARAMETER["Latitude_Of_Origin",34.75],UNIT["Foot_US",0.30480060960121924]]'});
console.log(params.outSR);&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is the log return that I get from this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Object {wkid: 102709, wkt: "PROJCS["NAD_1983_StatePlane_Nevada_West_FIPS_2703_�?�igin",34.75],UNIT["Foot_US",0.30480060960121924]]", wkid: null, wkt: null, _info: Object�?�}&lt;BR /&gt;wkid: 102709&lt;BR /&gt;wkt: "PROJCS["NAD_1983_StatePlane_Nevada_West_FIPS_2703_Feet",GEOGCS["GCS_North_American_1983",DATUM["D_North_American_1983",SPHEROID["GRS_1980",6378137,298.257222101]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",2624666.666666666],PARAMETER["False_Northing",13123333.33333333],PARAMETER["Central_Meridian",-118.5833333333333],PARAMETER["Scale_Factor",0.9999],PARAMETER["Latitude_Of_Origin",34.75],UNIT["Foot_US",0.30480060960121924]]"&lt;BR /&gt;__proto__: Object&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Notice that there are wkid and wkt values that are correctly populated, BUT then there are two more wkid and wkt values that are set to null. What gives? Maybe this is the spatial reference that is not being correctly populated, but why?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:56:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/project-function-fails-cannot-read-property/m-p/579927#M54111</guid>
      <dc:creator>MatthewLawton</dc:creator>
      <dc:date>2021-12-12T00:56:27Z</dc:date>
    </item>
    <item>
      <title>Re: Project function fails - Cannot read property 'spatialReference' of undefined</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/project-function-fails-cannot-read-property/m-p/579928#M54112</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;So I created a very simple app with the same project function as above, except I stored it directly in the script tag in the html file instead of referencing to an external js file, and it works. But if I reference the exact same code in an external js file then it errors on the project output.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Mar 2013 19:45:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/project-function-fails-cannot-read-property/m-p/579928#M54112</guid>
      <dc:creator>MatthewLawton</dc:creator>
      <dc:date>2013-03-06T19:45:15Z</dc:date>
    </item>
    <item>
      <title>Re: Project function fails - Cannot read property 'spatialReference' of undefined</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/project-function-fails-cannot-read-property/m-p/579929#M54113</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;After hours of combing through all of my code, I finally isolated the problem. I use the Prototype framework to run a pull-down list in my application. Apparently the reference to that framework was conflicting with the project function. I don't know what the conflict is, but that is what is causing all of my problems.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Mar 2013 21:33:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/project-function-fails-cannot-read-property/m-p/579929#M54113</guid>
      <dc:creator>MatthewLawton</dc:creator>
      <dc:date>2013-03-06T21:33:26Z</dc:date>
    </item>
  </channel>
</rss>

