2012-03-27 35 views
2

您好,我的主要問題是如何使用MKAnnotationView爲我所有的座標點設置自定義圖釘圖像。MonoTouch多Mapkit CLLocationCoordinate2D與自定義PIN圖像

作爲參考,我已經繼續並硬編碼了值,我通常會從json webservice調用中調用這些值。 繼承人硬編碼路徑的一個例子:

CLLocationCoordinate2D[] trail1 = new CLLocationCoordinate2D[]{ 
new CLLocationCoordinate2D(10.74812, -97.330277), 
new CLLocationCoordinate2D(10.74501, -97.350277), 
new CLLocationCoordinate2D(10.74912, -97.340277), 
}; 

CLLocationCoordinate2D[] trail2 = new CLLocationCoordinate2D[]{ 
new CLLocationCoordinate2D(10.84812, -97.331277), 
new CLLocationCoordinate2D(10.94501, -97.352277), 
new CLLocationCoordinate2D(10.14912, -97.343277), 
new CLLocationCoordinate2D(10.12912, -97.313277),  
}; 

mapview.AddAnnotation (new SampleMapAnnotation (trail1)); 

現在我使用MKAnnotation但意識到我需要使用MKAnnotationView自定義圖像銷。

public class SampleMapAnnotation : MKAnnotation 
{ 
string _title; 

public SampleMapAnnotation (CLLocationCoordinate2D coordinate) 
{ 
Coordinate = coordinate; 
_title = "Sample"; 
} 

public override CLLocationCoordinate2D Coordinate { get; set; } 

public override string Title 
     { 
      get { 
       return _title; 
     } 
    } 
} 
+0

目前還不清楚你的問題是從網絡服務答案和類似於你的硬編碼答案(即解析)或**(b)**從這樣一個List < >實際上使用它與一些API? – poupou 2012-03-27 19:31:17

回答

2

查看Xamarin的MapCallout sample。這是來自Apple的Objective-C sample的C#端口。它將向您展示如何創建基於圖像的註釋並將其顯示在地圖上。