简体   繁体   中英

How to take textbox values to MapWinGIS axMap1.Latitude function in C#

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 !

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;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM