<?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: Geometry Server projection error in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/geometry-server-projection-error/m-p/338833#M31368</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Apparently it is the return.&amp;nbsp; I altered it slightly to set a global variable to projectedPoints[0], and then used that global to extract the xy to use in constructing the url.&amp;nbsp; I have it working now.&amp;nbsp; Thanks for pointing me in the right direction.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Final code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;function projectToLatLong(evt) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; gsvc = new esri.tasks.GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");

&amp;nbsp;&amp;nbsp;&amp;nbsp; var outSR = new esri.SpatialReference({ wkid: 4326 });
&amp;nbsp;&amp;nbsp;&amp;nbsp; pt = evt.mapPoint;
&amp;nbsp;&amp;nbsp;&amp;nbsp; gsvc.project([pt], outSR, function (projectedPoints) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newPt = projectedPoints[0];
&amp;nbsp;&amp;nbsp;&amp;nbsp; }, function (e) { console.log(e.message); });
}&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 16:01:58 GMT</pubDate>
    <dc:creator>ShawnHolyoak</dc:creator>
    <dc:date>2021-12-11T16:01:58Z</dc:date>
    <item>
      <title>Geometry Server projection error</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/geometry-server-projection-error/m-p/338830#M31365</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It seems really simple, yet I keep getting an error when trying to project a point.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;function projectToLatLong(evt) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; gsvc = new esri.tasks.GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");

&amp;nbsp;&amp;nbsp;&amp;nbsp; var outSR = new esri.SpatialReference({ wkid: 4326 });
&amp;nbsp;&amp;nbsp;&amp;nbsp; pt = evt.mapPoint;
&amp;nbsp;&amp;nbsp;&amp;nbsp; gsvc.project([pt], outSR, function (projectedPoints) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return projectedPoints[0];
&amp;nbsp;&amp;nbsp;&amp;nbsp; }, function (e) { console.log(e.message); });
}&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;pt is a valid esri.geometry.Point, in the 2276 spatial reference.&amp;nbsp; The error I get is "projectedPoints is not defined".&amp;nbsp; I've tried it with my own internal geometry service, and ESRI's, and I always get the same error.&amp;nbsp; I've tried using the web based REST api for each of those two services, and both project the geometry properly.&amp;nbsp; My error callback doesn't write anything to the console either.&amp;nbsp; What's going on?&amp;nbsp; Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Apr 2012 17:48:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/geometry-server-projection-error/m-p/338830#M31365</guid>
      <dc:creator>ShawnHolyoak</dc:creator>
      <dc:date>2012-04-10T17:48:40Z</dc:date>
    </item>
    <item>
      <title>Re: Geometry Server projection error</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/geometry-server-projection-error/m-p/338831#M31366</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Why are you using return instead of directly doing something with your projectedPoints array?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Apr 2012 18:07:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/geometry-server-projection-error/m-p/338831#M31366</guid>
      <dc:creator>derekswingley1</dc:creator>
      <dc:date>2012-04-10T18:07:13Z</dc:date>
    </item>
    <item>
      <title>Re: Geometry Server projection error</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/geometry-server-projection-error/m-p/338832#M31367</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I need to construct a URL to open a new window.&amp;nbsp; I suppose I could do it within the function, but I don't think that will make any difference, as I don't even get into the function.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Apr 2012 18:08:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/geometry-server-projection-error/m-p/338832#M31367</guid>
      <dc:creator>ShawnHolyoak</dc:creator>
      <dc:date>2012-04-10T18:08:43Z</dc:date>
    </item>
    <item>
      <title>Re: Geometry Server projection error</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/geometry-server-projection-error/m-p/338833#M31368</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Apparently it is the return.&amp;nbsp; I altered it slightly to set a global variable to projectedPoints[0], and then used that global to extract the xy to use in constructing the url.&amp;nbsp; I have it working now.&amp;nbsp; Thanks for pointing me in the right direction.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Final code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;function projectToLatLong(evt) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; gsvc = new esri.tasks.GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");

