简体   繁体   English

如何在Windows Phone 8.1中的Bing地图上绑定MapIcon

[英]How to bind MapIcon on Bing Map in Windows Phone 8.1

I use the Bing Map on my Windows Phone 8.1 app. 我在Windows Phone 8.1应用程序上使用“必应地图”。 Precisally, in XAML file, I wrote 基本上,在XAML文件中,我写了

<Maps:MapControl x:Name="Map" Loaded="Map_Loaded">
    <Maps:MapItemsControl ItemsSource="{Binding Locations}">
        <Maps:MapItemsControl.ItemTemplate>
            <DataTemplate>
                <Image Source="Images/arte_icon_label.png"
                       Height="25"
                       Maps:MapControl.Location="{Binding Geopoint}"
                       Maps:MapControl.NormalizedAnchorPoint=".5,.5"/>
            </DataTemplate>
        </Maps:MapItemsControl.ItemTemplate>
    </Maps:MapItemsControl>
</Maps:MapControl>

I want to add many Images, but I don't know what is the code procedure to add theme. 我想添加许多图像,但是我不知道添加主题的代码过程是什么。

Can you help me please? 你能帮我吗?

Do you want to add multiple MapIcon with C# code? 您是否要使用C#代码添加多个MapIcon? I get this code snippet from following post . 我从下面的帖子中获得了此代码段。

private async Task SearchNearbyIncidents(Geopoint location)
{
    IList<Geopoint> geoPoints = await bingMapRestService.GetIncidents(MapUtil.GetBoundingBox(location.Position, 5), ConstantValues.BingMapKey);
    foreach (var geoPoint in geoPoints)
    {
        MapIcon mapIcon = new MapIcon
        {
            Image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/TrafficYield.png")),
            Location = geoPoint,
            NormalizedAnchorPoint = new Point(0.5, 0.5),
            Title = "Incidents"
        };
        mapControl.MapElements.Add(mapIcon);
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM