Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

Async adding points on Xamarin.Forms.Maps

$
0
0

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

Viewing all articles
Browse latest Browse all 91519

Trending Articles