Windows Phone 8.1中的多个图钉 [英] Muliple Pushpins in Windows Phone 8.1

查看:57
本文介绍了Windows Phone 8.1中的多个图钉的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用MapControl显示地图.我也有MapServiceToken.我使用MapIcon添加了自定义图钉,并将此对象分配给Map.一切正常. 但是,当我尝试使用相同的场景添加多个图钉并将其分配给地图时,我就在地图上获取了最后一个图钉.其他图钉的其余部分将不可见. 请告诉我有关此问题的任何简单解决方案.谢谢

I am using MapControl to display map. I have MapServiceToken too. I have added custom pushpin using MapIcon and assigned this object to Map. It is working fine. But when i try to add multiple pushpins using same scenario and assign it to map so i am getting last pushpin on the map. Rest of other pushpins are not getting visible. Kindly tell me any simple solution to this problem. Thanks

推荐答案

您可以在没有MapIcon的情况下在地图上绑定图钉.

You can binding your pushpins on map without MapIcon.

添加xaml

<Maps:MapControl x:Name="MapLocationsControl" MapServiceToken="add your token here">
        <Maps:MapItemsControl x:Name="mapitem">
            <Maps:MapItemsControl.ItemTemplate>
                <DataTemplate>

                        <Image Height="50" Width="50"
                               Source="{Binding image,Mode=OneWay}"
                       Maps:MapControl.Location="{Binding Geopoint}"/>

                </DataTemplate>
            </Maps:MapItemsControl.ItemTemplate>
        </Maps:MapItemsControl>
    </Maps:MapControl>

在MapControl源代码中的c#绑定项中

And in c# binding items in MapControl source

 mapitem.ItemsSource = items;

其中项目是可观察到的MapItems类项目的集合.您可以使用Add()添加项目.

Where items is observable collection with MapItems class items. You can add items with Add().

ObservableCollection<MapItem> items = new ObservableCollection<MapItem>();

items.Add(new MapItem(lat,lng, "Assets/pushpinicon.png"));

MapItem类就是这样

MapItem Class is like this

public class MapItem {

public Geopoint Geopoint { get; set; }

public string image {get; set;}

    public MapItem(double lat , double lng , string img)
    {

        Geopoint = new Geopoint(new BasicGeoposition() { Latitude = lat, Longitude = lng });

        image=img;
     }
}

这篇关于Windows Phone 8.1中的多个图钉的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