1

我有下一个 XAML:

<maps:Map x:Name="MyMap"  HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Height="410" Width="436" CartographicMode="Hybrid">
            <toolkit:MapExtensions.Children>
                <toolkit:Pushpin Visibility="Collapsed" x:Name="pushpin" Content="My Position"/>
            </toolkit:MapExtensions.Children>
        </maps:Map>

这是我的 C# 代码:

string[] tmp = result.ToString().Split(' ');
        MyMap.Center = new GeoCoordinate(double.Parse(tmp[0]), double.Parse(tmp[1]));
        MapLayer layer0 = new MapLayer();
        Pushpin pushpin0 = new Pushpin();
        pushpin0.Visibility = Visibility.Visible;
        pushpin0.GeoCoordinate = new GeoCoordinate(double.Parse(tmp[0]), double.Parse(tmp[1]));
        MapOverlay overlay0 = new MapOverlay();
        overlay0.Content = pushpin0;
        overlay0.GeoCoordinate = new GeoCoordinate(double.Parse(tmp[0]), double.Parse(tmp[1]));
        layer0.Add(overlay0);

我的图钉没有显示在地图上,我在这里缺少什么?

4

2 回答 2

1

我相信您忘记将图层添加到地图中:

MyMap.Layers.Add(layer0);
于 2013-08-30T08:24:36.580 回答
0

请参阅以下链接 http://mendez.quora.com/Working-with-Pushpins-and-Maps-in-Windows-Phone-8 祝你好运

于 2013-08-30T09:06:30.023 回答