-1

I am working on offline map using MapWinGIS in C# where i am successfully able to draw map based on latitude and longitude.

working

    axMap1.Latitude = 60.1282f;
    axMap1.Longitude = 18.6435f;
    axMap1.CurrentZoom = 10;

Not Working

axMap1.Latitude = Textbox1.Text;

How to achieve this

Thank you !

1 Answers1

0

Looks like your map is taking a float value for Latitude etc. so you need to change type on the string you get from the text field to float. Best way is to use float.TryParse for that as if it fails you'll want to handle that.

Depends a little bit on which framework you're on but something like this should work.

if (float.TryParse(Textbox1.Text, out var result)){
    axMap1.Latitude = result;
}
Moriya
  • 7,750
  • 3
  • 35
  • 53
  • Thanks for the reply Moriya ! I am using .NET Framework 4.5 and i tired your code but it is showing error "var does not exist in the current context" – KADAR KHAN Jan 15 '20 at 14:15
  • when i am trying without "var" the program executing successfully but it failed to store "Textbox1.Text" value to "result" – KADAR KHAN Jan 15 '20 at 14:22
  • Define the variable before entering the TryParse. Just google tryparse and I’m sure you’ll find examples – Moriya Jan 15 '20 at 16:05