I'm trying to implement some zoom-in-zoom out feature in my program, for this I'm using two ViewPoints with Wgs84 projection, one is default and other one is current, when I return to the default one it seems to "drift" by ~ 0.1 degrees(P.s the logic working as intended)
so on the first time _currentViewPoint ,XMin for example, is 4.77075... which is exactly as _defaultViewPoint XMin
but on the second time(after some panning and zooming the else condition is met and returning to _defaultViewPoint) the _currentViewPoint XMin is 4.62159...
why this so called drift happens?
public void Click() { if(_firstClick) { _firstClick = false; _mapService = GetMapService(); _defaultViewPoint = _mapService.IntialViewPoint; } _currentViewPoint = _mapService.GetViewPoint(); if(ArePointsEqual(_defaultViewPoint,_currentViewPoint) { if(_viewPointToZoom != null) { _mapService.SetViewPointAsync(_viewPointToZoom) } } else { _viewPointToZoom = _mapService.GetViewPoint(); _mainMapService.SetViewPointAsync(_defaultViewPoint); } } public ViewPoint GetViewPoint() { ViewPoint current = null; try { current = EsriGeoView.GetCurrentViewPoint(ViewpointType.BoundingGeomerty); return ProjectToWgs84(current.TargetGeometry); } catch(...) { //catch } return current; } private ViewPoint ProjectToWgs94(Geometry targetGeometry) { try { var geometry = GeometryEngine.Project(targetGeometry, SpatialReefernces.Wgs84); return new ViewPoint(geometry); } catch(...) { //catch } } private async Task SetViewPointAsync(ViewPoint viewpoint) { //some non relevent code await EsriGeoView.SetViewPointAsync(viewpoint); } private bool AreViewPointsEqual(Viewpoint vp1, Viewpoint vp2, double tolerance = 1e-4) { Envelope r1 = vp1.TargetGeometry.Extent, r2 = vp2.TargetGeometry.Extent; var x1 = (r1.XMax + r1.XMin) / 2; var x2 = (r1.YMax + r1.YMin) / 2; var y1 = (r2.XMax + r2.XMin) / 2; var y2 = (r2.YMax + r2.YMin) / 2; return Math.abs(x1-x2) < tolerance && Math.abs(y1-y2) < tolerance); }