&amp;nbsp;&amp;nbsp;&amp;nbsp; var outSR = new esri.SpatialReference({ wkid: 4326 });
&amp;nbsp;&amp;nbsp;&amp;nbsp; pt = evt.mapPoint;
&amp;nbsp;&amp;nbsp;&amp;nbsp; gsvc.project([pt], outSR, function (projectedPoints) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newPt = projectedPoints[0];
&amp;nbsp;&amp;nbsp;&amp;nbsp; }, function (e) { console.log(e.message); });
}&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:01:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/geometry-server-projection-error/m-p/338833#M31368</guid>
      <dc:creator>ShawnHolyoak</dc:creator>
      <dc:date>2021-12-11T16:01:58Z</dc:date>
    </item>
    <item>
      <title>Re: Geometry Server projection error</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/geometry-server-projection-error/m-p/338834#M31369</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;OK, I've got it close, but the deferred aspect is messing things up.&amp;nbsp; What I'm trying to do, big picture, is open Google street view at the location the user clicks.&amp;nbsp; The problem is now, that the deferred finishes after the new window is opened with an invalid url.&amp;nbsp; The second time the user clicks, the url is now valid (but with the location of the first click!) and street view opens fine.&amp;nbsp; If I put svurl and the window.open call inside the deferred, the url is constructed properly, but the window now opens in a new window (it's treated as a pop-up by webkit, and I have to specifically allow my site to open pop-ups), not a new tab, whereas if I put the window.open call outside of the deferred, it opens in a new tab, and is NOT treated as a pop-up.&amp;nbsp; Is there a better way?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;function openStreetView(evt) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; //convert the point&amp;nbsp;&amp;nbsp;&amp;nbsp; //make sure we have a geometry server
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (gsvc === null) initializeProjection();

&amp;nbsp;&amp;nbsp;&amp;nbsp; var outSR = new esri.SpatialReference({ wkid: 4326 });
&amp;nbsp;&amp;nbsp;&amp;nbsp; pt = evt.mapPoint;
&amp;nbsp;&amp;nbsp;&amp;nbsp; gsvc.project([pt], outSR, function (projectedPoints) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newPt = projectedPoints[0];
&amp;nbsp;&amp;nbsp;&amp;nbsp; }, function (e) { console.log(e.message); });

&amp;nbsp;&amp;nbsp;&amp;nbsp; //create the URL
&amp;nbsp;&amp;nbsp;&amp;nbsp; var svurl = "http://maps.google.com/maps?ll=" + newPt.y + "," + newPt.x + "&amp;amp;t=w&amp;amp;z=19&amp;amp;layer=c&amp;amp;cbll=" + newPt.y + "," + newPt.x + "&amp;amp;cbp=13,-85.37630595889367,,0,2.062648062470899";

&amp;nbsp;&amp;nbsp;&amp;nbsp; //open the window
&amp;nbsp;&amp;nbsp;&amp;nbsp; window.open(svurl, "_blank");
}&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:02:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/geometry-server-projection-error/m-p/338834#M31369</guid>
      <dc:creator>ShawnHolyoak</dc:creator>
      <dc:date>2021-12-11T16:02:01Z</dc:date>
    </item>
    <item>
      <title>Re: Geometry Server projection error</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/geometry-server-projection-error/m-p/338835#M31370</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Shawn, not sure if you're still working on this.&amp;nbsp; I implemented Dual Maps in my app for this functionality.&amp;nbsp; Obviously the code is handled by Dual Maps so there's no customising it but it's a quick way to get StreetView into an AGS JavaScript app.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Apr 2012 02:31:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/geometry-server-projection-error/m-p/338835#M31370</guid>
      <dc:creator>EdSaunders</dc:creator>
      <dc:date>2012-04-13T02:31:36Z</dc:date>
    </item>
    <item>
      <title>Re: Geometry Server projection error</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/geometry-server-projection-error/m-p/338836#M31371</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I wasn't aware of Dual Maps.&amp;nbsp; I'll take a good look at it.&amp;nbsp; Thanks for the tip.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Apr 2012 13:10:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/geometry-server-projection-error/m-p/338836#M31371</guid>
      <dc:creator>ShawnHolyoak</dc:creator>
      <dc:date>2012-04-13T13:10:40Z</dc:date>
    </item>
    <item>
      <title>Re: Geometry Server projection error</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/geometry-server-projection-error/m-p/338837#M31372</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;sholyoak,&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; As Derek tries to point out, the call to 'project' is asynchronous which means your inline function that handles the projected geometries will not runs until after you get a reply from the server.&amp;nbsp; On the other hand, the code right after your call to 'project' runs immediately after making the call, which means you're trying to use a variable (newPt) that hasn't been set yet.&amp;nbsp; Try this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
function openStreetView(evt) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; //convert the point&amp;nbsp;&amp;nbsp;&amp;nbsp; //make sure we have a geometry server
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (gsvc === null) initializeProjection();

