<?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: Save AGSMapView viewpoint after user zoom/pan in ArcGIS Runtime SDK for iOS Questions</title>
    <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/save-agsmapview-viewpoint-after-user-zoom-pan/m-p/449368#M3842</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My problem is not performance, but the fact that during the "setup" of the viewpoint, the reported&amp;nbsp;currentViewpoint goes from 0,0 to&amp;nbsp;the destination viewpoint and reports some of the intermediate&amp;nbsp;states... (e.g. you may end up with 10,10 as a valid value, with isNavigating set to true, however that's just a transition from 0,0 to 100,100).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 29 Oct 2019 04:20:27 GMT</pubDate>
    <dc:creator>marius</dc:creator>
    <dc:date>2019-10-29T04:20:27Z</dc:date>
    <item>
      <title>Save AGSMapView viewpoint after user zoom/pan</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/save-agsmapview-viewpoint-after-user-zoom-pan/m-p/449364#M3838</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm running into an issue when trying to save the current map viewpoint &lt;EM&gt;only&lt;/EM&gt; after a user interaction.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've implemented&amp;nbsp;viewpointChangedHandler, however, that method is called also when the map is&amp;nbsp;programatically setup (e.g. at start up).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To avoid saving a map position that wasn't set by the user, I'm also checking that &lt;STRONG&gt;isNavigating&amp;nbsp;== true&lt;/STRONG&gt;,&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;however that doesn't seem to be enough. It seems that&amp;nbsp;&lt;STRONG&gt;isNavigating &lt;/STRONG&gt;might&amp;nbsp;be &lt;STRONG&gt;true/false&lt;/STRONG&gt;&amp;nbsp;in other situations as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Logs from my tests:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;// Loading map (with viewpoint set to 37.926438,-122.070035,0.004000,0.006430,0.000000)
18:28:37:196 isNavigating: true viewpoint: -0.000000,0.000000,160.809973,360.000000,0.000000
18:28:37:228 isNavigating: true viewpoint: 0.000052,-0.000931,160.798596,359.913489,0.000000
18:28:37:450 isNavigating: false viewpoint: 37.926438,-122.070035,0.004000,0.006430,0.000000

