View Full Version : Wrong answer from ConvertToLatLong

09-12-2002, 01:11 PM
I'll try to make this short and understandable.

I am trying to get the CORRECT lat/long points from a rendered image in a picturebox using the ConvertToLatLong function. As you mouse over (or click ) the X and Y of the picture box are passed into the "convert" function which then gives you the lat/long correspning to that point.

1. If I create a brand new MapView, choose a centerpoint and don't set any MapOptions I get the correct results.


2. If I set scale (or height & width) I get whacked out results. The same goes for zooming or panning (even after #1 above). So for example when my program first comes up I would like to see the US. So I create a new MapView and set the height and width at like 4000. I click on an area like Buffalo, NY which should give me (lat/long of 40s/-70s) and I get things in the (17s/-108s)

I have tried a NUMBER of different work arounds and I have read the documentation over and over. I just don't understand why it is messed up.

One thing I can say is if I run #1 and then zoom out say (3x) - I get the view of the US. My CenterPoints in both #1 and #1-zoom3 are the same,, my scale, height, width and ESPECIALLY Bounding Rectangle are all VERY different, BUT the only thing I have adjusted is the Zoom.

I hope someone can help me out. If I have not been clear, please let me know.

Thanks in advance.


Eric Frost
09-19-2002, 09:03 PM
Did you figure out the solution to your problem? There's a geodesy library on this site you might poke around:

Let us know if you figure it out..


09-20-2002, 03:18 PM
I did figure it out - after extensive testing it was user error.

I had switched X and Y in a function call, but what masked that as the fact was that when you were zoomed in close, it really didn't matter what the X and Y pixles were, you were looking at a SMALL difference in lat/long on a close zoom so it "seemed" like it was the ConvertFunction was working because you got "correct looking" results.

Only when the mapped was zoomed out did the difference in X,Y and Lat/Long manifest itself. With the X and Y switched I was getting very strange values when looking at a map zoomed out to say the "USA" level.