Async adding points on Xamarin.Forms.Maps

MaksAr.2598MaksAr.2598 USMember
edited January 2016 in Xamarin.Forms

Hi, everybody.

I have a prolema, can't asynchronously add a point on the map

help please

    public MapPage ()
  {           
      map = new Map { 
          IsShowingUser = true,
          HeightRequest = 100,
          WidthRequest = 960,
          VerticalOptions = LayoutOptions.FillAndExpand
      };

        //Creating pins
  List<Pin> pinList; 
        //pinList.Add(new Pin {
        //    Label = "Curent location",
        //    Position = new Position(group[0].lat, group[0].lon)
        //});
        
        Button btn = new Button();

        btn.Clicked += async (sender, e) => {
            map.Pins.Clear();
            await Task.Run(() => {
                for(int i = 0; i < pinList.Count; ++i) {
                    map.Pins.Add(pinList[i]);
                }
            });
        };

        StackLayout stack = new StackLayout();

        stack.Children.Add(map);
        stack.Children.Add(btn);

        Content = stack;
  }
Sign In or Register to comment.