I’m making a C#/XAML Windows 8 app using Bing Maps. I’m copying a bunch of Windows Phone 7 code over, and I’m having a problem simply plotting geocoords. Here’s the WP7 code:
GeoCoordinate mapCenter = new GeoCoordinate(37.784, -122.408);
map1.Center = mapCenter;
However, when I try to instantiate mapCenter in Win 8, (and I do use lowercase Geocoordinate instead of GeoCoordinate) I get an error saying that “Windows.Devices.Geolocation.Geocoordinate does not contain a constructor that takes 2 arguments”.
I’m sorta stumped, as I planned on using Geocoordinates quite a bit, and I’m not really sure how to figure out what exactly the Geocoordinate constructor takes.
thanks,
Amanda
Edited to fix code indentation
The
Windows.Devices.Geolocation.Geocoordinateclass cannot be directly instantiated. Also, keep in mind, that the namespace you are using is used specifically for retrieving location data from the device.First, you’ll need to get an instance of
GeopositionviaGeolocator.GetGeopositionAsync.You can then get the
Geocoordinateinstance fromGeoposition.Coordinate.If you’re looking to simply center the map on a given latitude and longitude (and you’re using the Bing Maps for Windows Store Apps SDK), it looks like you should be using the
Locationclass instead (asMap.Centeris of typeLocation).