Problem with SetZoomToFitRect

Aug 24, 2010 at 4:58 PM

Hello

SetZoomToFitRect is not centered to the passed rectangle ! The view, is north of the selected rectangle ... do I miss something ? 

Using August 12th sources ! 

 

This is the view I get when calling SetZoomToFitRect : http://xaqc.org/linkto/gmap.net-SetZoomToFitRect.jpg

If I draw a polygon of the Rect use in the previous photo ... http://xaqc.org/linkto/gmap.net-RectLatLng.jpg

If I show you a larger view, you can see that the view view given by SetZoomToFitrect is North of the selected Rect : http://xaqc.org/linkto/gmap.net-totalview.jpg

 

Aug 24, 2010 at 6:44 PM

hold SHIFT drag mouse, always zooms to center, so where is the issue?

Aug 24, 2010 at 7:01 PM

Holding Shift + Drag works fine ... doing it programmatically ... the zoom is not ok. 

That made me think about the problem, I found a solution. But I dont know if the problem is from me or in the the zoom function. I guess I am wrong.

I am used to work with gfx both in 2d and 3d ... and the latitude is a bit confusing since Top is 90 and Bottom is -90. So to be able to do easy computation with RectLatLng ... the HeightLat must be negative, but the zoom function want it positive.

 

if (checkBoxGPXAutoZoom.Checked)            
{                
   RectLatLng temp = new RectLatLng();               
   temp = zoomRect;                
   temp.HeightLat = -temp.HeightLat;                
   gMapControl.SetZoomToFitRect(temp);            
}

This invert my negative latitude height and the zoom is fine.

To follow every other rectangle class ... they all have some thing like : x, y, width, height.

To get top left corner ... you have :  x, y

To get bottom right corner you do :   x+width,  y+height

So for your rect to follow standard, with latitude axe inverted ... you need to have negative height to be able to compute bottom right corner using : r.lat+r.heightlat !

It will be simpler for me to modify it on my side, at the one place I will autozoom ;)

Aug 24, 2010 at 7:49 PM

hm.. thats really something ;] ..and why do you need to specify HeightLat?

Aug 24, 2010 at 8:02 PM

True I could use the other creator : RectLatLng(PointLatLng, SizeLatLng) ... but being from the game industry its an habit to always use the fuctions that requires the less allocators as possible ;)

So I was using : RectLatLng(lat, lng, widthlng, heightlat);      which is wierd by the way in the order of the params .... you have :   lat, lng, lng, lat  !?!?!?! you should do  : lat lat lng lng ... or lat lng lat lng :P

Ok I stop, its your lib you do it the way you want.

Aug 24, 2010 at 9:34 PM

he he it's not my ;}, i own nothing, but that just how the current version is, i've converted usual rect to deal with coordinates, and latitude is Y, but inverted, so it's sort of strange, i'll promise to clean it on the way.

..There is few core issues, and my inbox is full of all kind of things from these discussions, so the sands of time are getting big but the destiny is great! ;}