There are two main coordinate systems:
Wkid = 102100
Wkid = 4326
In addition, the width and height of a geometry object are 0, which requires special attention.
// Coordinate points to focus on ESRI. arcGIS. client. projection. webmercator Mercator = new ESRI. arcGIS. client. projection. webmercator (); ESRI. arcGIS. client. geometry. envelope selectedfeatureextent = Mercator. togeographic (graphic. geometry ). extent; // The Position of the last vertex; double expandpercentage = 30; double widthexpand = (selectedfeatureextent. width + 5) * (expandpercentage/100); double heightexpand = (selectedfeatureextent. height + 5) * (expandpercentage/100); ESRI. arcGIS. client. geometry. envelope displayextent = new ESRI. arcGIS. client. geometry. envelope (selectedfeatureextent. xmin-(widthexpand/2), selectedfeatureextent. ymin-(heightexpand/2), selectedfeatureextent. xmax + (widthexpand/2), selectedfeatureextent. ymax + (heightexpand/2); mymap. zoomto (displayextent );
double widthExpand = (selectedFeatureExtent.Width + 5) * (expandPercentage / 100);
Note that you can add 5 to each width to achieve this.
How to set the coordinate system:
ESRI.ArcGIS.Client.Geometry.Envelope initialExtent = new ESRI.ArcGIS.Client.Geometry.Envelope( _mercator.FromGeographic( new ESRI.ArcGIS.Client.Geometry.MapPoint(-122.4545596, 37.783443296)) as MapPoint, _mercator.FromGeographic( new ESRI.ArcGIS.Client.Geometry.MapPoint(-122.4449924, 37.786447331)) as MapPoint); initialExtent.SpatialReference = new SpatialReference(102100); //WKID=4326 MyMap.Extent = initialExtent;