我想使用Bing Map SDK和控件將地圖添加到Windows 8商店應用程序。有了這一套的XAML:Bing地圖MapItemsControl拋出E_FAIL異常設置圖釘位置
<Page.Resources>
<DataTemplate x:Key="LogoTemplate">
<m:Pushpin m:MapLayer.Position="{Binding Item2}" Text="{Binding Item1}"/>
</DataTemplate>
</Page.Resources>
...
<m:Map Credentials="{StaticResource BingMapsApiKey}" ZoomLevel="12" HomeRegion="US" Heading="2">
<m:MapItemsControl x:Name="ListOfItems"
ItemTemplate="{StaticResource LogoTemplate}"
ItemsSource="{Binding LocationList}">
</m:MapItemsControl>
</m:Map>
綁定到該物業的視圖模型:
public IEnumerable<Tuple<string, Bing.Maps.Location>> LocationList
{
get
{
if (MapLocation != null)
{
return new List<Tuple<string, Bing.Maps.Location>>
{
new Tuple<string, Bing.Maps.Location>("1", new Bing.Maps.Location(MapLocation.lat, MapLocation.lng))
};
}
return Enumerable.Empty<Tuple<string, Bing.Maps.Location>>();
}
}
它始終與來自Bing地圖COM組件的E_FAIL HResult
節選。在調試器輸出窗口中輸入以下消息:
WinRT information: Failed to assign to property 'Bing.Maps.MapLayer.Position'
Lat和Long是有效點。我很難過,看不出有什麼不同。 Interwebs關於Bing Maps控件的App Store版本的信息非常少,所以希望有人能夠實現這一點。