<?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: Incorrect popup location when zooming in in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/incorrect-popup-location-when-zooming-in/m-p/1063050#M73335</link>
    <description>&lt;P&gt;I've had initial success with using a FeatureLayer to query a point's geometry, manually setting the returned geometry as the popup's features. Then watching the view's scale and resetting the popup's location property using the popup's selectedFeature property. I also added a function to offset the popup anchor if you're using a symbol with a yoffset.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const createOffsetGeom = (args) =&amp;gt; {
  const { geometry, yoffset = 0, xoffset = 0 } = args;
  const screenPoint = view.toScreen(geometry);
  let offsetGeom = {};
  screenPoint.y = screenPoint.y + yoffset;
  screenPoint.x = screenPoint.x + xoffset;
  offsetGeom = view.toMap(screenPoint)
  return { latitude: offsetGeom.latitude, longitude: offsetGeom.longitude };
};
view.watch("scale", (scale) =&amp;gt; {
  if (view.popup.visible) {
    view.popup.location = createOffsetGeom({ geometry: 
    view.popup.selectedFeature.geometry, yoffset: -18 });
  }
});&lt;/LI-CODE&gt;&lt;P&gt;It seems the geometry returned with hitTest is more generalized when you click on the map at smaller scale.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 28 May 2021 20:02:55 GMT</pubDate>
    <dc:creator>bmanghi</dc:creator>
    <dc:date>2021-05-28T20:02:55Z</dc:date>
    <item>
      <title>Incorrect popup location when zooming in</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/incorrect-popup-location-when-zooming-in/m-p/1004588#M70906</link>
      <description>&lt;P&gt;We have popup precisely tied to feature location by tracking view.on(click) event and setting popup location like so:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;this&lt;/SPAN&gt;.&lt;SPAN&gt;view&lt;/SPAN&gt;.&lt;SPAN&gt;popup&lt;/SPAN&gt;.&lt;SPAN&gt;open&lt;/SPAN&gt;({&lt;BR /&gt;  &lt;SPAN&gt;features: &lt;/SPAN&gt;&lt;SPAN&gt;response&lt;/SPAN&gt;.&lt;SPAN&gt;results&lt;/SPAN&gt;[&lt;SPAN&gt;0&lt;/SPAN&gt;].&lt;SPAN&gt;graphic&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;BR /&gt;&lt;/SPAN&gt;  &lt;SPAN&gt;location: &lt;/SPAN&gt;&lt;SPAN&gt;response&lt;/SPAN&gt;.&lt;SPAN&gt;results&lt;/SPAN&gt;[&lt;SPAN&gt;0&lt;/SPAN&gt;].&lt;SPAN&gt;graphic&lt;/SPAN&gt;.&lt;SPAN&gt;geometry&lt;BR /&gt;&lt;/SPAN&gt;})&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ChrisShaw_1-1606288666043.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/947i8D17288FB9E47DCC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ChrisShaw_1-1606288666043.png" alt="ChrisShaw_1-1606288666043.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;However, when zooming in manually or clicking Zoom to in the popup the resulting popup drifts to incorrect location.&lt;/P&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ChrisShaw_0-1606288805126.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/948i01EB8E8CEAEC4741/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ChrisShaw_0-1606288805126.png" alt="ChrisShaw_0-1606288805126.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;This issue is present in official demos as well (at least when zooming in with scroll wheel). In some demos when clicking Zoom to the popup snaps back to correct location.&lt;/P&gt;&lt;P&gt;We are using version 4.16&lt;/P&gt;</description>
      <pubDate>Wed, 25 Nov 2020 07:21:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/incorrect-popup-location-when-zooming-in/m-p/1004588#M70906</guid>
      <dc:creator>ChrisShaw</dc:creator>
      <dc:date>2020-11-25T07:21:07Z</dc:date>
    </item>
    <item>
      <title>Re: Incorrect popup location when zooming in</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/incorrect-popup-location-when-zooming-in/m-p/1063050#M73335</link>
      <description>&lt;P&gt;I've had initial success with using a FeatureLayer to query a point's geometry, manually setting the returned geometry as the popup's features. Then watching the view's scale and resetting the popup's location property using the popup's selectedFeature property. I also added a function to offset the popup anchor if you're using a symbol with a yoffset.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const createOffsetGeom = (args) =&amp;gt; {
  const { geometry, yoffset = 0, xoffset = 0 } = args;
  const screenPoint = view.toScreen(geometry);
  let offsetGeom = {};
  screenPoint.y = screenPoint.y + yoffset;
  screenPoint.x = screenPoint.x + xoffset;
  offsetGeom = view.toMap(screenPoint)
  return { latitude: offsetGeom.latitude, longitude: offsetGeom.longitude };
};
view.watch("scale", (scale) =&amp;gt; {
  if (view.popup.visible) {
    view.popup.location = createOffsetGeom({ geometry: 
    view.popup.selectedFeature.geometry, yoffset: -18 });
  }
});&lt;/LI-CODE&gt;&lt;P&gt;It seems the geometry returned with hitTest is more generalized when you click on the map at smaller scale.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 May 2021 20:02:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/incorrect-popup-location-when-zooming-in/m-p/1063050#M73335</guid>
      <dc:creator>bmanghi</dc:creator>
      <dc:date>2021-05-28T20:02:55Z</dc:date>
    </item>
  </channel>
</rss>

