<?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 geolocation coords to State Plane in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/project-geolocation-coords-to-state-plane/m-p/409314#M37695</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Which JSAPI version are you using?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is the excerpt of the api source for project method:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;project : function(_1e, _1f, _20, _21) {&amp;nbsp; var _22 = _2.mixin({}, this._url.query, { &amp;nbsp; f : "json"&amp;nbsp; }), _23; ...&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;SPAN&gt;From the source, the error message means this._url is not defined. Check the code where geometryService is defined, making sure the correct url is fed into the constructor.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 26 Aug 2013 20:07:37 GMT</pubDate>
    <dc:creator>JasonZou</dc:creator>
    <dc:date>2013-08-26T20:07:37Z</dc:date>
    <item>
      <title>Project geolocation coords to State Plane</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/project-geolocation-coords-to-state-plane/m-p/409311#M37692</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a State Plane-based map to which I'd like to add a point (WGS84) for the user's location. This is my code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;if (navigator.geolocation) {&amp;nbsp; navigator.geolocation.getCurrentPosition(function(location) { &amp;nbsp; gpsPoint.setLatitude(location.coords.latitude); &amp;nbsp; gpsPoint.setLongitude(location.coords.longitude); &amp;nbsp;&amp;nbsp; &amp;nbsp; gpsGraphic.setGeometry(gpsPoint); &amp;nbsp; gpsGraphic.setSymbol(gpsSymbol);&amp;nbsp; &amp;nbsp; map.graphics.add(gpsGraphic); &amp;nbsp; map.centerAndZoom(gpsPoint, 12);&amp;nbsp; &amp;nbsp; gpsIsOn = true; &amp;nbsp; }); }&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So far I'm getting the error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Map: Geometry (wkid: 4326) cannot be converted to spatial reference of the map (wkid: 2229)&lt;BR /&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Specifically it's the centerAndZoom call that is throwing the error. I found &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://forums.arcgis.com/threads/75993-Map-Geometry-cannot-be-converted" rel="nofollow" target="_blank"&gt;this &lt;/A&gt;&lt;SPAN&gt;post which suggested using a geometry service to reproject the point:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;// Project gpsPoint to State Plane var projectParams = new esri.tasks.ProjectParameters(); projectParams.geometries = [gpsPoint]; projectParams.outSR = map.spatialReference;&amp;nbsp; var defer = geometryService.project(projectParams); dojo.when(&amp;nbsp; defer,&amp;nbsp; function(projectedGeometry) { &amp;nbsp; if (projectedGeometry.length &amp;gt; 0) { &amp;nbsp;&amp;nbsp; gpsPoint = projectedGeometry[0]; &amp;nbsp; }&amp;nbsp; });&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But that gives the error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Uncaught TypeError: Cannot read property 'query' of undefined &lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;No idea where that's coming from! I've checked the projectParams object and both the geometry and outSR look fine. Can anyone tell what I'm doing wrong here, or what a better method might be?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Many thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Aug 2013 16:01:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/project-geolocation-coords-to-state-plane/m-p/409311#M37692</guid>
      <dc:creator>RobertMartin2</dc:creator>
      <dc:date>2013-08-26T16:01:41Z</dc:date>
    </item>
    <item>
      <title>Re: Project geolocation coords to State Plane</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/project-geolocation-coords-to-state-plane/m-p/409312#M37693</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I would reproject the gpsPoint after set its lat/lon. The code will look like this.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;if (navigator.geolocation) {
 navigator.geolocation.getCurrentPosition(function(location) {
&amp;nbsp; gpsPoint.setLatitude(location.coords.latitude);
&amp;nbsp; gpsPoint.setLongitude(location.coords.longitude);
&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; projectToMapCoords(gpsPoint);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });
}

function projectToMapCoords(gpsPoint) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; // Project gpsPoint to State Plane
&amp;nbsp;&amp;nbsp;&amp;nbsp; var projectParams = new esri.tasks.ProjectParameters();
&amp;nbsp;&amp;nbsp;&amp;nbsp; projectParams.geometries = [gpsPoint];
&amp;nbsp;&amp;nbsp;&amp;nbsp; projectParams.outSR = map.spatialReference;

