gpt4 book ai didi

c# - 在 Windows 8/Bing map 应用程序中绘制坐标

转载 作者:太空宇宙 更新时间:2023-11-03 11:14:46 25 4
gpt4 key购买 nike

我正在使用 Bing map 制作 C#/XAML Windows 8 应用程序。我正在复制一堆 Windows Phone 7 代码,但我在绘制地理坐标时遇到了问题。这是 WP7 代码:

GeoCoordinate mapCenter = new GeoCoordinate(37.784, -122.408);
map1.Center = mapCenter;

但是,当我尝试在 Win 8 中实例化 mapCenter 时(我确实使用小写 Geocoordinate 而不是 GeoCoordinate)我收到一条错误消息,指出“Windows.Devices.Geolocation.Geocoordinate 不包含采用 2 个参数的构造函数” .

我有点难过,因为我计划大量使用 Geocoordinates,而且我不太确定如何弄清楚 Geocoordinate 构造函数究竟需要什么。

谢谢,

阿曼达

编辑以修复代码缩进

最佳答案

Windows.Devices.Geolocation.Geocoordinate 类不能直接实例化。另外请记住,您使用的命名空间专门用于从设备检索位置数据。

首先,您需要通过Geolocator.GetGeopositionAsync 获取Geoposition 实例。 .

然后您可以从 Geoposition.Coordinate 获取 Geocoordinate 实例。

如果您希望简单地将 map 居中放置在给定的经度和纬度上(并且您正在使用 Bing Maps for Windows Store Apps SDK),看起来您应该使用 Location类(因为 Map.Center 属于 Location 类型)。

关于c# - 在 Windows 8/Bing map 应用程序中绘制坐标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12984467/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com