【问题标题】:how to add pushpins on map in windows phone 8.1如何在 Windows Phone 8.1 的地图上添加图钉
【发布时间】:2014-10-15 08:42:25
【问题描述】:

是否有任何教程或示例显示如何在 windows phone 8.1 中的地图上添加图钉 此代码不起作用:

MapIcon MapIcon1 = new MapIcon();
MapIcon1.Location = new Geopoint(new BasicGeoposition()
{
    Latitude = latitude,
    Longitude = -longitude
 });
 MapIcon1.NormalizedAnchorPoint = new Point(0.5, 1.0);
 RestoMap.MapElements.Add(MapIcon1);

【问题讨论】:

    标签: c# windows-phone-8.1 pushpin


    【解决方案1】:

    MapIcon 对象不保证显示在地图上,它们可能会被其他元素遮挡。

    如果您想放置始终可见的内容,请使用 XAML 控件: http://msdn.microsoft.com/en-us/library/windows/apps/xaml/dn792121.aspx#showing_xaml_controls_and_shapes_on_the_map

    【讨论】:

    • 此代码对于绑定位置是否正确: 位置 location = new Location(); location.Latitude = 纬度; location.Longitude = 经度;位置。添加(位置); } MapIcons.ItemsSource = this.locations;
    • @ahmad 我正在使用类似的代码,但 maps:MapControl.Location 需要绑定到 Geopoint 值。
    【解决方案2】:
     <Maps:MapItemsControl x:Name="MapIcons" >
        <Maps:MapItemsControl.ItemTemplate>
            <DataTemplate>
                 ........
                 .......
            </DataTemplate>
         </Maps:MapItemsControl.ItemTemplate>
     </Maps:MapItemsControl>
    
    class MapIcon
    {
       public String id { get; set; }
       public String name { get; set; }
       public String description { get; set; }
       public String picture { get; set; }
       public Geopoint MapLocation { get; set; }
    }
    
    funtion
    {
         Double latitude = item.latitude;
         Double longitude = item.longitude;
         Geopoint location = new Geopoint(new BasicGeoposition()
         {
            Latitude = latitude,
            Longitude = longitude,
         });
         MapIcon icon = new MapIcon() { MapLocation = location, name = name, picture = picture ,description = description};
         icons.Add(icon);
    }
    MapIcons.ItemsSource = icons;  
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多