none
TrySetViewAsync in MapControl for UWP not working correctly RRS feed

  • Question

  • Hi,

    I am using TrySetViewAsync to set map view in MapControl, it works fine if I give desiredPitch=0, but when I provide desiredPitch value to the method and the value>0 , it sets the view to a different unexpected view. 
    To reproduce this, I am trying to get center, zoomLevel, heading and desiredPitch from the map and then pass these values in TrySetViewAsync(center, zoomLevel, heading, desiredPitch).

    Is it a known issue or this is the expected behavior? Please check.

    Thanks



    Rohit Garg.

    Monday, April 9, 2018 8:22 AM

Answers

  • Calling the following:

                await myMapControl.TrySetViewAsync(myMapControl.Center, myMapControl.ZoomLevel, myMapControl.Heading, myMapControl.Pitch);

    Appears to behave as expected (the view remains the same or shifts only slightly) for all values of pitch, heading, and zoom that I tested.

    I'm not sure why you would be trying to set the view to the current view, but setting the values to something other explicitly like this:

    await myMapControl.TrySetViewAsync(myMapControl.Center, myMapControl.ZoomLevel, myMapControl.Heading, 45);

    Also appears to be working as expected.

    Monday, April 9, 2018 4:34 PM
    Moderator
  • I'm not able to reproduce any issue. Setting the center while looking at Hyderabad at a tilt of 27 results in no view change as expected.

    Are you doing anything else with the view like setting the TransformOrigin or ViewPadding? Is this on a system with DPI scaling set to something other than 100%?

    Tuesday, April 10, 2018 4:25 PM
    Moderator

All replies

  • Calling the following:

                await myMapControl.TrySetViewAsync(myMapControl.Center, myMapControl.ZoomLevel, myMapControl.Heading, myMapControl.Pitch);

    Appears to behave as expected (the view remains the same or shifts only slightly) for all values of pitch, heading, and zoom that I tested.

    I'm not sure why you would be trying to set the view to the current view, but setting the values to something other explicitly like this:

    await myMapControl.TrySetViewAsync(myMapControl.Center, myMapControl.ZoomLevel, myMapControl.Heading, 45);

    Also appears to be working as expected.

    Monday, April 9, 2018 4:34 PM
    Moderator
  • I had a doubt that the API was not working as expected, so I tried setting the current view, so that, if there's any issue it can be identified.

    I recorded the following test cases by passing the current view to TrySetViewAsync() :

    1. When pitch of the map is 0.

    Before:

    After:

    2.When pitch of the map has been changed to some value (27).

    Before:

    After:

    As you can see, the API doesn't work fine when the pitch is changed, and it is not a slight shift.

    Thanks for looking into the issue.


    Rohit Garg.

    Tuesday, April 10, 2018 7:47 AM
  • I'm not able to reproduce any issue. Setting the center while looking at Hyderabad at a tilt of 27 results in no view change as expected.

    Are you doing anything else with the view like setting the TransformOrigin or ViewPadding? Is this on a system with DPI scaling set to something other than 100%?

    Tuesday, April 10, 2018 4:25 PM
    Moderator