<?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: Set viewpoint for graphics overlay when using floating panels in Swift Maps SDK Questions</title>
    <link>https://community.esri.com/t5/swift-maps-sdk-questions/set-viewpoint-for-graphics-overlay-when-using/m-p/1550754#M453</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/39442"&gt;@rolarola&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;thanks for that quick reply, that helped me a lot!&lt;/P&gt;&lt;P&gt;Greetings&lt;BR /&gt;Marvin&lt;/P&gt;</description>
    <pubDate>Tue, 22 Oct 2024 06:32:08 GMT</pubDate>
    <dc:creator>mmoosbac94</dc:creator>
    <dc:date>2024-10-22T06:32:08Z</dc:date>
    <item>
      <title>Set viewpoint for graphics overlay when using floating panels</title>
      <link>https://community.esri.com/t5/swift-maps-sdk-questions/set-viewpoint-for-graphics-overlay-when-using/m-p/1550482#M451</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;I have a question about adjusting the viewpoint for a graphics overlay when using floating panels. We’ve implemented a search feature that displays results in a floating panel (by default its displayed half of the screen), alongside a graphics overlay on the map. Currently, we’re using an ExtentBuilder and setViewpointGeometry to set the viewpoint for these results, and while this is working well, the viewpoint defaults to the center of the extent. As a result, some of the results are obscured by the floating panel.&lt;/P&gt;&lt;P&gt;Our goal is to position the viewpoint above the floating panel so that all results are fully visible, similar to how it works in Google Maps. This means we need to set the viewpoint for the extent at a fixed height above the floating panel, regardless of the scale level and extent size. I’ve tried various approaches but haven’t had any success yet.&lt;/P&gt;&lt;P&gt;Any suggestions on how to achieve this would be greatly appreciated!&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;What I tried:&lt;BR /&gt;&lt;BR /&gt;1. Try (Viewpoint is center of extent)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="swift"&gt;let modifiedExtent = calculateModifiedExtent(from: overlay)
await proxy.setViewpointGeometry(modifiedExtent!)


static func calculateModifiedExtent(from graphicsOverlay: GraphicsOverlay) -&amp;gt; Envelope? {

        let extentBuilder = graphicsOverlay.extent?.makeBuilder()

        extentBuilder?.expand(by: 2.0)

        return extentBuilder?.toGeometry()

    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;&lt;BR /&gt;2. Try (Not working due to different scale-levels with modifying screenPoint.y)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="swift"&gt;var screenPoint = proxy.screenPoint(fromLocation: overlay.extent!.center)

            screenPoint!.y = screenPoint!.y - 150

            

            let newMapPoint = proxy.location(fromScreenPoint: screenPoint!)

            

            let extentBuilder = overlay.extent?.makeBuilder()

            extentBuilder?.expand(by: 2.0, anchor: newMapPoint)

            let newExtent = extentBuilder?.toGeometry()

            await proxy.setViewpointGeometry(newExtent!)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;3. Try (its working when setting viewpoint without anchor first and then setting viewpoint with anchor, but then there are two animations, looking weird)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="swift"&gt;let modifiedExtent = calculateModifiedExtent(from: overlay)
            await proxy.setViewpointGeometry(modifiedExtent!)

            var screenPoint = proxy.screenPoint(fromLocation: overlay.extent!.center)
            screenPoint!.y = screenPoint!.y - 150
            
            let newMapPoint = proxy.location(fromScreenPoint: screenPoint!)
            
            let extentBuilder = overlay.extent?.makeBuilder()
            extentBuilder?.expand(by: 2.0, anchor: newMapPoint)
            let newExtent = extentBuilder?.toGeometry()
            await proxy.setViewpointGeometry(newExtent!)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;BR /&gt;&lt;BR /&gt;Kind regards,&lt;BR /&gt;&lt;SPAN&gt;Marvin&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Oct 2024 15:06:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/swift-maps-sdk-questions/set-viewpoint-for-graphics-overlay-when-using/m-p/1550482#M451</guid>
      <dc:creator>mmoosbac94</dc:creator>
      <dc:date>2024-10-21T15:06:50Z</dc:date>
    </item>
    <item>
      <title>Re: Set viewpoint for graphics overlay when using floating panels</title>
      <link>https://community.esri.com/t5/swift-maps-sdk-questions/set-viewpoint-for-graphics-overlay-when-using/m-p/1550498#M452</link>
      <description>&lt;P&gt;Marvin,&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you have any part of the map view obscured by other content, then you can use the contentInsets view modifier to tell the map view what part is obscured. From there when you zoom to an extent, the extent zoomed to will be in the unobscured portion of the map view:&lt;/P&gt;&lt;LI-CODE lang="swift"&gt;    /// Allows you to set the edges where the map view is obscured by some other
    /// UI. This is important so that the location display is anchored
    /// appropriately. Setting this also affects the way viewpoints are set and
    /// reported by the map view. For example, setting a viewpoint with a center
    /// will cause the geographic center of the viewpoint to be contained within
    /// the area affected by the insets.
    /// - Parameter contentInsets: The insets from the edges where the map view
    /// content is obscured.
    func contentInsets(_ contentInsets: EdgeInsets) -&amp;gt; MapView {&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Oct 2024 15:40:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/swift-maps-sdk-questions/set-viewpoint-for-graphics-overlay-when-using/m-p/1550498#M452</guid>
      <dc:creator>rolson_esri</dc:creator>
      <dc:date>2024-10-21T15:40:34Z</dc:date>
    </item>
    <item>
      <title>Re: Set viewpoint for graphics overlay when using floating panels</title>
      <link>https://community.esri.com/t5/swift-maps-sdk-questions/set-viewpoint-for-graphics-overlay-when-using/m-p/1550754#M453</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/39442"&gt;@rolarola&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;thanks for that quick reply, that helped me a lot!&lt;/P&gt;&lt;P&gt;Greetings&lt;BR /&gt;Marvin&lt;/P&gt;</description>
      <pubDate>Tue, 22 Oct 2024 06:32:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/swift-maps-sdk-questions/set-viewpoint-for-graphics-overlay-when-using/m-p/1550754#M453</guid>
      <dc:creator>mmoosbac94</dc:creator>
      <dc:date>2024-10-22T06:32:08Z</dc:date>
    </item>
  </channel>
</rss>

