HI,
What I am wanting to define a set of points and display all points in a map at the proper zoom level. I found this code, but some of the classes do not resolve. Could someone help out with this transaltion, or suggest a better way?
private RectangleR CalculateMapExtent()
{
//Declare Variables
PointShape pointShape;
double upperLeftLat = 0;
double upperLeftLong = 0;
double lowerRightLat = 0;
double lowerRightLong = 0;
//Loop through the points collection to find the upper left and lower right point values
foreach (BaseMapShape baseMapShape in Map1.MapShapes)
{
if (baseMapShape is PointMapShape)
{
pointShape = (PointShape)baseMapShape.BaseShape;
if (pointShape.Y > upperLeftLat | upperLeftLat == 0) upperLeftLat = pointShape.Y;
if (pointShape.X < upperLeftLong | upperLeftLong == 0) upperLeftLong = pointShape.X;
if (pointShape.Y < lowerRightLat | lowerRightLat == 0) lowerRightLat = pointShape.Y;
if (pointShape.X > lowerRightLong | lowerRightLong == 0) lowerRightLong = pointShape.X;
}
}
//Create variables to set the extent
PointR upperLeftPoint = new PointR(upperLeftLong, upperLeftLat);
PointR lowerRightPoint = new PointR(lowerRightLong, lowerRightLat);
RectangleR mapExtent = new RectangleR(upperLeftPoint, lowerRightPoint);
//Scale Up Map extent by 5%
mapExtent.ScaleUp(5);
if (mapExtent.get_Width(MapLengthUnits.DecimalDegrees, MapLengthUnits.miles) < 400)
{
while (!(mapExtent.get_Width(MapLengthUnits.DecimalDegrees, MapLengthUnits.miles) > 400))
{
mapExtent.ScaleUp(5);
}
}
return mapExtent;
}