C# 如何在地图控件中显示多个位置(windows phone 8.1)

C# 如何在地图控件中显示多个位置(windows phone 8.1),c#,json,google-maps,windows-phone-8.1,bing-maps,C#,Json,Google Maps,Windows Phone 8.1,Bing Maps,我正在尝试在WindowsPhone8.1中开发一个带有地图控件的应用程序。GooglePlaceAPI用于以Json格式获取附近的位置。现在,如何在windows phone应用程序中将它们显示到我的地图控件 当我提取Json格式时,我得到了以下类 public class Location { public double lat { get; set; } public double lng { get; set; } } publ

我正在尝试在WindowsPhone8.1中开发一个带有地图控件的应用程序。GooglePlaceAPI用于以Json格式获取附近的位置。现在,如何在windows phone应用程序中将它们显示到我的地图控件

当我提取Json格式时,我得到了以下类

 public class Location
    {
        public double lat { get; set; }
        public double lng { get; set; }
    }

    public class Northeast
    {
        public double lat { get; set; }
        public double lng { get; set; }
    }

    public class Southwest
    {
        public double lat { get; set; }
        public double lng { get; set; }
    }

    public class Viewport
    {
        public Northeast northeast { get; set; }
        public Southwest southwest { get; set; }
    }

    public class Geometry
    {
        public Location location { get; set; }
        public Viewport viewport { get; set; }
    }

    public class OpeningHours
    {
        public bool open_now { get; set; }
        public List<object> weekday_text { get; set; }
    }

    public class Photo
    {
        public int height { get; set; }
        public List<string> html_attributions { get; set; }
        public string photo_reference { get; set; }
        public int width { get; set; }
    }

    public class Result
    {
        public Geometry geometry { get; set; }
        public string icon { get; set; }
        public string id { get; set; }
        public string name { get; set; }
        public string place_id { get; set; }
        public string reference { get; set; }
        public string scope { get; set; }
        public List<string> types { get; set; }
        public string vicinity { get; set; }
        public OpeningHours opening_hours { get; set; }
        public List<Photo> photos { get; set; }
        public double? rating { get; set; }
    }

    public class RootObject
    {
        public List<object> html_attributions { get; set; }
        public string next_page_token { get; set; }
        public List<Result> results { get; set; }
        public string status { get; set; }
    }
公共类位置
{
公共双lat{get;set;}
公共双精度{get;set;}
}
公共课东北
{
公共双lat{get;set;}
公共双精度{get;set;}
}
西南公务舱
{
公共双lat{get;set;}
公共双精度{get;set;}
}
公共类视口
{
公共东北{get;set;}
公共西南西南{get;set;}
}
公共课几何
{
公共位置位置{get;set;}
公共视口{get;set;}
}
公共课开放时间
{
公共bool open_now{get;set;}
公共列表工作日_text{get;set;}
}
公开课照片
{
公共整数高度{get;set;}
公共列表html_属性{get;set;}
公共字符串photo_引用{get;set;}
公共整数宽度{get;set;}
}
公开课成绩
{
公共几何体{get;set;}
公共字符串图标{get;set;}
公共字符串id{get;set;}
公共字符串名称{get;set;}
公共字符串place_id{get;set;}
公共字符串引用{get;set;}
公共字符串作用域{get;set;}
公共列表类型{get;set;}
公共字符串{get;set;}
公共开放小时开放时间{get;set;}
公开列表照片{get;set;}
公共双重评级{get;set;}
}
公共类根对象
{
公共列表html_属性{get;set;}
公共字符串下一页标记{get;set;}
公共列表结果{get;set;}
公共字符串状态{get;set;}
}
所以我想用图钉显示地图控件中的每个位置


在几何学中,我们有纬度值和逻辑度值。如何将它们放置在我的地图控件中

我认为您应该从观看本教程开始

我认为您应该从观看本教程开始

您必须执行类似的操作,首先创建两个列表,然后像这样将位置传递给它

        public List<string> longt = new List<string>();
        public List<string> lati = new List<string>();
public List long=new List();
公共列表lati=新列表();
然后循环在地图上显示许多图标,就像这样

