HeavenWord1
Posts: 4
Joined: Wed Apr 22, 2009 8:14 am

ZoomByBoundingBox in CF Not Working

Fri Feb 26, 2010 12:51 pm

I am using GpsToolsNET.dll File Version 2.3.1.227 and the following code. I am passing in 4 doubles, which are lat/long pairs for the upper left and lower right corners of the area I want the map to zoom to.

Code: Select all

public void GetZoomForBox(double[] daLatLongs)
{ GpsToolsNET.Position position1 = new GpsToolsNET.Position();	// Upper left
  GpsToolsNET.Position position2 = new GpsToolsNET.Position();	// Lower right
  position1.Latitude  = daLatLongs[0];
  position1.Longitude = daLatLongs[1];
  position2.Latitude  = daLatLongs[2];
  position2.Longitude = daLatLongs[3];
  MapGPS.ZoomByBoundingBox(position1, position2);
  //GpsViewNET.Pen objPen = new GpsViewNET.Pen();
  //GpsViewNET.Rectangle objRect = MapGPS.NewRectangle();
  //objPen.Width = 2;
  //objPen.Red = 255;	    objPen.Blue = 128;    objPen.Green = 128;
  //objRect.Pen = objPen;
  //objRect.Position1 = position1;
  //objRect.Position2 = position2;
  MapGPS.Update();
}
Note that the commented out code correctly draws the rectangle around the area I want to zoom to. But no zoom occurs. Checking the MapGPS.zoom value before and after the call reveals no change.

What is wrong?

bbulla
Posts: 282
Joined: Fri Jun 17, 2005 12:13 am
Location: Canada

RE: ZoomByBoundingBox in CF Not Working

Fri Feb 26, 2010 5:20 pm

The only thing I can think of is that you need to make it say:

MapGPS.ZoomByBoundingBox(position2, position1);

As per the Reference Manual, you need it to be (upperLeft, lowerRight). You rectangle will still draw if these are switched, but the Zoom probably won't work.


Brian

HeavenWord1
Posts: 4
Joined: Wed Apr 22, 2009 8:14 am

RE: ZoomByBoundingBox in CF Not Working

Fri Feb 26, 2010 9:27 pm

I flipped it with no difference. BTW, after I build the positions and do

Code: Select all

GpsViewNET.Point pt1 = MapGPS.Position2Point(position1);
GpsViewNET.Point pt2 = MapGPS.Position2Point(position2);
I get:

Code: Select all

pt1.X = -10
pt1.Y = 52
pt2.X = 18
pt2.Y = -3
so I think the original order is correct, unless I'm badly misunderstanding.

HeavenWord1
Posts: 4
Joined: Wed Apr 22, 2009 8:14 am

RE: ZoomByBoundingBox in CF Not Working

Tue Mar 02, 2010 9:12 am

Got it working. Not sure what was wrong, but I flipped the points around until it got happy.

Return to “GpsTools”