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

When Broweser scroll down ImageToWorld() function retunes different coordinates for same point.

Topics: Algorithms, Web Controls
Sep 27, 2007 at 6:03 AM
I am developing Sharp map application using raster Image( SharpMap.Layers.GdalRasterLayer) . But When browser scroll down or image move ImageToWorld() function retunes different values.

I am using AJAX MAP With Following code

function MapClicked(event,obj)
var mousePos = SharpMap_GetRelativePosition(event.clientX,event.clientY,obj.container);
var pnt = SharpMap_PixelToMap(mousePos.x,mousePos.y,obj);
var field = document.getElementById('dataContents');
field.innerHTML = "You clicked map at: " + pnt.x + "," + pnt.y;

// Call AJAX methord and it will call to ImageToWorld(pnt) But it will return different value for same point.

Sep 27, 2007 at 7:42 AM
There are two errors in this:

First of all, your extent on the serverside has to fit with the extent of the clientside, and the ajaxmap doesn't any of this syncronization. Set the server's extent and width/height to that of the client to make it return correct values.

The second problem is that you parse in a map coordinate to ImageToWorld, which expects a screen coordinate (you just converted it from screen using PixelToMap didn't you, so why not just use this?).
Basically Map.ImageToWorld is on the server what SharpMap_PixelToMap is on the client. Why would you even want to convert it on the server, when you already know the map coordinate?
Sep 27, 2007 at 8:44 AM
Thanks for the reply.
Initially I used PixelToMap method to convert coordinates. But basic issue I have is when browser scroll down or move image it will provide deferent coordinate for same point in time to time . What is the reason for this. How to avoid? Please explain me.
Sep 27, 2007 at 1:07 PM

Check out this work item:
Sep 27, 2007 at 5:13 PM
Thanx for the reply. But This will not provide solution to my problem .

Can you explain me withthis code how to find a solution to my issue.

Any after this chages image become very clear.
Sep 27, 2007 at 5:16 PM
Did you try the patch? The SharpMap source code does not handle rasters well at all. If you try zooming or panning on an image, the coordinates get all messed up.

The patch in that link fixes many problems with rasters.
Sep 27, 2007 at 5:39 PM
Sorry ti disturb you I try with your patch and sedn u previous mail.

Can you sedn out smaple code to with GDAL raster exampale for AJAX MAP . or post code here
Sep 29, 2007 at 4:59 AM
Hi Dan

I try with patch . No solution yet. Can you provide me sample code. please