This project has moved and is read-only. For the latest updates, please go here.

WorldToMap Seems offset first time it is called

Topics: General Topics
Oct 4, 2006 at 10:48 AM
Well, I have only been doing this stuff for a couple of months and I have got on quite a way but this has me stumped.

I use the following code in the ItemSelectionChanged event of a listview

MoebiusCell oCell = (MoebiusCell)e.Item.Tag;

SharpMap.Data.Providers.GeometryProvider oGeoProvider = new SharpMap.Data.Providers.GeometryProvider(oCell.WKB);
PointF oPT = SharpMap.Utilities.Transform.WorldtoMap(new SharpMap.Geometries.Point(oGeoProvider.GetExtents().Left, oGeoProvider.GetExtents().Bottom),_Map );

ttpMain.IsBalloon = true;
ttpMain.Show(oCell.ToString(), mapCell , (int)oPT.X,(int)oPT.Y);

The tooltips display fine but the first time I click on an item in the list the tool tip is displayed offset (sometimes by a long way.) I have tried using the map transforms and the utilities transforms (no change,) I have checked the value of oPT.X and oPT.Y on subsequent calls to the routine and the values are the same both times. The only other thing of note is that the map control is hosted in a toolstrip content panel ?

Hope someone can help I am at my wits end.

Regards & Thanks.

Oct 4, 2006 at 12:13 PM
Yeuchh. Its not the fine sharpmap code after all.

It would seem the balloon style tips display incorectly the first time.

Another weird problem people may want to look out for is the following.

I have a checkbox style listview displayed next to my map, in the itemchecked event I turn on or off layers depending on the checked value. When you minimize the form (to the taskbar) the listview fires uncheck events for each item, it does the opposite on restore. This causes my app to stop while it tries to enable/disable each layer. I have had to trap the WM_SIZE message and set a flag to ignore the check events on minimize and maximise. What a load of hassle.

Anyway, getting there slowly.