Select to view content in your preferred language

Don´t  work CenterAndZoom funtion whit screen resolution 1920x1080?

647
2
04-14-2011 10:02 AM
FranciscoRodriguez1
Emerging Contributor
Hi ,

I implement Funtion CenterAndZoom of ZoomToResolution(Double,MapPoint) Method. When I rum my application in my computer with resolution 144x 900 work fine. But when I change resolution screen to 1920 x 1080 the Method isn´t work. Teache how can i do?. Attach the Method

private void CenterAndZoom(ESRI.ArcGIS.Client.Map myMap, ESRI.ArcGIS.Client.Geometry.MapPoint myMapPoint, double myResolution)
    {

      // Set a default value to determine whether to 'zoom and center' or just pan.
      double ratio = 0.1;

      // Ensure that we only have a map with a non-zero Resolution in order to calculate a new ratio for re-centering.
      if (myMap.Resolution != 0.1)
      {
        // Create the ratio used to re-center the map
        ratio = myResolution / myMap.Resolution;
      }

      if (ratio == 0.0)
      {
        // Just perform a pan without zooming in.
        myMap.PanTo(myMapPoint);
      }
      else
      {
        // Get the current extent of the map.
        ESRI.ArcGIS.Client.Geometry.Envelope myEnvelope = myMap.Extent;

        // Get the current center of the maps extent.
        ESRI.ArcGIS.Client.Geometry.MapPoint centerMapPoint = myEnvelope.GetCenter();

        // Calculate the X,Y coordinates for the new map extent center.
        double X = (myMapPoint.X - ratio * centerMapPoint.X) / (1 - ratio);
        double Y = (myMapPoint.Y - ratio * centerMapPoint.Y) / (1 - ratio);
        ESRI.ArcGIS.Client.Geometry.MapPoint newMapPoint = new ESRI.ArcGIS.Client.Geometry.MapPoint(X, Y);
        // Zoom in and re-center the map.
        myMap.ZoomToResolution(myResolution, newMapPoint);
      }
    }
0 Kudos
2 Replies
DominiqueBroux
Esri Frequent Contributor
At first glance, I don't see why the screen resolution would change anything to the calculation.
What do you call  'isn't work'? (crashing, bad calculation, do nothing, ....)
0 Kudos
FranciscoRodriguez1
Emerging Contributor
Hi,

When i work in my computer whith 1440x900 the method work fine. I don`t have problem. But when I diplay my application on the other computer with the resolution is 1920 x 1080 the method don't work how I expect. First clic on my data grid calculate center fine , in the second clic isn't calculate the center. I suppose that is problem the resolution becouse when  I change the resolution and work without problem. I test on other computer with  the first resolution and wrok fine. I test the second computer with resolution 1920 x 1080 and don`t work fine.
0 Kudos