Ben, your code worked. I didnt open and close the layer and get a correct currentExtent thats why it didnt work before. However, i noticed the latitude ang longitude derived was wrong, it gave me very big numbers like "632587.84328, 96851.26119". i tried GeographyUnit of Meters, DecimalDegree…etc but all the same. I also tried other .SID files, also the same. Is there something we should do when using MrSid layers?
Here is my code:
private void Form1_Load(object sender, EventArgs e)
{
winformsMap1.MapUnit = GeographyUnit.Meter;
MrSidRasterLayer mrSidRasterLayer = new MrSidRasterLayer(@"C:\Maps\abbott1.sid");
mrSidRasterLayer.Open();
winformsMap1.CurrentExtent = mrSidRasterLayer.GetBoundingBox();
mrSidRasterLayer.Close();
winformsMap1.StaticOverlay.Layers.Add("MrSidLayer", mrSidRasterLayer);
winformsMap1.Refresh();
}
private void winformsMap1_MouseMove(object sender, MouseEventArgs e)
{
ScreenPointF lastMouseMove = new ScreenPointF(e.X, e.Y);
PointShape mouseLocation = ExtentHelper.ToWorldCoordinate(winformsMap1.CurrentExtent, lastMouseMove, winformsMap1.Width, winformsMap1.Height);
//update the world location on screen
lblWorldPos.Text = string.Format(CultureInfo.InvariantCulture, "({0}, {1})", mouseLocation.X.ToString("N5", CultureInfo.InvariantCulture), mouseLocation.Y.ToString("N5", CultureInfo.InvariantCulture));
}
Ric