WorldToImage point outside of image

Topics: SharpMap Project
Nov 12, 2009 at 3:19 AM

I am trying to get the X/Y coordinates of a Latitude/Longitude using the 'WorldToImage' function.

I have created a map with the width and height of the image i want to draw on.  I have then centered the map in the middle of my latitude/longitude coordinates

I then call the WorldToImage function. 

The point I get from this is: X = 7662.661 and Y = -7589.42725 which does not fit onto my image.

Dim dMinLat As Double = -34.8341700000001
Dim dMaxLat As Double = -22.1250299999992
Dim dMinLong As Double = 16.4518900000003
Dim dMaxLong As Double = 32.94499
Dim dLat As Double = -25.2885299999998
Dim dLong As Double = 28.7395899999992

Dim map As SharpMap.Map
Dim pnt As PointF

map = New SharpMap.Map(New Drawing.Size(2076, 1600))
map.Center = New SharpMap.Geometries.Point(dMinLat + ((dMaxLat - dMinLat) / 2), _
                                                 dMaxLong - ((dMaxLong - dMinLong) / 2))

pnt = map.WorldToImage(New SharpMap.Geometries.Point(dLat, dLong))


Can anyone tell me what is wrong with my code example.


Dec 2, 2009 at 1:07 PM

You also need to set the map's zoom level.  In this case it should probably be: map.Zoom = 2076