Exact measure of the "Powered by esri" banner

147
2
2 weeks ago
Labels (2)
RenzSui
New Contributor

How do you get the exact dimension of the attribution text and banner? My task is to get the exact viewport map that we supply but it seems the SetViewportAsync is oversizing the actual map to include the part under the attribution text/banner as well. I've looked into the documentation but there's not mention of how to fetch the dimension of the attribution text's banner. Thank you in advance for any help!

0 Kudos
2 Replies
dotMorten_esri
Esri Notable Contributor

I'm not quite sure what you mean by "oversizing" ?
If you zoom to the red polygon below (or its blue extent), the map will zoom to it in such a way that it guarantees the feature will not be blocked by the attribution bar. Example:

dotMorten_esri_0-1714754072505.png

Are you seeing this not working and the extent you go to is obscured by the attribution?

These are called view insets, and it automatically will add the attribution to the inset. You can further add to the insets but setting the GeoView.ViewInsets property to add additional padding. For instance if you have a 200px wide side panel you sometimes have open, when it's open you can add that to the view to ensure when you pan or zoom to a viewpoint, it won't be obscured by the feature:

myMapView.ViewInsets = new Thickness((isPanelOpen ? 200 : 0), 0,0,0);

dotMorten_esri_1-1714754506453.png

 

0 Kudos
RenzSui
New Contributor

Hello,

In our case, it isn't. Our goal is to get the exact screenshot given a viewpoint. In our example we set the viewpoint to

[XMin=643337.447936 YMin=262073.813165 XMax=645931.670118 YMax=263557.442529 Wkid=27700] on MapView dimension set to [761, 435]

ArcGIS runtime returns this screenshot with viewpoint at

[XMin=643275.904459005, YMin=262073.813165, XMax=645993.213594995, YMax=263557.442529, Wkid=27700]

SS2.png

 

For reference, here's what it looks like in-app:SS1.png

 

The Y component is equal to what we supplied meaning we should expect the Y to be as exact to what we're after.

However, upon inspection, the bottom pixel is at 266008 which is off by 64 world units.

SS3.png

Here's where we expect the bottom border of our screenshot should be:

SS4.png

I tried hard-coding half of the height of the attribution text (measured from paint) and cropping that amount relative to the screenshot and it perfectly brought out the exact screenshot. This perfectly works in my machine but It will probably mess up in another machine unless I can get exactly how tall the attribution text is.

Note that the ViewInsets right now is set to 0,0,0,0

 

0 Kudos