2013-02-21 82 views
0

我有一个Windwows Phone应用程序,允许用户在地图上看到他通过扫描qr码获取的初始位置。当用户扫描Qr代码时,他会获取存储在Web服务器中的地图的URL以及其初始位置的X和Y坐标。如何将标记添加到Windows Phone上的.png地图图像?

我在的.xaml页面中创建地图图像的容器:

<Image x:Name="ImagePanel" Width="470" Margin="5,0,5,98" Grid.Row="1" /> 

在页面的.cs,我下载的地图图像从服务器:

public void DownloadImage(string URLmappa) 
    { 

     ImagePanel.Source = new BitmapImage(new Uri(URLmappa)); 

     WebClient wc = new WebClient(); 
     wc.OpenReadCompleted += new OpenReadCompletedEventHandler(wc_OpenReadCompleted); 

     try 
     { 

      wc.OpenReadAsync(new Uri(URLmappa), wc); 

     } 

     catch (Exception ex) 
      { 
       MessageBox.Show(ex.Message); 
      } 

    } 


    void wc_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e) 
      { 
       if (e.Error == null && !e.Cancelled) 
       { 
        try 
        { 
        BitmapImage image = new BitmapImage(); 
        image.SetSource(e.Result); 
        ImagePanel.Source = image; 
        } 
        catch (Exception ex) 
        { 
         MessageBox.Show(ex.Message); 
        } 
       } 
       else 
       { 
        MessageBox.Show("It's impossibile to download map from server"); 
       } 

        } 

...和它的作品但困难的部分是在图像上标记位置(报告)。

我找到了这样的事情:

public void MarkLocation(int posizioneX, int posizioneY) 
    { 
var imageMarker = new System.Web.UI.WebControls.Image { ImageUrl = "/pin.jpg" }; 
imageMarker.Style.Value = string.format("position:absolute;top:{0}px;left:{1}px;display:block;width:30px; height:30px;", point.X, point.Y); 
imagePanel.Controls.Add(imageMarker); } 

但它并不在Windows Phone上运行。

我对如何在给定X,Y坐标的图像上标记位置的建议感兴趣。

替代方法将不胜感激。

回答

0

您可以将图像放置在画布上,并在您尝试使用Web控件时完全放置标记元素。或者,您可以使用WriteableBitmapEx

+0

非常感谢您在图像上写下标记。我会遵照你的建议。 – Flanders 2013-02-24 16:57:55

相关问题