<?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: 3.17 Measurement Widget Location Conversion Incorrect in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/3-17-measurement-widget-location-conversion/m-p/394459#M36415</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Joel!&lt;/P&gt;&lt;P&gt;Thank you for taking the time to report these issues. &lt;/P&gt;&lt;P&gt;Both workflows described in this thread have been fixed internally and will be available in the next release (3.18). &lt;/P&gt;&lt;P&gt;Please don't hesitate to let us know if you discover any other issues. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 03 Aug 2016 19:46:16 GMT</pubDate>
    <dc:creator>JonathanUihlein</dc:creator>
    <dc:date>2016-08-03T19:46:16Z</dc:date>
    <item>
      <title>3.17 Measurement Widget Location Conversion Incorrect</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/3-17-measurement-widget-location-conversion/m-p/394457#M36413</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;A bug exists in the Measurement dijit of version 3.17 of the API.&amp;nbsp; This could also exist is previous versions as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Description:&lt;/P&gt;&lt;P&gt;After obtaining a location value, you get nothing or a garbage value when switching the units to UTM, MGRS, or USNG.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Conditions:&lt;/P&gt;&lt;P&gt;1) Your map's spatial reference is web mercator (may happen for other spatial references besides WGS 84 as well).&lt;/P&gt;&lt;P&gt;2) You create the measurement dijit with "advancedLocationUnits" set to true&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Steps to reproduce:&lt;/P&gt;&lt;P&gt;(Note, you can reproduce this is in the measurement widget sample at &lt;A href="https://developers.arcgis.com/javascript/3/sandbox/sandbox.html?sample=widget_measurement" rel="nofollow noopener noreferrer" target="_blank"&gt;https://developers.arcgis.com/javascript/3/sandbox/sandbox.html?sample=widget_measurement&lt;/A&gt; if you also add the "advancedLocationUnits" parameter and set it to true in the constructor and then run the sample)&lt;/P&gt;&lt;P&gt;1) Click the "Location" tool of the widget&lt;/P&gt;&lt;P&gt;2) Click a point on the map so you see the output for the point&lt;/P&gt;&lt;P&gt;3) Switch the units to UTM, USNG, OR MGRS&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note: This bug is not manifested if you select UTM, USNG, or MGRS and then click the point on the map.&amp;nbsp; It is only where there is an existing point and you switch units.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example: If your original units are UTM, and you click a point, you get a good value.&amp;nbsp; If you then re-select UTM in the units list, you get a garbage value for the same location.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Diagnosis:&lt;/P&gt;&lt;P&gt;There are different code paths taken when clicking on a point, or switching the dropdown list.&amp;nbsp; The problem occurs in the _switchLocationUnit function, particularly in this line of code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;"esriDegreeMinuteSeconds"===b||"esriDecimalDegrees"===b?(this._mouseMoveMapHandler=c.connect(this._map,"onMouseMove",this,"_locationMoveHandler"),this._toggleLocationResultsTable(!0,!1),this._locationGraphic&amp;amp;&amp;amp;this._calculateLocation(this._locationGraphic.geometry,!0)):(this._toggleLocationResultsTable(!1,!1),null===this.resultValue||null===this.markerLocationX&amp;amp;&amp;amp;null===this.markerLocationY||(a=this.markerLocationX,d=this.markerLocationY,this._locationGraphic&amp;amp;&amp;amp;this._updateGeocoordinateStringLocation({coordinates:[[a,
