C# 从UI线程外部向MKMapView添加注释
我正在尝试将地图标记从API显示到MKMapView。我正在Xamarin Studio中为iOS编写代码。我正在调用函数C# 从UI线程外部向MKMapView添加注释,c#,.net,xamarin.ios,xamarin,C#,.net,Xamarin.ios,Xamarin,我正在尝试将地图标记从API显示到MKMapView。我正在Xamarin Studio中为iOS编写代码。我正在调用函数getAllMarkers()我创建的 看起来是这样的: private void getAllMarkers() { var client = new RestClient("http://example.com/"); var request = new RestRequest(String.Format(""));
getAllMarkers()代码>我创建的
看起来是这样的:
private void getAllMarkers()
{
var client = new RestClient("http://example.com/");
var request = new RestRequest(String.Format(""));
client.ExecuteAsync (request, response => {
JsonValue data = JsonValue.Parse(response.Content);
for (var i = 0; i < data.Count; i++){
var store = new BasicMapAnnotation (new CLLocationCoordinate2D(10.00, -1.00), "Shop name", "Extras);
map.AddAnnotation(store);
}
});
}
private void getAllMarkers()
{
var client=新的RestClient(“http://example.com/");
var请求=新的重新请求(String.Format(“”);
client.ExecuteAsync(请求、响应=>{
JsonValue data=JsonValue.Parse(response.Content);
对于(var i=0;i
这给了我以下错误:
如何从函数getAllMarkers()向地图添加标记?使用()
InvokeOnMainThread ( () => {
// manipulate UI controls
` map.AddAnnotation(store);`
});