Getting location in Windows 8 desktop apps

前端 未结 2 1046
清酒与你
清酒与你 2021-01-06 10:44

I am a total beginner at C#, but I have used Java a lot. I am trying to use the following code in my app to get location data. I am making a Windows 8 desktop app to use the

2条回答
  •  既然无缘
    2021-01-06 11:01

    alex's solution works! add that reference and geolocation api starts working like a charm! so do async methods for other sensors!

    here is a function i just got working using it.

    async public void UseGeoLocation()
    {
        Geolocator _GeoLocator = new Geolocator();
        Geoposition _GeoPosition = 
            await _GeoLocator.GetGeopositionAsync();
    
        Clipboard.Clear();
        Clipboard.SetText("latitude," + 
            _GeoPosition.Coordinate.Latitude.ToString() + 
            "," + "longitude," + _GeoPosition.Coordinate.Longitude.ToString() + 
            "," + "heading," + _GeoPosition.Coordinate.Heading.ToString() +
            "," + "speed," + _GeoPosition.Coordinate.Speed.ToString());
    
        Application.Exit();
    }
    

提交回复
热议问题