2014-07-27 46 views
0

我正在开发Windows Phone 8应用程序在c#和xaml。 我必须使用诺基亚Here Here Map SDK绘制多个位置。 我有纬度,经度和标题属性。诺基亚HERE地图多个位置c#

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 

有没有办法做到这一点?

回答

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); 

遍历所有的链接,并添加坐标坐标列表是会有地理座标的名单。

一旦你获得了坐标列表,然后将它们添加到地图。

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; 
    }