shpar map maptoworld conversion problem-at low level zoom

Topics: SharpMap Project, SharpMap v0.9 / v1.x, SharpMap v2.0, Web Controls, WinForms Controls
Aug 2, 2011 at 7:04 AM

Hi frends.

When i am trying to convert map coordinates to world coordinates using maptoworld function.

I am not getting acurate lat and long values at low level zoom.

In case if i zoom the location to max and takes lat and long then its acurate.

public static Point MapToWorld(PointF p, Map map)        {                      

Point ul = new Point(map.Center.X - map.Zoom * .5, map.Center.Y + map.MapHeight * .5);                      

return new Point(ul.X + p.X * map.PixelWidth, ul.Y - p.Y * map.PixelHeight);       

}

i am calling this from aspx page, can you please help me regarding this

 

Coordinator
Aug 2, 2011 at 7:29 PM

could you try to be more specific?

what is low zoom level, where is the point, what is the result, what would the expected result be

cheers FObermaier

Aug 3, 2011 at 7:42 AM

Hi FObermaier

  Thanks for reply..

1)  I am trying to use sharpmap in aspx page.

<asp:ImageButton Width="800" Height="800" ID="imgMap" runat="server" OnClick="imgMap_Click"  style="border: 1px solid #000;" BorderColor="Brown" BorderWidth="10px" />

Initially map is launched by fitting to map area, with the help of "myMap.ZoomToExtents();"  method provided by sharpmap.

2) Now on click of map i am trying to get latitude and longitude using code

double longitude = RamcoMap.Utilities.Transform.MapToWorld(new System.Drawing.PointF(e.X, e.Y), myMap).X;         

 double latitude = RamcoMap.Utilities.Transform.MapToWorld(new System.Drawing.PointF(e.X, e.Y), myMap).Y;

3) If i place a marker at above position, marker is not showing at exact location on map ,where i clicked in step-2  (Marker is showing at some other place )

4) what ever lat and long i got in step-2 are not correct.

All the above scenario happening at initial fit of map , 

5)Now i am zooming the map to some street level 

6) Now if i repeat stpe-2 and step-3  , marker is displayed at correct position. Here latitude and longitude are correct

7) So if i zoom to max level , return values of "MapToWorld"  are more accurate that initial zoom.

My aim is, If i click on map i have to get exact lat and latitude at all zoom levels.

 

Hope this information is clear, In case any other further information is required pls let me know...

 

 

 

 

 

Coordinator
Aug 3, 2011 at 7:54 AM

Have you checked this thread?
http://sharpmap.codeplex.com/discussions/246276

Are you having the same problem?

Aug 3, 2011 at 8:19 AM

just now i have checked it.

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

what is meant my normal font, can you give little bit information.

and MapToWorld  returns latitude and longitude am i right

Coordinator
Aug 3, 2011 at 8:41 AM

With large fonts set, most of the windows, fonts and controls are scaled accordingly.
I know there have been some issues with some controlcontainers not beeing able to handle "Large Fonts" accordingly and thereby returning the wrong click-coordinates.

Can you verify that e.X and e.Y is 400,400 if you click in the center of your map when you have large font set.

 

Aug 3, 2011 at 10:31 AM

I have checked the center coordinates,its 400,400

Coordinator
Aug 3, 2011 at 10:36 AM

Ok, then SharpMap is not adopting its Transformation for Large Font settings, we'll have to look into that.