for (i = 0; i <=t.Longitudelist.Count-1 ; i++)
            {

                MapIcon mapIcon1 = new MapIcon();
                string latitudetxt;
                string longitudetxt;
                latitudetxt = t.Latitudelist[i].Text;
                longt.Add(latitudetxt);
                longitudetxt = t.Longitudelist[i].Text;
                lati.Add(longitudetxt);
                // mapIcon1.Image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/StoreLogo.png"));
                mapIcon1.Location = new Geopoint(new BasicGeoposition()
                {

                   Latitude = Convert.ToDouble(longt[i]),
                   Longitude = Convert.ToDouble(lati[i])
                });
               // mapIcon1.Image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/StoreLogo.png"));
                mapIcon1.NormalizedAnchorPoint = new Point(0.5, 0.5);
                Map.MapElements.Add(mapIcon1);

                var bt = new Button();
                buttonn.Add(bt);
                bt.Content = "";
                bt.Width = 30;
                bt.Height = 50;
                bt.Opacity = 10;
                bt.Content = i;
                 // button.
                this.Map.Children.Add(bt);
                // assign geoposition
                var position = new Geopoint(new BasicGeoposition()
                {
                    Latitude = Convert.ToDouble(longt[i]),
                    Longitude = Convert.ToDouble(lati[i])

                });
                MapControl.SetLocation(buttonn[i], position);
                var pointt=MapControl.GetLocation(bt);
                pointt.Position.Latitude.ToString();
                pointt.Position.Longitude.ToString();
                //longg= position.Position.Latitude;
                //latt = position.Position.Longitude;
              //  button.Tag = longg;

                MapControl.SetNormalizedAnchorPoint(bt, new Point(0.5, 0.5));
                MapControl.SetIsTemplateFocusTarget(bt, true);

                bt.Click += Button_Click;

                await Map.TrySetViewAsync(mapIcon1.Location, 18D, 0, 0, MapAnimationKind.Bow);

            }

for(i=0;i你必须这样做,首先制作两个列表,并像那样将位置传递给它

        public List<string> longt = new List<string>();
        public List<string> lati = new List<string>();
public List long=new List();
公共列表lati=新列表();
然后循环在地图上显示许多图标,就像这样

for (i = 0; i <=t.Longitudelist.Count-1 ; i++)
            {

                MapIcon mapIcon1 = new MapIcon();
                string latitudetxt;
                string longitudetxt;
                latitudetxt = t.Latitudelist[i].Text;
                longt.Add(latitudetxt);
                longitudetxt = t.Longitudelist[i].Text;
                lati.Add(longitudetxt);
                // mapIcon1.Image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/StoreLogo.png"));
                mapIcon1.Location = new Geopoint(new BasicGeoposition()
                {

                   Latitude = Convert.ToDouble(longt[i]),
                   Longitude = Convert.ToDouble(lati[i])
                });
               // mapIcon1.Image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/StoreLogo.png"));
                mapIcon1.NormalizedAnchorPoint = new Point(0.5, 0.5);
                Map.MapElements.Add(mapIcon1);

                var bt = new Button();
                buttonn.Add(bt);
                bt.Content = "";
                bt.Width = 30;
                bt.Height = 50;
                bt.Opacity = 10;
                bt.Content = i;
                 // button.
                this.Map.Children.Add(bt);
                // assign geoposition
                var position = new Geopoint(new BasicGeoposition()
                {
                    Latitude = Convert.ToDouble(longt[i]),
                    Longitude = Convert.ToDouble(lati[i])

                });
                MapControl.SetLocation(buttonn[i], position);
                var pointt=MapControl.GetLocation(bt);
                pointt.Position.Latitude.ToString();
                pointt.Position.Longitude.ToString();
                //longg= position.Position.Latitude;
                //latt = position.Position.Longitude;
              //  button.Tag = longg;

                MapControl.SetNormalizedAnchorPoint(bt, new Point(0.5, 0.5));
                MapControl.SetIsTemplateFocusTarget(bt, true);

                bt.Click += Button_Click;

                await Map.TrySetViewAsync(mapIcon1.Location, 18D, 0, 0, MapAnimationKind.Bow);

            }

for(i=0;i)有多个位置。我想在我的地图控件中显示几何类->位置->纬度和逻辑度值中存在的所有位置,视频向您展示如何在地图上添加项目。您还需要什么?而不是整个粘贴教程(链接),唯一最好的解决方案可能更好这里有多个位置。我想在我的地图控件中显示几何类->位置->纬度和逻辑度值中存在的所有位置。视频向您展示如何在地图上添加项目。您还需要什么?而不是整个粘贴教程(链接),只有最好的解决方案可能更好