&amp;nbsp;&amp;nbsp;&amp;nbsp; var outSR = new esri.SpatialReference({ wkid: 4326 });
&amp;nbsp;&amp;nbsp;&amp;nbsp; pt = evt.mapPoint;
&amp;nbsp;&amp;nbsp;&amp;nbsp; gsvc.project([pt], outSR, function (projectedPoints) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newPt = projectedPoints[0];&amp;nbsp;&amp;nbsp;&amp;nbsp; 

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // WAIT FOR SERVER RESPONSE AND THEN DO SOMETHING WITH newPt HERE...

&amp;nbsp;&amp;nbsp;&amp;nbsp; }, function (e) { console.log(e.message); });

&amp;nbsp;&amp;nbsp;&amp;nbsp; // CODE HERE RUNS IMMEDIATELY AFTER CALLING PROJECT BUT RESPONSE FROM SERVER MAY NOT HAVE HAPPENED YET...

}&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:02:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/geometry-server-projection-error/m-p/338837#M31372</guid>
      <dc:creator>JohnGrayson</dc:creator>
      <dc:date>2021-12-11T16:02:04Z</dc:date>
    </item>
    <item>
      <title>Re: Geometry Server projection error</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/geometry-server-projection-error/m-p/338838#M31373</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Right. As I mentioned in my post on April 10, I figured out that was the underlying problem. The problem now is, as I explained in that post, by opening the window within the callback once I get the response from the server, I get inconsistent and undesired behavior from the call. I don't understand why opening the window from the callback results in different behavior than opening it directly as a result of the click event.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt; sholyoak,&amp;nbsp;&amp;nbsp; &lt;BR /&gt; As Derek tries to point out, the call to 'project' is asynchronous which means your inline function that handles the projected geometries will not runs until after you get a reply from the server. On the other hand, the code right after your call to 'project' runs immediately after making the call, which means you're trying to use a variable (newPt) that hasn't been set yet. Try this:&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt; &lt;PRE class="lia-code-sample line-numbers language-none"&gt;
function openStreetView(evt) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; //convert the point&amp;nbsp;&amp;nbsp;&amp;nbsp; //make sure we have a geometry server
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (gsvc === null) initializeProjection();

&amp;nbsp;&amp;nbsp;&amp;nbsp; var outSR = new esri.SpatialReference({ wkid: 4326 });
&amp;nbsp;&amp;nbsp;&amp;nbsp; pt = evt.mapPoint;
&amp;nbsp;&amp;nbsp;&amp;nbsp; gsvc.project([pt], outSR, function (projectedPoints) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newPt = projectedPoints[0];&amp;nbsp;&amp;nbsp;&amp;nbsp; 

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // WAIT FOR SERVER RESPONSE AND THEN DO SOMETHING WITH newPt HERE...
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color:&amp;quot;#FF0000&amp;quot;;"&gt;//This gives undesirable behavior as the window.open() call results in inconsistent behavior&lt;/SPAN&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; }, function (e) { console.log(e.message); });

&amp;nbsp;&amp;nbsp;&amp;nbsp; // CODE HERE RUNS IMMEDIATELY AFTER CALLING PROJECT BUT RESPONSE FROM SERVER MAY NOT HAVE HAPPENED YET...
&amp;nbsp;&amp;nbsp; &lt;SPAN style="color:&amp;quot;#FF0000&amp;quot;;"&gt;//The window.open() call works as expected, but the newPt variable is null, so this doesn't workl&lt;/SPAN&gt;

}&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:02:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/geometry-server-projection-error/m-p/338838#M31373</guid>
      <dc:creator>ShawnHolyoak</dc:creator>
      <dc:date>2021-12-11T16:02:07Z</dc:date>
    </item>
    <item>
      <title>Re: Geometry Server projection error</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/geometry-server-projection-error/m-p/338839#M31374</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am not answering to your question but cannot you create a dialog dojo ( &lt;/SPAN&gt;&lt;A href="http://dojotoolkit.org/reference-guide/1.7/dijit/Dialog.html"&gt;http://dojotoolkit.org/reference-guide/1.7/dijit/Dialog.html&lt;/A&gt;&lt;SPAN&gt; ) and in it you can use for example an iframe with src to a page html where you pass only lat,lon for view in street view?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 14 Apr 2012 13:38:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/geometry-server-projection-error/m-p/338839#M31374</guid>
      <dc:creator>nicogis</dc:creator>
      <dc:date>2012-04-14T13:38:01Z</dc:date>
    </item>
  </channel>
</rss>

