<?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: Scaling a graphic in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/scaling-a-graphic/m-p/427049#M39289</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think its happening if selected graphic is not centered&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 06 Aug 2016 13:48:48 GMT</pubDate>
    <dc:creator>Haider_Ali</dc:creator>
    <dc:date>2016-08-06T13:48:48Z</dc:date>
    <item>
      <title>Scaling a graphic</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/scaling-a-graphic/m-p/427044#M39284</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #3d3d3d;"&gt;I want to scale a&amp;nbsp; line graphic on scale event and below is the the code of what i am doing&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #3d3d3d;"&gt;myEditor.editToolbar.on('scale', function(e) {&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #3d3d3d;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var tt = transform(e.graphic.geometry, e.info.scaleX, e.info.scaleY);&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #3d3d3d;"&gt;&amp;nbsp; &lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #3d3d3d;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tsymbolGraphic.setGeometry(tt);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #3d3d3d;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // and then drawing the tsymbolGraphic on map&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #3d3d3d;"&gt;});&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #3d3d3d;"&gt;///and my transform function&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #3d3d3d;"&gt;function transform(geometry,scaleX,scaleY)&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #3d3d3d;"&gt;&amp;nbsp; {&amp;nbsp; // currently for polyline&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #3d3d3d;"&gt;&amp;nbsp; var poly = new Polyline(geometry.spatialReference);&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #3d3d3d;"&gt;&amp;nbsp; var screenPoint,mapPoint;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #3d3d3d;"&gt;&amp;nbsp; arrayUtils.forEach(geometry.paths,function(path,i)&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #3d3d3d;"&gt;&amp;nbsp; {&lt;/P&gt;&lt;P style="padding-left: 60px; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #3d3d3d;"&gt;&amp;nbsp; poly.paths&lt;I&gt; = [];&lt;/I&gt;&lt;/P&gt;&lt;P style="padding-left: 60px; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #3d3d3d;"&gt;&amp;nbsp; arrayUtils.forEach(path,function(pnt,j)&lt;/P&gt;&lt;P style="padding-left: 60px; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #3d3d3d;"&gt;&amp;nbsp; {&lt;/P&gt;&lt;P style="padding-left: 90px; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #3d3d3d;"&gt;&amp;nbsp; screenPoint = map.toScreen(new Point(pnt[0],pnt[1], geometry.spatialReference));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 90px; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #3d3d3d;"&gt;&amp;nbsp; screenPoint.x = screenPoint.x * scaleX&amp;nbsp; + 5&amp;nbsp; ;&lt;/P&gt;&lt;P style="padding-left: 90px; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #3d3d3d;"&gt;&amp;nbsp; screenPoint.y = screenPoint.y * scaleY&amp;nbsp; + 5 ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 90px; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #3d3d3d;"&gt;&amp;nbsp; mapPoint =&amp;nbsp; map.toMap(screenPoint);&lt;/P&gt;&lt;P style="padding-left: 90px; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #3d3d3d;"&gt;&amp;nbsp; poly.paths&lt;I&gt;&lt;J&gt; = [mapPoint.x,mapPoint.y];&lt;/J&gt;&lt;/I&gt;&lt;/P&gt;&lt;P style="padding-left: 60px; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #3d3d3d;"&gt;&amp;nbsp; });&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #3d3d3d;"&gt;&amp;nbsp; });&lt;/P&gt;&lt;P style="padding-left: 30px; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #3d3d3d;"&gt;&amp;nbsp; return poly;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #3d3d3d;"&gt;&amp;nbsp; }&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #3d3d3d;"&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; color: #3d3d3d;"&gt;here is the link of full code &lt;SPAN style="font-family: 'Calibri','sans-serif'; color: black;"&gt;&lt;A href="https://jsfiddle.net/0fy3v8yr/" title="https://jsfiddle.net/0fy3v8yr/ Ctrl+click or tap to follow link"&gt;https://jsfiddle.net/0fy3v8yr/&lt;/A&gt;​ &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Aug 2016 16:49:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/scaling-a-graphic/m-p/427044#M39284</guid>
      <dc:creator>Haider_Ali</dc:creator>
      <dc:date>2016-08-05T16:49:40Z</dc:date>
    </item>
    <item>
      <title>Re: Scaling a graphic</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/scaling-a-graphic/m-p/427045#M39285</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Scale cannot be done similar to move by just using transform. You would have to consider reference point for the scaling. &lt;/P&gt;&lt;P&gt;In the scale event arguments, the info argument contains &lt;STRONG&gt;around&lt;/STRONG&gt; property. Roughly, the calculation should be something like below&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;X = around.x + ((point.x - around.x) * scalex)&lt;/P&gt;&lt;P&gt;Y = around.y + ((point.y - around.y) * scaley)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry I have not verified it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Aug 2016 17:48:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/scaling-a-graphic/m-p/427045#M39285</guid>
      <dc:creator>thejuskambi</dc:creator>
      <dc:date>2016-08-05T17:48:40Z</dc:date>
    </item>
    <item>
      <title>Re: Scaling a graphic</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/scaling-a-graphic/m-p/427046#M39286</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Its working&amp;nbsp; better this way, try this fiddle&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://jsfiddle.net/agha_ali22/0fy3v8yr/2/" title="https://jsfiddle.net/agha_ali22/0fy3v8yr/2/"&gt;graphicScale - JSFiddle&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;on some window size&amp;nbsp; its not working fine (try adjusting the map area in jsfddle&amp;nbsp; )&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Aug 2016 18:34:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/scaling-a-graphic/m-p/427046#M39286</guid>
      <dc:creator>Haider_Ali</dc:creator>
      <dc:date>2016-08-05T18:34:28Z</dc:date>
    </item>
    <item>
      <title>Re: Scaling a graphic</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/scaling-a-graphic/m-p/427047#M39287</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The logic for scaling is working correctly. If I comment the line where you are using geometryEngine.offset. The Red graphic and the editor graphic seems to match.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Aug 2016 19:38:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/scaling-a-graphic/m-p/427047#M39287</guid>
      <dc:creator>thejuskambi</dc:creator>
      <dc:date>2016-08-05T19:38:29Z</dc:date>
    </item>
    <item>
      <title>Re: Scaling a graphic</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/scaling-a-graphic/m-p/427048#M39288</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please&amp;nbsp; select the line graphic at different zoom level in some its working fine&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Aug 2016 23:46:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/scaling-a-graphic/m-p/427048#M39288</guid>
      <dc:creator>Haider_Ali</dc:creator>
      <dc:date>2016-08-05T23:46:07Z</dc:date>
    </item>
    <item>
      <title>Re: Scaling a graphic</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/scaling-a-graphic/m-p/427049#M39289</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think its happening if selected graphic is not centered&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 06 Aug 2016 13:48:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/scaling-a-graphic/m-p/427049#M39289</guid>
      <dc:creator>Haider_Ali</dc:creator>
      <dc:date>2016-08-06T13:48:48Z</dc:date>
    </item>
    <item>
      <title>Re: Scaling a graphic</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/scaling-a-graphic/m-p/427050#M39290</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I get what the issue is, The offset happens only when you pan the map. If zoom or change the level, the issue does not occur. Its because, whenever we pan, the 0,0 location of the map/layer is offset and that information is missing while scaling.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To overcome that, add the following to maintain a variable with map delta offsets.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;var mapDelta;
