简体   繁体   中英

c# Windows Phone 8.1 How to get Geocoordinate object

I need to get Geocoordinate object with my Longitude and Latitude. Cannot get Geocoordinates by new() https://msdn.microsoft.com/en-us/library/windows/apps/windows.devices.geolocation.geocoordinate One way is for example this code

var locator = new Geolocator();
        locator.DesiredAccuracyInMeters = 50;
        var position = await locator.GetGeopositionAsync();
        Geocoordinate Coordinate = position.Coordinate;

Which gets GPS coordinate. But I need Geocoordinate with my Longitude and Latitude.

You cannot create a Geocoordinate since it is a sealed, read-only class. Instead, bind to a Geopoint , which contains all the location info you need without the location service baggage that Geocoordinate has.

public Geopoint Location { get; set; }

Maps:MapControl.Location="{Binding Location}"

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