Hi Ethan,
tetikusGerak_Loaded is the mousemove_Loaded i will change the name function to mousemove_loaded. I will put all the projection code in the map loaded function. Supposedly the code for the : PointShape pointShape = ExtentHelper.ToWorldCoordinate(Map1.CurrentExtent, screenPointF, (float)Map1.Width, (float)Map1.Height);
into the mouse move function right?
I try it just now but it still throw the exception on the following code:
PointShape pointShape = ExtentHelper.ToWorldCoordinate(Map1.CurrentExtent, screenPointF, (float)Map1.Width, (float)Map1.Height);
This mean the map width and height can’t retrieve the correct value from the map loaded function right? The code for the longitude and latitude with mouse move function can’t be put on the map loaded ?
Overall Code
private void Map_Loaded(object sender, RoutedEventArgs e)
{
Map1.MapUnit = GeographyUnit.Meter;
LayerOverlay myOverlay = new LayerOverlay();
Map1.Overlays.Add(myOverlay);
myOverlay.TileCache = new FileBitmapTileCache(@"C:\Users\User\Documents\Visual Studio 2012\Projects\RasterMapViewer\RasterMapViewer\Cache\");
string[] files = System.IO.Directory.GetFiles(@"C:\Users\User\Documents\Visual Studio 2012\Projects\RasterMapViewer\RasterMapViewer\Data\");
foreach (string file in files)
{
GeoTiffRasterLayer tiffLayer = new GeoTiffRasterLayer(file);
myOverlay.Layers.Add(tiffLayer);
}
myOverlay.Open();
Map1.CurrentExtent = myOverlay.GetBoundingBox();
myOverlay.Close();
Proj4Projection proj4Projection = new Proj4Projection();
proj4Projection.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(3375);
proj4Projection.ExternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326);
proj4Projection.Open();
Vertex projVertex = proj4Projection.ConvertToExternalProjection(747032, 1297787);
proj4Projection.Close();
}
private void mouseMove_Loaded(object sender, MouseEventArgs e)
{
Point point = e.MouseDevice.GetPosition(null);
ScreenPointF screenPointF = new ScreenPointF((float)point.X, (float)point.Y);
PointShape pointShape = ExtentHelper.ToWorldCoordinate(Map1.CurrentExtent, screenPointF, (float)Map1.Width, (float)Map1.Height);
TextBoxSatu.Text = "X: " + DecimalDegreesHelper.GetDegreesMinutesSecondsStringFromDecimalDegree(pointShape.X) +
" Y: " + DecimalDegreesHelper.GetDegreesMinutesSecondsStringFromDecimalDegree(pointShape.Y);
}
}