【问题标题】:WP8 map overlay out of range errorWP8 地图覆盖超出范围错误
【发布时间】:2017-03-14 20:43:14
【问题描述】:

我有以下问题。我编写这个函数是为了在适用于 Windows Phone 8 的 Silverlight C# 应用程序上将一些图像作为图标添加到我的地图中。

private void SpecialMapIcons()
{
    MapLayer layer = new MapLayer();
    List<string[]> SpecialIcons = new List<string[]>();

    SpecialIcons.Add(new string[] { "icon0.png", "52.5", "13.5" });
    SpecialIcons.Add(new string[] { "icon1.png", "52.4", "13.4" });

    for (int i = 0; i < SpecialIcons.Count; i++)
    {
        string[] Icons = SpecialIcons[i];

        MapOverlay overlay = new MapOverlay()
        {
            GeoCoordinate = new GeoCoordinate(Convert.ToDouble(Icons[1]), Convert.ToDouble(Icons[2])),
            Content = new Image
            {
                Source = new BitmapImage(new Uri("/Assets/icon/" + Icons[0], UriKind.Relative)),
                Width = 50,
                Height = 50,
                VerticalAlignment = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center
            }
        };
        layer.Add(overlay);
    }
    Map.Layers.Add(layer);
}

在模拟器上它工作得很好,但在设备上我总是得到一个超出范围的异常,在我创建覆盖的行上的 exapted 值为 -90 到 90:

MapOverlay overlay = new MapOverlay()

我不知道为什么会发生这种情况,也不知道这个值应该意味着什么。有没有人提示如何解决这个问题?

【问题讨论】:

    标签: c# windows silverlight windows-phone-8 outofrangeexception


    【解决方案1】:

    好的,我找到了问题,我不知道为什么,但模拟器上的 silvelight 可以使用

    Convert.ToDouble()

    功能但设备没有。那里:

    float.Parse(, System.Globalization.CultureInfo.InvariantCulture)

    必须使用函数。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多