如何将图像添加到地图上的位置(Windows Phone 8)

时间:2014-01-22 12:09:24

标签: windows-phone-8

我正在效仿这个例子 Nokia blog但我的问题是,

1>我需要将图像添加到位置点而不是颜色

2 - ;我想在弹出窗口中显示详细信息,如谷歌地图

1 个答案:

答案 0 :(得分:1)

愿这对你有所帮助。 在这里,我使用textblock来显示自定义数据。堆栈面板的背景图像

      Private void ShoeCustomPushPuin()
{
            Pushpin pushPin = null;
            StackPanel stackPanel = null;
            TextBlock txtblkDownloadSpeed = null;
            TextBlock txtblkUploadSpeed = null;
            GeoCoordinate cordinates = null;

            try
            {
                cordinates = new GeoCoordinate();
                pushPin = new Pushpin();
                stackPanel = new StackPanel();
                txtblkDownloadSpeed = new TextBlock();

                txtblkUploadSpeed = new TextBlock();
                cordinates.Latitude = Your latitude value;
                cordinates.Longitude = your longitude value;
                txtblkUploadSpeed.Text = your data;
                txtblkDownloadSpeed.Text =your data;
                ImageBrush imgbrush= new ImageBrush
                    {
                ImageSource = new BitmapImage(new Uri("your background image path",     UriKind.Relative)),
            };

                stackPanel.Background = imgbrush;

                stackPanel.Children.Add(txtblkDownloadSpeed);
                stackPanel.Children.Add(txtblkUploadSpeed);
                pushPin.Content = stackPanel;
                pushPin.GeoCoordinate = cordinates;

                MapOverlay overlay = new MapOverlay
                {
                    GeoCoordinate = cordinates,
                    Content = pushPin
                };

                MapLayer layer = new MapLayer();
                layer.Add(overlay);
                mapHistory.Center = cordinates;
                mapHistory.Layers.Add(layer);
            }
            catch (Exception ex)
            {
            }
}