WP8地图覆盖超出范围错误

时间:2016-11-01 16:48:37

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

我有以下问题。我写了这个Fnction,在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);
}

在模拟器上它工作得很好但是在设备上我总是得到一个超出范围的例外,在创建叠加层的行上有-90到90的值:

MapOverlay overlay = new MapOverlay()

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

1 个答案:

答案 0 :(得分:0)

好吧我发现了这个问题,我不知道为什么但是模拟器上的silvelight可以使用

Convert.ToDouble()

功能但设备没有。那里:

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

必须使用功能。

相关问题