首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Bing地图MapItemsControl抛出E_FAIL异常设置图钉位置

Bing地图MapItemsControl抛出E_FAIL异常设置图钉位置
EN

Stack Overflow用户
提问于 2012-11-15 11:22:44
回答 2查看 624关注 0票数 0

我正在尝试使用Bing map SDK和控件将地图添加到Windows 8应用商店应用。使用这组Xaml:

代码语言:javascript
复制
<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>

绑定到视图模型的此属性:

代码语言:javascript
复制
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例外。调试器输出窗口中显示以下消息:

代码语言:javascript
复制
WinRT information: Failed to assign to property 'Bing.Maps.MapLayer.Position'

Lat和Long是有效点。我被难住了,看不出有什么不同之处。interwebs几乎没有关于App Store版本的必应地图控件的信息,所以我希望有人能让它工作。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-11-18 05:28:56

以防其他人遇到这个问题(或者在将此控件的windows store版本集成到MVVM模型时遇到困难),看起来解决方案是将控件包装在一个可绑定的版本中。到目前为止,我使用this code form codeplex取得了一些成功。

票数 0
EN

Stack Overflow用户

发布于 2014-10-26 18:36:30

根本不可能将MapLayer.Position数据绑定到Location对象,但是可以将LatitudeLongitude数据绑定

代码语言:javascript
复制
<m:Pushpin Text="{Binding Item1}"/>
    <m:MapLayer.Position>
        <m:Location Latitude="{Binding Item2.Latitude}" Longitude="{Binding Item2.Longitude}" />
    </m:MapLayer.Position>
</m:Pushpin>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13391102

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档