而不是像这样的坐标:纬度:99,9999397213696,经度:99,9999990115402 我想得到这样的东西:Lat 99.9999 lon 99.9999。
如何使地理位置更短/数值不太准确?
var request = new GeolocationRequest(GeolocationAccuracy.Medium);
var location = await Geolocation.GetLocationAsync(request);
答案 0 :(得分:0)
如果要将数字显示为字符串,可以使用格式化程序:
var latString = $"Lat {location.Latitude:N4}";
N4
是string formatter的地方,有很多变化。
如果您实际上想舍入double值,则可以使用Math.Round
:
var rounded = Math.Round(location.Latitude, 4);
4
是您想要的小数位数。