<?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: GeometryService is not a constructor in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/geometryservice-is-not-a-constructor/m-p/1208469#M78534</link>
    <description>&lt;P&gt;Case sensitivity:&lt;/P&gt;&lt;P&gt;Your require statements shout be:&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;"esri/rest/&lt;FONT color="#3366FF"&gt;GeometryService&lt;/FONT&gt;",&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Not:&amp;nbsp; "esri/rest/&lt;FONT color="#FF0000"&gt;geometryService&lt;/FONT&gt;",&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 31 Aug 2022 21:53:10 GMT</pubDate>
    <dc:creator>NLA-ICTNLA-ICT</dc:creator>
    <dc:date>2022-08-31T21:53:10Z</dc:date>
    <item>
      <title>GeometryService is not a constructor</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/geometryservice-is-not-a-constructor/m-p/1208464#M78532</link>
      <description>&lt;P&gt;I am trying to create a graphic on the map and grab its Latitude and Longitude values.&amp;nbsp; To do so, I need to project from State Plane to WGS84 (wkid=4326).&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. When I try to create a new GeometryService, I get an error saying "GeometryService is not a constructor".&lt;/P&gt;&lt;P&gt;In my require statement, I'm using&lt;/P&gt;&lt;P&gt;"esri/rest/geometryService",&lt;BR /&gt;"esri/rest/support/ProjectParameters",&lt;/P&gt;&lt;P&gt;In my function statement, I'm using&amp;nbsp;&lt;/P&gt;&lt;P&gt;GeometryService,&lt;BR /&gt;ProjectParameters,&lt;/P&gt;&lt;P&gt;This is the line that causes the error&amp;nbsp;"GeometryService is not a constructor":&lt;/P&gt;&lt;P&gt;const myGeometryService = new GeometryService("&lt;A href="https://utility.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer" target="_blank"&gt;https://utility.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer&lt;/A&gt;");&lt;/P&gt;&lt;P&gt;2.&amp;nbsp; If I change my function statement to lower case g:&lt;/P&gt;&lt;P&gt;geometryService,&lt;BR /&gt;ProjectParameters,&lt;/P&gt;&lt;P&gt;This is the line that causes a different error "Identifier 'geometryService' has already been declared"&lt;/P&gt;&lt;P&gt;const myGeometryService = new geometryService("&lt;A href="https://utility.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer" target="_blank"&gt;https://utility.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer&lt;/A&gt;");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What am I doing wrong?&lt;/P&gt;&lt;P&gt;Note:&amp;nbsp; I've also tried URL&amp;nbsp;"&lt;A href="http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/Geometry/GeometryServer" target="_blank"&gt;http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/Geometry/GeometryServer&lt;/A&gt;"&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2022 21:39:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/geometryservice-is-not-a-constructor/m-p/1208464#M78532</guid>
      <dc:creator>LoriMcCormack1</dc:creator>
      <dc:date>2022-08-31T21:39:26Z</dc:date>
    </item>
    <item>
      <title>Re: GeometryService is not a constructor</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/geometryservice-is-not-a-constructor/m-p/1208468#M78533</link>
      <description>&lt;P&gt;It's not a class, so you don't create a new instance. It has methods that you just pass the url and options. The old Task based classes were removed at 4.24 after being deprecated for a few releases.&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-geometryService.html" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-geometryService.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;References:&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.esri.com/arcgis-blog/products/js-api-arcgis/developers/rest-is-up-to-the-task/" target="_blank"&gt;https://www.esri.com/arcgis-blog/products/js-api-arcgis/developers/rest-is-up-to-the-task/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/release-notes/#breaking-changes" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/release-notes/#breaking-changes&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2022 21:55:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/geometryservice-is-not-a-constructor/m-p/1208468#M78533</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2022-08-31T21:55:54Z</dc:date>
    </item>
    <item>
      <title>Re: GeometryService is not a constructor</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/geometryservice-is-not-a-constructor/m-p/1208469#M78534</link>
      <description>&lt;P&gt;Case sensitivity:&lt;/P&gt;&lt;P&gt;Your require statements shout be:&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;"esri/rest/&lt;FONT color="#3366FF"&gt;GeometryService&lt;/FONT&gt;",&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Not:&amp;nbsp; "esri/rest/&lt;FONT color="#FF0000"&gt;geometryService&lt;/FONT&gt;",&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2022 21:53:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/geometryservice-is-not-a-constructor/m-p/1208469#M78534</guid>
      <dc:creator>NLA-ICTNLA-ICT</dc:creator>
      <dc:date>2022-08-31T21:53:10Z</dc:date>
    </item>
    <item>
      <title>Re: GeometryService is not a constructor</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/geometryservice-is-not-a-constructor/m-p/1208487#M78536</link>
      <description>&lt;P&gt;1. The documentation shows the require statement as camelcase &lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="geometryServiceRequireFor424.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/50072i90438AEA302E0323/image-size/large?v=v2&amp;amp;px=999" role="button" title="geometryServiceRequireFor424.png" alt="geometryServiceRequireFor424.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;2. I realize that it changed in 4.19, but the example in the API reference (shown below) says I need the new GeometryService.&amp;nbsp; So, in the example below from the API Reference, the const geomSer = new GeometryService(...); is wrong? By removing the new GeometryService() statement, the error went away, as long as geometryService was set to camelcase.&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="geometryServiceProjectExample.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/50073i5CD1DB1959AB6517/image-size/large?v=v2&amp;amp;px=999" role="button" title="geometryServiceProjectExample.png" alt="geometryServiceProjectExample.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;3. How do I get "project" to be recognized?&amp;nbsp; Now I am getting an error with the code below, saying "ReferenceError:&amp;nbsp; project is not defined"&lt;/P&gt;&lt;LI-CODE lang="c"&gt;    const urlGeomServ = "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/Geometry/GeometryServer";
    view.when(() =&amp;gt; {
        view.on("click", function (event) {
            var outSR = new SpatialReference(4326);
            var geomSerParams = new ProjectParameters({
                geometries: [event.mapPoint],
                outSpatialReference: outSR
             });
             project(urlGeomServ, geomSerParams).then(function (projectedPoints) {
                 pt = projectedPoints[0];
                 ptLatitude = pt.y;
                 ptLongitude = pt.x;
                 createPointGraphic(ptLongitude, ptLatitude, "AddPost");
             });
         });
    });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2022 22:31:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/geometryservice-is-not-a-constructor/m-p/1208487#M78536</guid>
      <dc:creator>LoriMcCormack1</dc:creator>
      <dc:date>2022-08-31T22:31:33Z</dc:date>
    </item>
    <item>
      <title>Re: GeometryService is not a constructor</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/geometryservice-is-not-a-constructor/m-p/1208499#M78537</link>
      <description>&lt;P&gt;The snippet is incorrect and will be updated in next release.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;require([
  "esri/rest/geometryService",
  "esri/rest/support/ProjectParameters"
], function(geometryService, ProjectParameters) {
  const params = new ProjectParameters({
    geometries: [point],
    outSpatialReference: outSpatialReference,
    transformation: transformation
  });

  geometryService.project(url, params).then( ... );
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This can also be written as:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;import { project } from "@arcgis/core/rest/geometryService";
import ProjectParameters from "@arcgis/core/rest/support/ProjectParameters";

const params = new ProjectParameters({
  geometries: [point],
  outSpatialReference: outSpatialReference,
  transformation: transformation
});

project(url, params).then( ... );&lt;/LI-CODE&gt;&lt;P&gt;The snippet assumes you are using ESM, which should only import the project method.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Aug 2022 23:00:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/geometryservice-is-not-a-constructor/m-p/1208499#M78537</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2022-08-31T23:00:46Z</dc:date>
    </item>
    <item>
      <title>Re: GeometryService is not a constructor</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/geometryservice-is-not-a-constructor/m-p/1208518#M78539</link>
      <description>&lt;P&gt;Could you post your full require/function section? This can be caused by a mismatch between the require modules and the function arguments.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Sep 2022 00:20:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/geometryservice-is-not-a-constructor/m-p/1208518#M78539</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2022-09-01T00:20:19Z</dc:date>
    </item>
    <item>
      <title>Re: GeometryService is not a constructor</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/geometryservice-is-not-a-constructor/m-p/1208728#M78558</link>
      <description>&lt;P&gt;I was able to fix the code by simply adding "geometryService." in front of the "project" statement, as shown in the first snippet in ReneRubalcava's response above.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;require([
  "esri/rest/geometryService",
  "esri/rest/support/ProjectParameters"
], function(geometryService, ProjectParameters) {
const urlGeomServ = "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/Geometry/GeometryServer";
    view.when(() =&amp;gt; {
        view.on("click", function (event) {
            var outSR = new SpatialReference(4326);
            var geomSerParams = new ProjectParameters({
                geometries: [event.mapPoint],
                outSpatialReference: outSR
             });
             geometryService.project(urlGeomServ, geomSerParams).then(function (projectedPoints) {
                 pt = projectedPoints[0];
                 ptLatitude = pt.y;
                 ptLongitude = pt.x;
                 createPointGraphic(ptLongitude, ptLatitude, "AddPost");
             });
         });
    });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you all for responding so quickly to help me identify the problem.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've only used the import statements in python code, so I wasn't familiar with that usage in the ArcGIS API for JavaScript.&amp;nbsp; Great to know!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Sep 2022 15:03:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/geometryservice-is-not-a-constructor/m-p/1208728#M78558</guid>
      <dc:creator>LoriMcCormack1</dc:creator>
      <dc:date>2022-09-01T15:03:03Z</dc:date>
    </item>
  </channel>
</rss>

