This project has moved. For the latest updates, please go here.

ImageToWorld - returns incorrect x/y coords

Topics: SharpMap v0.9 / v1.x
Feb 16, 2011 at 12:51 PM



I have a web system that uses the imagebutton as a map (imgMap)

I am using LO31 - Hartebeesthoek94

The roads and aerial photos all seem to load ok and are aligned, but when I click on a point it does not return the correct x/y coords.

I have the following code to define the Map

Private shMap as new SharpMap.Map

Dim size as new System.Drawing.Size(Cint(imgMap.Width.Value), Cint(imgMap.Height.Value))

shMap = InitializeMap(size, GISRdCode etc

This uses the size of the imgMap to do the following in the InitializeMap routine

Dim Map as new SharpMap.Map(Size)  and then all the layers are loaded

 When I click on a point on the Map I do the following in the imgMap_Click event

 Dim ClickPt as new SharpMap.Geometries.Point

 ClickPt = shMap.ImageToWorld(New System.Drawing.PointF(e.X,e.Y))

I display the coords of ClickPt. They are x= 2931; y=-3302249 when in fact the correct coords are x=2897; y = -3302216 (i got these from another GIS package)

I am not sure what I am doing wrong - please can someone help. I think that the way I have coded this means that the X/Y Coords of the image click are based on imgMap and not the Control Panel that it is in on the Web Page




Feb 16, 2011 at 2:45 PM

I have moved my Imagebutton right to the left and top of the page, but am still getting the wrong coords

Feb 17, 2011 at 9:07 AM
Edited Feb 17, 2011 at 9:29 AM

Hello colleen,

are you sure you have the right click point in regard to the mapimage? Maybe you need to subtract the mapimage offset.

Hth FObermaier

Feb 17, 2011 at 12:12 PM

This is really strange - I am working in using VS2010 - and was running the map in the development environment when I got the above error. I decided to install the application on the server and run it as a web app. When I run it through IE ON THE SERVER MACHINE then ImageToWorld returns the correct co-ordinates, but as soon as I run it from my machine as a web app, it returns the incorrect coords - does anyone know who to fix this - thanks

Feb 17, 2011 at 1:27 PM

OK, I've sorted this out. I had large fonts set on my screen - when I set this to nomal font then the x/y co-ordinates return correctly - not sure why this causes the problem