d]],sr:{wkid:4326},conversionType:this._unitStrings&lt;B&gt;},this._locationGraphic.geometry)))&lt;/B&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since that's difficult to comprehend, I've translated it (more or less) here:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;if ((b == "esriDegreeMinuteSeconds")&amp;nbsp; || (b == "esriDecimalDegrees")) {
 this._mouseMoveMapHandler = c.connect(this._map, "onMouseMove", this, "_locationMoveHandler");
 this._toggleLocationResultsTable(true, false);
 if (this._locationGraphic)
&amp;nbsp; this._calculateLocation(this._locationGraphic.geometry, true);
} else {
 this._toggleLocationResultsTable(false, false);
 if ((this.resultValue !== null) &amp;amp;&amp;amp; (this.markerLocationX !== null) &amp;amp;&amp;amp; (this.markerLocationY !== null)) {
&amp;nbsp; a = this.markerLocationX;
&amp;nbsp; d = this.markerLocationY;
&amp;nbsp; if (this._locationGraphic)
&amp;nbsp;&amp;nbsp; this._updateGeocoordinateStringLocation({coordinates:[[a,d]], sr:{wkid: 4326}, conversionType:this._unitStrings&lt;B&gt;}, this._locationGraphic.geometry);
 }
}&lt;/B&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Notice the call at the end to _updateGeocoordinateStringLocation...notice in particular the hard-coded value of the "sr" parameter {wkid:4326}.&amp;nbsp; This is the problem...explanation below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When just clicking a point on the map, the workflow goes from _measureCustomPoint to _calculateLocation.&amp;nbsp; This results in call to _updateMarkerLocation, where markerLocationX and markerLocationY are set to wm values of _userGeometry (the point the user clicked).&amp;nbsp; In _calculateLocation, a copy of the geometry projected to wgs 84 is obtained, which then makes its way to _updateGeocoordinateStringLocation.&amp;nbsp; This works because the coordinate values passed are in wgs 84.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, when changing the unit drop-down, the flow is a little different.&amp;nbsp; This starts with a call to _switchLocationUnit, which, as you can see in the code, grabs the markerLocationX and markerLocationY values, which are in web mercator, but slaps a hard coded wkid of 4326 on them, saying they're wgs 84 instead.&amp;nbsp; You can probably see where this is a problem.&amp;nbsp; This is why you get nothing/garbage when switching to UTM, MGRS, or USNG.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Prescription:&lt;/P&gt;&lt;P&gt;You can do this yourself if you have a locally hosted copy of the API.&amp;nbsp; The cause of the bug lies in the hard-coded value for sr (sr:{wkid: 4326}).&amp;nbsp; I instead recommend changing it to sr:this._locationGraphic.geometry.spatialReference&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is because the values of the _locationGraphic geometry are actually copied into markerLocationX and markerLocationY, which are the coordinates passed in the same call.&amp;nbsp; See flow of _locationClickHandler -&amp;gt; _calculateLocation -&amp;gt; this._updateMarkerLocation&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 18:04:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/3-17-measurement-widget-location-conversion/m-p/394457#M36413</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2021-12-11T18:04:21Z</dc:date>
    </item>
    <item>
      <title>Re: 3.17 Measurement Widget Location Conversion Incorrect</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/3-17-measurement-widget-location-conversion/m-p/394458#M36414</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There is another subtle bug in the measure tool related to the advanced location measurements.&amp;nbsp; In some cases, which could be very common in our setup, The "measure-end" will fire once on the first mouse move if one of the advanced units is selected.&amp;nbsp; This was also noticed in 3.17.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The perceived intent of the advanced tools is that they shouldn't update on mouse move.&amp;nbsp; The code is set up to detect that and turn the move handler off, but not until after the first time it fires.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can reproduce this in the sandbox (see above) by adding the advancedLocationUnits parameter to the constructor and running it.&amp;nbsp; Then, expand the measure tool, click the Location tool, switch to MGRS, click a different tool (Distance or Area) and then click back on Location.&amp;nbsp; Then move the mouse over the map...you will see the tool calculates the location of where the mouse cursor first intersected the map.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem occurs in the _calculateLocation function&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can fix the problem by changing the line:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="javascript" __jive_macro_name="code" class="_jivemacro_uid_14698072735475033 jive_macro_code jive_text_macro" data-renderedposition="346_8_1332_16" jivemacro_uid="_14698072735475033"&gt;&lt;P&gt;A&amp;amp;&amp;amp;this._mouseMoveMapHandler&amp;amp;&amp;amp;(c.disconnect(this._mouseMoveMapHandler),this._mouseMoveMapHandler=null);&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;to&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="javascript" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14698073540375113" data-renderedposition="440_8_1332_16" jivemacro_uid="_14698073540375113"&gt;&lt;P&gt;if((A)&amp;amp;&amp;amp;(this._mouseMoveMapHandler)){c.disconnect(this._mouseMoveMapHandler);this._mouseMoveMapHandler=null;if(!a)return;}&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Jul 2016 15:50:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/3-17-measurement-widget-location-conversion/m-p/394458#M36414</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2016-07-29T15:50:44Z</dc:date>
    </item>
    <item>
      <title>Re: 3.17 Measurement Widget Location Conversion Incorrect</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/3-17-measurement-widget-location-conversion/m-p/394459#M36415</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Joel!&lt;/P&gt;&lt;P&gt;Thank you for taking the time to report these issues. &lt;/P&gt;&lt;P&gt;Both workflows described in this thread have been fixed internally and will be available in the next release (3.18). &lt;/P&gt;&lt;P&gt;Please don't hesitate to let us know if you discover any other issues. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Aug 2016 19:46:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/3-17-measurement-widget-location-conversion/m-p/394459#M36415</guid>
      <dc:creator>JonathanUihlein</dc:creator>
      <dc:date>2016-08-03T19:46:16Z</dc:date>
    </item>
    <item>
      <title>Re: 3.17 Measurement Widget Location Conversion Incorrect</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/3-17-measurement-widget-location-conversion/m-p/394460#M36416</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have noticed alot of items fixed in 3.18, and references that people are using it. &amp;nbsp;However it is not available for download&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Sep 2016 14:26:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/3-17-measurement-widget-location-conversion/m-p/394460#M36416</guid>
      <dc:creator>JeffPace</dc:creator>
      <dc:date>2016-09-15T14:26:17Z</dc:date>
    </item>
  </channel>
</rss>