map.on("extent-change", function(evt){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; console.log(JSON.stringify(evt.delta));
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(!evt.levelChange &amp;amp;&amp;amp; mapDelta){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mapDelta.x += evt.delta.x;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mapDelta.y += evt.delta.y;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } else {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mapDelta = evt.delta;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
});&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now the scaling logic will looks like below&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;screenPoint.x = (refPnt.x + mapDelta.x)&amp;nbsp; + ((screenPoint.x - (refPnt.x&amp;nbsp; + mapDelta.x)) * scaleX);
screenPoint.y = (refPnt.y + mapDelta.y) + ((screenPoint.y - (refPnt.y + mapDelta.y)) * scaleY);&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 19:13:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/scaling-a-graphic/m-p/427050#M39290</guid>
      <dc:creator>thejuskambi</dc:creator>
      <dc:date>2021-12-11T19:13:18Z</dc:date>
    </item>
    <item>
      <title>Re: Scaling a graphic</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/scaling-a-graphic/m-p/427051#M39291</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thankyou its working fine,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;just added&lt;/P&gt;&lt;P&gt;if( !evt.delta)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;because evt.delta was undefined when i opened developer tool in chrome and resized it&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Updated code in the following fiddle&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://jsfiddle.net/agha_ali22/0fy3v8yr/10/" title="https://jsfiddle.net/agha_ali22/0fy3v8yr/10/"&gt;graphicScale - JSFiddle&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Aug 2016 18:26:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/scaling-a-graphic/m-p/427051#M39291</guid>
      <dc:creator>Haider_Ali</dc:creator>
      <dc:date>2016-08-08T18:26:52Z</dc:date>
    </item>
  </channel>
</rss>

