MapViewTapped invalid location DPI problem

916
7
08-24-2016 02:46 AM
AlexKost
New Contributor II

Hi, I'am using ArcGIS  SDK for .NET 10.2.7.0 and creating "modern" store app (Store API) for Windows 8.1.  I have problem with DPI changes. On some monitors (Full HD, 24 inch, 100% scaling in Windows 10) returns MapViewTapped event correct location, but on some monitors (Full HD, 15 inch, 150% scaling) returns wrong location (several cm from correct position on Map).

0 Kudos
7 Replies
AnttiKajanus1
Occasional Contributor III

Hi,

Unfortunately this is a bug in Windows 10 when running Windows Store 8.1 apps in different DPI settings. We have submitted support case to Microsoft for it. I'll have a look if we have update for this.

AlexKost
New Contributor II

Thank you, is there some workaround? With pixel to coordinates ratio and real click point?

0 Kudos
AlexKost
New Contributor II

I found some workaround:

public async void OnMapTouch(object sender, MapViewInputEventArgs e)
{

   MapView view = sender as MapView;
   MapPoint mapPoint = e.Location; //clicked coordinate, not works on some DPI/DPI changes
   double unitPerPx = view.UnitsPerPixel; //not works on some DPI/DPI changes
   double unitPerPx_real = view.Extent.Width / view.ActualWidth; //it seems to works

   double x_offset = e.Position.X * unitPerPx_real;
   double y_offset = e.Position.Y * unitPerPx_real;

   Viewpoint viewpoint = view.GetCurrentViewpoint(ViewpointType.BoundingGeometry);

   double x = viewpoint.TargetGeometry.Extent.XMin + x_offset; //x coordinate, seems to works
   double y = viewpoint.TargetGeometry.Extent.YMax - y_offset; //y coordinate, seems to works

....

Update:

But other functions, as mapView.Editor.RequestShapeAsync not works

AnttiKajanus1
Occasional Contributor III

Just an idea what to test. You could override editor progress and fix the geometry in the event.

0 Kudos
AlexKost
New Contributor II

I tried this:

var progress = new Progress<GeometryEditStatus>((status) =>
{

   / /never called

}

Esri.ArcGISRuntime.Geometry.Geometry newGeometry = await mapView.Editor.RequestShapeAsync(Esri.ArcGISRuntime.Controls.DrawShape.LineSegment, null, progress);

But progress delegate is never invoked during drawing

0 Kudos
AnttiKajanus1
Occasional Contributor III

Ah, line segments doesn't have events since it's only one action. Ie. Polygons would raise the event. I take that the only way to fix LineSegment is to iterate through the Points collection and fix all the points. Not very convenient but might do the trick.

AlexKost
New Contributor II

Thank you, I solved it by own drawing to Canvas and pixel -> coordinates workaround from former post.