&amp;nbsp;&amp;nbsp;&amp;nbsp; geometryService.project(projectParams, projectCallback);
}

function projectCallback(projectParams) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var newPoint;

 if (projectParams.length &amp;gt; 0) {
&amp;nbsp; newPoint= projectParams[0];
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gpsGraphic.setGeometry(newPoint);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gpsGraphic.setSymbol(gpsSymbol);

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map.graphics.add(gpsGraphic);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map.centerAndZoom(newPoint, 12);

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gpsIsOn = true; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
}&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The code assumes that map, gpsPoint, geometryService, gpsSymbol, and gpsIsOn are global variables. If not, change the code accordingly to apply the variable scope.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 18:36:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/project-geolocation-coords-to-state-plane/m-p/409312#M37693</guid>
      <dc:creator>JasonZou</dc:creator>
      <dc:date>2021-12-11T18:36:24Z</dc:date>
    </item>
    <item>
      <title>Re: Project geolocation coords to State Plane</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/project-geolocation-coords-to-state-plane/m-p/409313#M37694</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the tip Jason, I dropped your code in but I'm still getting "Cannot read property 'query' of undefined" when it calls geometryService.project. I can't figure out for the life of me why there's a query here... I do have a couple of query tasks initiated but I'm not using them here. And yes, all the variables are globals so they should be visible throughout.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Aug 2013 19:47:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/project-geolocation-coords-to-state-plane/m-p/409313#M37694</guid>
      <dc:creator>RobertMartin2</dc:creator>
      <dc:date>2013-08-26T19:47:34Z</dc:date>
    </item>
    <item>
      <title>Re: Project geolocation coords to State Plane</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/project-geolocation-coords-to-state-plane/m-p/409314#M37695</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Which JSAPI version are you using?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is the excerpt of the api source for project method:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;project : function(_1e, _1f, _20, _21) {&amp;nbsp; var _22 = _2.mixin({}, this._url.query, { &amp;nbsp; f : "json"&amp;nbsp; }), _23; ...&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;SPAN&gt;From the source, the error message means this._url is not defined. Check the code where geometryService is defined, making sure the correct url is fed into the constructor.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Aug 2013 20:07:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/project-geolocation-coords-to-state-plane/m-p/409314#M37695</guid>
      <dc:creator>JasonZou</dc:creator>
      <dc:date>2013-08-26T20:07:37Z</dc:date>
    </item>
    <item>
      <title>Re: Project geolocation coords to State Plane</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/project-geolocation-coords-to-state-plane/m-p/409315#M37696</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Well this is embarrassing... I thought GeometryService was a utility class that would do the projection locally. Now I see it wants a URL, so I tried the ArcGIS Online one and it works! Thanks for the snippet Jason, that was a big help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm still wondering though, is this really the only way to add geometry with a different spatial reference? Seems like a lot of overhead for something so simple...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Aug 2013 20:41:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/project-geolocation-coords-to-state-plane/m-p/409315#M37696</guid>
      <dc:creator>RobertMartin2</dc:creator>
      <dc:date>2013-08-26T20:41:58Z</dc:date>
    </item>
    <item>
      <title>Re: Project geolocation coords to State Plane</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/project-geolocation-coords-to-state-plane/m-p/409316#M37697</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;To be able to overlay a graphic onto a map with different spatial reference correctly, reproject has to be done. Either JASPI can take care of it for us, or else we have to handle that ourselves. To figure out whether JSAPI takes the responsibility, the best way is to look at the source. We can also try it out though.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But nevertheless, I do agree that since map and the graphic to be added both have the spatial reference provided, it will be better for the JSAPI to take care of the reproject for us.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Aug 2013 20:49:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/project-geolocation-coords-to-state-plane/m-p/409316#M37697</guid>
      <dc:creator>JasonZou</dc:creator>
      <dc:date>2013-08-26T20:49:55Z</dc:date>
    </item>
  </channel>
</rss>

