[ArcGIS SDK for .Net 100.x] Using MapView.SetViewPoint specifying thickness...

1902
9
Jump to solution
03-13-2017 05:01 AM
DamienPONNELLE
New Contributor II

Hi,

With ArcGIS Runtime version 10.2.x, it was possible to optionally specify a "margin" (thickness) on the MapView.SetViewAsync() operations. Very convenient for the map to be correctly centered when, for example, a horizontal menu bar covers the bottom of the map (but may disappear in some cases).

Example:

await MapView1.SetViewAsync(mpYouAreHere, dblScale, tsDelay, new Thickness(0, 0, 0, Menu.ActualHeight));

I try to migrate my application to the new Runtime version 100 but I do not find this possibility.

There is indeed a "padding" argument in the MapView.SetViewpointGeometryAsync() method but it is of type "double" but not "thickness" ; It is therefore not possible to specify a different "margin" for the 4 sides.

Do you have an idea to help me?

Thank you in advance.

damien.

0 Kudos
1 Solution

Accepted Solutions
dotMorten_esri
Esri Notable Contributor

The margin is for ensuring a bit of space all the way around the geometry at that instant.

For your specific scenario where you have an overlay somewhat more permanent on top of the map, use the MapView.ViewInsets instead. Ie when you popup up your overlay, use

    MapView.ViewInsets = new Thickness(0,0,0,overlay.ActualHeight);

and when you close it, set it back to 0:

   MapView.ViewInsets = new Thickness(0);

When you do that, all setviewpoint calls will automatically take the insets into account, LocationDisplay will center correct etc.

View solution in original post

9 Replies
PreetiMaske
Esri Contributor

Hell Damien,

Support to add margin is going to be available in the next update release.

-Preeti

DamienPONNELLE
New Contributor II

Hi Preeti,

Cool !

Thank you for your answer. Is there a planned date for this next update?

Regards,

damien.

0 Kudos
PreetiMaske
Esri Contributor

Most likely around summer , like May-June time frame.

DamienPONNELLE
New Contributor II

Nice. Thank you for your answer.

Regards,

damien.

0 Kudos
DamienPONNELLE
New Contributor II

Hi Preeti,

I am currently testing v100.2 and I find that the possibility of specifying a "margin" (thickness) has still not been reintroduced.


Or a subtlety escaped me, which is not impossible.


Thank you in advance for your response.

Regards,

damien.

0 Kudos
PreetiMaske
Esri Contributor

Hello Damien,

MapView has a method called SetViewpointGeometryAsync that takes a geometry for setting the viewpoint and as well as a margin/padding value. I think that's what you are looking for.

example code

```

var curExtent = mv.GetCurrentViewpoint(ViewpointType.BoundingGeometry).TargetGeometry;
await mv.SetViewpointGeometryAsync(curExtent, 100);

```

0 Kudos
DamienPONNELLE
New Contributor II

Hello Preeti,

Thank you for your answer but this one does not correspond to my problem.

On the other hand, that of Morten (using MapView.ViewInsets) answers it completely.

Thank you and have a nice day.

Regards,

damien.

0 Kudos
dotMorten_esri
Esri Notable Contributor

The margin is for ensuring a bit of space all the way around the geometry at that instant.

For your specific scenario where you have an overlay somewhat more permanent on top of the map, use the MapView.ViewInsets instead. Ie when you popup up your overlay, use

    MapView.ViewInsets = new Thickness(0,0,0,overlay.ActualHeight);

and when you close it, set it back to 0:

   MapView.ViewInsets = new Thickness(0);

When you do that, all setviewpoint calls will automatically take the insets into account, LocationDisplay will center correct etc.

DamienPONNELLE
New Contributor II

Hello Morten,

Perfect ! Your answer totally corresponds to my problem.

Thank you very much !

In addition, I find it elegant to be able to permanently define the "useful" area and not have to pass the thikness parameter when repositioning the card (possibility offered by MapView1.SetViewAsync with SDK 10.2.x).

Nice day to you and thank you again!

Regards,

damien.