如何将缩略图图像添加到Bing Map图钉的弹出/弹出窗口?

时间:2014-10-20 04:44:40

标签: html windows-store-apps bing-maps

我不确定点击地图标记/图钉时弹出的小窗口的术语,但是我想在这个暂时窗口中使用Bing Map图钉做什么就像这样显示它被点击/点击:

My Dog Spot - miPerroMancha.png
{ the thumbnail here }
5/29/2013

elAmadoDeFresno.png
{ the thumbnail here }
10/19/2014

IOW," popup"应该显示:

The image description, if available, plus file name; otherwise, just the file name, 
The thumbnail version of the photo
The date the photo was taken

标记将固定在拍摄照片的地图上

到目前为止,我所获得的代码如下所示。 photraxMap 是Bing Map的名称; pbd 是一个类,其中包含有关图钉所代表的照片的信息:

String fileNameOnly = Path.GetFileName(pbd.filePath);
Pushpin pushpin = new Pushpin();
if (null == pbd.imgDescription)
{
    pushpin.Text = fileNameOnly;
}
else
{
    pushpin.Text = String.Format("{0} - {1}", pbd.imgDescription, fileNameOnly);
}
MapLayer.SetPosition(pushpin, new Location(pbd.latitude, pbd.longitude));
photraxMap.Children.Add(pushpin);

因此,文本将与我想在弹出窗口/弹出窗口中首先显示的内容相同。

当推动/点击/敲击图钉时,当然可以利用什么显示器,但是如何? Intellisense并没有向我显示任何明显的方式。我希望图钉有一些我可以分配HTML的属性。我正朝着正确的方向看,还是咆哮着错误的树?

更新

如果这是不可能的,那么我可能需要的是一个弹出窗口(或一个"不受限制的弹出窗口"),它直接与Bing Map有关,但是由于点击了图钉,从那个位置弹出(弹出/不受限制的弹出的左上角在图钉中间)

更新2

我在你的文章博客上工作过。它似乎是一种享受,除了一件事:弹出的信息框是深灰色并且没有显示数据:

enter image description here

我确实稍微更改了代码,使用String和DateTime而不是两个字符串:

// The next few methods derived from http://rbrundritt.wordpress.com/2013/06/17/infoboxes-for-native-windows-store-apps/
private void CloseInfobox_Tapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e)
{
    Infobox.Visibility = Visibility.Collapsed;
}

// Does an inline class make the most sense here?
public class PushpinMetadata
{
    public string FileName { get; set; }
    public DateTime DateTimeTaken { get; set; }
    // TODO: Add a Bitmap for the Thumbnail
}

// TODO: Add the Bitmap/Thumbnail to the args and the class
public void AddPushpin(Location latlong, string fileName, DateTime dateTimeTaken,  MapLayer layer)
{
    Pushpin p = new Pushpin()
    {
        Tag = new PushpinMetadata()
        {
            FileName = fileName,
            DateTimeTaken = dateTimeTaken // add Thumbnail = thumbnail
        }
    };

    MapLayer.SetPosition(p, latlong);

    p.Tapped += PinTapped;

    layer.Children.Add(p);
}

private void PinTapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e)
{
    Pushpin p = sender as Pushpin;
    PushpinMetadata m = (PushpinMetadata)p.Tag;

    //Ensure there is content to be displayed before modifying the infobox control
    if (!String.IsNullOrEmpty(m.FileName) || (null != m.DateTimeTaken))
    {
        Infobox.DataContext = m;

        Infobox.Visibility = Visibility.Visible;

        MapLayer.SetPosition(Infobox, MapLayer.GetPosition(p));
    }
    else
    {
        Infobox.Visibility = Visibility.Collapsed;
    }
}

我是否需要坚持使用两个字符串,传递DateTime.ToString()?还是有其他问题吗?

更新3

我的不好 - 我没有更新的是XAML;我更改了类成员的名称,忘了更改XAML中的Binding语句。现在它可以工作了(除了位图 - 仍然不知道如何将其压入/将其从字节数组转换为BitmapImage)

1 个答案:

答案 0 :(得分:2)

看起来您正在尝试创建一个信息框(工具提示),它会在图钉上方显示一个面板并包含一些信息。这很容易做,这是我在博客和书中多次写过的。以下是关于执行此操作的博文:http://rbrundritt.wordpress.com/2013/06/17/infoboxes-for-native-windows-store-apps/

您可能对我创建位置智能Windows应用商店应用的免费电子书感兴趣。您可以在此处下载其副本:http://rbrundritt.wordpress.com/my-book/

相关问题