// Rotating map, pan, zoom
18:29:40:253 isNavigating: true viewpoint: 37.926362,-122.070321,0.002501,0.004020,79.688963
18:29:40:570 isNavigating: true viewpoint: 37.926356,-122.070335,0.002631,0.004229,83.738892
18:29:40:821 isNavigating: true viewpoint: 37.926357,-122.070380,0.002793,0.004489,97.041926
18:29:41:040 isNavigating: false viewpoint: 37.926358,-122.070381,0.002793,0.004489,97.376031
18:29:43:911 isNavigating: true viewpoint: 37.926354,-122.070384,0.002873,0.004618,97.376031&lt;/PRE&gt;&lt;P&gt;I found this thread for the old SDK&amp;nbsp;&lt;A href="https://community.esri.com/thread/163678" target="_blank"&gt;notification when user moves map&lt;/A&gt;, that can be combined with&amp;nbsp;&lt;STRONG&gt;lastChangeFromInteraction&lt;/STRONG&gt;, but I can't find&amp;nbsp;something similar in SDK 100.6.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What's the most reliable way to save the viewpoint after a user interaction?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you,&lt;BR /&gt;Marius&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 16:29:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/save-agsmapview-viewpoint-after-user-zoom-pan/m-p/449364#M3838</guid>
      <dc:creator>marius</dc:creator>
      <dc:date>2021-12-12T16:29:34Z</dc:date>
    </item>
    <item>
      <title>Re: Save AGSMapView viewpoint after user zoom/pan</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/save-agsmapview-viewpoint-after-user-zoom-pan/m-p/449365#M3839</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;We use isNavigating in the open source maps app and it works well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://github.com/Esri/maps-app-ios/blob/de272de41a2cdcda680a1a296c6467339b63c422/maps-app-ios/UI/Map%20View/MapViewController%2BAppPreferences.swift#L31-L35" title="https://github.com/Esri/maps-app-ios/blob/de272de41a2cdcda680a1a296c6467339b63c422/maps-app-ios/UI/Map%20View/MapViewController%2BAppPreferences.swift#L31-L35"&gt;maps-app-ios/MapViewController+AppPreferences.swift at de272de41a2cdcda680a1a296c6467339b63c422 · Esri/maps-app-ios · Gi…&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You could prevent storing the viewpoint until the first isNavigating = false after setting the initial viewpoint.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Out of interest, are you setting&amp;nbsp;the map's viewpoint with an AGSMap constructor, or setting its initialViewpoint before assigning it to the AGSMapView, or are you setting the viewpoint on the AGSMapView?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Lastly, in your second set of logs, the isNavigating = false event at&amp;nbsp;18:29:41:040 looks like it's because the user has not moved the map, even though they might still have their fingers on the map view. Is that possible? But I would expect another log entry after&amp;nbsp;18:29:43:911 where isNavigating is false again. Did you not see that, or are the logs just a subset?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Oct 2019 18:39:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/save-agsmapview-viewpoint-after-user-zoom-pan/m-p/449365#M3839</guid>
      <dc:creator>Nicholas-Furness</dc:creator>
      <dc:date>2019-10-25T18:39:01Z</dc:date>
    </item>
    <item>
      <title>Re: Save AGSMapView viewpoint after user zoom/pan</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/save-agsmapview-viewpoint-after-user-zoom-pan/m-p/449366#M3840</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for this Nick.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'll check setting an observable on isNavigating, but&amp;nbsp;ignoring it until the first isNavigating = false, sounds weird...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is a simplified&amp;nbsp;layout of the maps code, all in the same class, with the self/strongSelf/etc bits removed.&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;// At view init time&lt;BR /&gt;mapView.viewpointChangedHandler = {&lt;BR /&gt;&amp;nbsp; if mapView.isNavigating {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; // Save changed map position&lt;BR /&gt;&amp;nbsp; }&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// At map change&lt;BR /&gt;webMap = AGSMap(item: userMap)&lt;BR /&gt;// webMap = AGSMap(basemap: basemap)&lt;BR /&gt;if mapView.map != nil {&lt;BR /&gt;&amp;nbsp; let currentViewpoint = mapView.currentViewpoint(with: .centerAndScale)&lt;BR /&gt;&amp;nbsp; webMap.initialViewpoint = currentViewpoint&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;webMap.load() {&lt;BR /&gt;&amp;nbsp; mapView.map = nil&lt;BR /&gt;&amp;nbsp; mapView.map = webMap&lt;BR /&gt;}&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Re the set of logs, it's a truncated representation. I've moved the map around, and those gaps were there while manipulating the map. Maybe the gaps are from&amp;nbsp;when the map was moving out of inertia though. If it helps, I can record a video.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Oct 2019 09:10:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/save-agsmapview-viewpoint-after-user-zoom-pan/m-p/449366#M3840</guid>
      <dc:creator>marius</dc:creator>
      <dc:date>2019-10-28T09:10:40Z</dc:date>
    </item>
    <item>
      <title>Re: Save AGSMapView viewpoint after user zoom/pan</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/save-agsmapview-viewpoint-after-user-zoom-pan/m-p/449367#M3841</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;We use the viewpointChangedHandler to trigger a redraw of our scale bar as well as stashing the viewpoint in NSUserDefaults. &amp;nbsp;Have to go Viewpoint-&amp;gt;JSON-&amp;gt;NSDictionary to get it in there but it is handy way to have the last viewpoint available if the app is closed in the background, or if we destroy the map view and want to reconstitute it later.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I haven't noticed a huge issue with it triggering for non-pan/zoom activities. &amp;nbsp;It happens but doesn't really impact performance in any major way. &amp;nbsp;I guess if we were so inclined we could compare the extent of the saved viewpoint with the current viewpoint and only update if different.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Oct 2019 00:21:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/save-agsmapview-viewpoint-after-user-zoom-pan/m-p/449367#M3841</guid>
      <dc:creator>MichaelDavis3</dc:creator>
      <dc:date>2019-10-29T00:21:51Z</dc:date>
    </item>
    <item>
      <title>Re: Save AGSMapView viewpoint after user zoom/pan</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/save-agsmapview-viewpoint-after-user-zoom-pan/m-p/449368#M3842</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My problem is not performance, but the fact that during the "setup" of the viewpoint, the reported&amp;nbsp;currentViewpoint goes from 0,0 to&amp;nbsp;the destination viewpoint and reports some of the intermediate&amp;nbsp;states... (e.g. you may end up with 10,10 as a valid value, with isNavigating set to true, however that's just a transition from 0,0 to 100,100).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Oct 2019 04:20:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/save-agsmapview-viewpoint-after-user-zoom-pan/m-p/449368#M3842</guid>
      <dc:creator>marius</dc:creator>
      <dc:date>2019-10-29T04:20:27Z</dc:date>
    </item>
    <item>
      <title>Re: Save AGSMapView viewpoint after user zoom/pan</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/save-agsmapview-viewpoint-after-user-zoom-pan/m-p/449369#M3843</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ahh I see - The way we avoid that is by making the assignment of viewpointChangedHandler the&amp;nbsp;&lt;EM&gt;very last thing&lt;/EM&gt; we do in the setup of the map. &amp;nbsp;We load the map, zoom to any previously stored viewpoint, set up basemap and base layers, reconstitute any definition queries&amp;nbsp;we might have... and then set the handler. &amp;nbsp;This seems to have minimized that sort of premature activity for us.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Oct 2019 04:34:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/save-agsmapview-viewpoint-after-user-zoom-pan/m-p/449369#M3843</guid>
      <dc:creator>MichaelDavis3</dc:creator>
      <dc:date>2019-10-29T04:34:58Z</dc:date>
    </item>
    <item>
      <title>Re: Save AGSMapView viewpoint after user zoom/pan</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/save-agsmapview-viewpoint-after-user-zoom-pan/m-p/449370#M3844</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Michael. After explaining the problem in the earlier post, I thought that this might be the solution. I'll give that a try.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Oct 2019 06:49:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/save-agsmapview-viewpoint-after-user-zoom-pan/m-p/449370#M3844</guid>
      <dc:creator>marius</dc:creator>
      <dc:date>2019-10-29T06:49:41Z</dc:date>
    </item>
  </channel>
</rss>

