Win 8 App: Bing Maps Binding Location

六月ゝ 毕业季﹏ 提交于 2019-12-11 22:19:38

问题


I want to bind the Longitude and Latidute value from a Bing Map. But that doesn't work. if I code the values in the xaml it works fine. But with the binding the Map does not center.

Here is my example:

<Maps:Map ZoomLevel="7" x:Name="myMap" Credentials="my_Code">
                    <Maps:Map.Center>
                        <Maps:Location Latitude="{Binding Maps.Latitude}" Longitude="{Binding Maps.Longitude}" />
                    </Maps:Map.Center>
                    <Maps:Map.Children>
                        <Maps:Pushpin>
                            <Maps:MapLayer.Position>
                                <Maps:Location Latitude="{Binding Maps.Latitude}" Longitude="{Binding Maps.Longitude}" />
                            </Maps:MapLayer.Position>
                        </Maps:Pushpin>
                    </Maps:Map.Children>
                </Maps:Map>

The position is marked in the map but the map does not center the marked position. If I do this it works:

<Maps:Map ZoomLevel="7" x:Name="myMap" Credentials="my_Code">
                    <Maps:Map.Center>
                        <Maps:Location Latitude="25" Longitude="25" />
                    </Maps:Map.Center>
                    <Maps:Map.Children>
                        <Maps:Pushpin>
                            <Maps:MapLayer.Position>
                                <Maps:Location Latitude="{Binding Maps.Latitude}" Longitude="{Binding Maps.Longitude}" />
                            </Maps:MapLayer.Position>
                        </Maps:Pushpin>
                    </Maps:Map.Children>
                </Maps:Map>

回答1:


According to the documentation here: http://msdn.microsoft.com/en-us/library/hh846504.aspx

The Center property of the map dos not support data binding. I believe this was done on purpose as the center property changes frequently when the map moves and data binding can cause a lot of performance issues.



来源:https://stackoverflow.com/questions/23203968/win-8-app-bing-maps-binding-location

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!