|
|
using Microsoft.Maps.MapControl; private void Dynamic_Click(o bject sender, RoutedEventArgs e) { double latitude = 0; double longitude = 0; double.TryParse (tbLatitude.Tex t, out latitude); double.TryParse (tbLongitude.Te xt, out longitude); this.map.SetVie w(new Location(latitu de, longitude), 5); } when I input the latitude and longitude through two textboxes,and click the button, the view of map always location on a same and wrong position, why? help me,please ,thank u.
Usually when this is happening, the try parse is failing and your long and lat will be 0 or it could be a different number if the parse works but the default culture doesn't recognise the number as a double. This is normally because of regional settings in how doubles are handled in your operating system If you use the System.Globalization namespace and the following code double.TryParse (tbLatitude.Tex t,NumberStyles. Float,CultureIn fo.InvariantCul ture, out latitude); This should solve your issue. Also check what value is being outputted and if you are getting a true or false in the tryParse