诺基亚HERE地图绘制多个位置c#

时间:2014-07-27 12:35:46

标签: c# windows-phone-8 here-api

我正在使用c#和xaml开发Windows Phone 8应用程序。 我必须使用Nokia Here Map SDK绘制多个位置。 我有纬度,经度和头衔属性。

http://here.com/map=29.1491875,75.7216527,17/title=Fancy%20Stationers
http://here.com/map=29.1491875,75.7216527,17/title=Fancy%20Stationers
http://here.com/map=28.5415839,77.2550147,17/title=Future%20Forward
http://here.com/map=28.651879,77.187967,17/title=Hotline%20Communication
http://here.com/map=28.831140,77.074928,17/title=Jindal%20Agencies
http://here.com/map=28.7,77.14,17/title=Ace%20Communication
http://here.com/map=28.6904,76.9409,17/title=Cell%20Solutions
http://here.com/map=28.54,77.27,17/title=Communication%20Solution
http://here.com/map=29.17,77.21,17/title=Dexter
http://here.com/map=28.65,77.09,17/title=Hotline%20Communications
http://here.com/map=28.47,77.04,17/title=Instant%20Solutions

有办法吗?

1 个答案:

答案 0 :(得分:0)

将所有链接放入列表中,然后尝试下面的代码

foreach (var node in ListofLinks)
{

  if (loc.Contains("map="))
  {
    loc = loc.Substring(20);
    coordinates = loc.Split(',');
    newCoordinate.Coordinates.Longitude = (coordinates != null ?   Double.Parse(coordinates[0]) : 0.00);
    newCoordinate.Coordinates.Latitude = (coordinates != null ? Double.Parse(coordinates[1]) : 0.00);
   }
}    CoOrdinates.Add(newCoordinate);

遍历所有链接并将坐标添加到CoOrdinates List,即GeoCoordinate列表。

获得坐标列表后,将其添加到地图中。

foreach (var cor in CoOrdinates)
 {
   MapOverlay myLocOverlay = new MapOverlay();
   myLocOverlay.PositionOrigin = new Point(0.5, 0.5);
   myLocOverlay.GeoCoordinate = new GeoCoordinate();
   myLocOverlay.GeoCoordinate.Latitude = cor.Coordinates.Longitude;
   myLocOverlay.GeoCoordinate.Longitude = cor.Coordinates.Latitude;
   myLocOverlay.Content = CreateShape(myLocOverlay.GeoCoordinate.Latitude, myLocOverlay.GeoCoordinate.Longitude);
   // Create a MapLayer to contain the MapOverlay.
   MapLayer myLocLayer = new MapLayer();
   myLocLayer.Add(myLocOverlay);

   // Add the MapLayer to the Map.
    mapWithMyLocation.Layers.Add(myLocLayer);
 }

private Polygon CreateShape(double latitude, double longitude)
    {
        Polygon MyPolygon = new Polygon();
        MyPolygon.Points.Add(new Point(4, 0));
        MyPolygon.Points.Add(new Point(22, 0));
        MyPolygon.Points.Add(new Point(4, 60));
        MyPolygon.Stroke = new SolidColorBrush(Colors.Red);
        MyPolygon.Fill = new SolidColorBrush(Colors.Green);
        MyPolygon.SetValue(Grid.RowProperty, 1);
        MyPolygon.SetValue(Grid.ColumnProperty, 0);
        MyPolygon.Tag = new GeoCoordinate(latitude, longitude);
        MyPolygon.Tap += MyPolygon_Tap;
        return MyPolygon;
    }