【发布时间】:2014-10-20 04:44:40
【问题描述】:
我不确定单击地图标记/图钉时弹出的小窗口的术语,但我想在这个临时窗口中使用我的 Bing 地图图钉做的是在它是点击/点击:
My Dog Spot - miPerroMancha.png
{ the thumbnail here }
5/29/2013
elAmadoDeFresno.png
{ the thumbnail here }
10/19/2014
IOW,“弹出”应该显示:
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 地图的名称; 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 地图直接相关,但由于单击图钉而被调用,它将从该位置弹出(弹出窗口的左上角/图钉中间的不受限制的弹出窗口)
更新 2
我浏览了您的文章博客。这似乎是一种享受,除了一件事:弹出的信息框是深灰色的,没有显示任何数据:
我确实对代码做了一些改动,使用了一个字符串和一个日期时间,而不是两个字符串:
// 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)
【问题讨论】:
标签: html windows-store-apps bing-maps