是否有任何教程或示例显示如何在Windows Phone 8.1中的地图上添加图钉 此代码无效:
MapIcon MapIcon1 = new MapIcon();
MapIcon1.Location = new Geopoint(new BasicGeoposition()
{
Latitude = latitude,
Longitude = -longitude
});
MapIcon1.NormalizedAnchorPoint = new Point(0.5, 1.0);
RestoMap.MapElements.Add(MapIcon1);
答案 0 :(得分:2)
不保证MapIcon对象在地图上显示,它们可能被其他元素遮挡。
如果要放置始终可见的内容,请使用XAML控件: http://msdn.microsoft.com/en-us/library/windows/apps/xaml/dn792121.aspx#showing_xaml_controls_and_shapes_on_the_map
答案 1 :(得分:0)
<Maps:MapItemsControl x:Name="MapIcons" >
<Maps:MapItemsControl.ItemTemplate>
<DataTemplate>
........
.......
</DataTemplate>
</Maps:MapItemsControl.ItemTemplate>
</Maps:MapItemsControl>
class MapIcon
{
public String id { get; set; }
public String name { get; set; }
public String description { get; set; }
public String picture { get; set; }
public Geopoint MapLocation { get; set; }
}
funtion
{
Double latitude = item.latitude;
Double longitude = item.longitude;
Geopoint location = new Geopoint(new BasicGeoposition()
{
Latitude = latitude,
Longitude = longitude,
});
MapIcon icon = new MapIcon() { MapLocation = location, name = name, picture = picture ,description = description};
icons.Add(icon);
}
MapIcons.ItemsSource = icons;