amay077 / Xamarin.Forms.GoogleMaps

Map library for Xamarin.Forms using Google maps API
https://www.nuget.org/packages/Xamarin.Forms.GoogleMaps/
MIT License
546 stars 346 forks source link

Drawling Line causing an exception #670

Open davidbuckleyni opened 4 years ago

davidbuckleyni commented 4 years ago

Trying to draw a line produces the following error System.ArgumentException: 'Polyline must have a 2 positions to be added to a map'

Even though when you see my screencast below I do indeed have 2 points. Or do you mean it must have a start and an end position. https://www.screencast.com/t/NlddvDqgIvIj private void Current_PositionChanged(object sender, PositionEventArgs e) {

         MyPostion pos = new MyPostion();
        pos.Lat = e.Position.Latitude;
        pos.Lng = e.Position.Longitude;
        listPostions.ItemsSource = null;
        postionsList.Add(pos);
        listPostions.ItemsSource = postionsList;

        Position pos2 = new Position(pos.Lat, pos.Lng);

        if ((postionsList.FirstOrDefault().Lat != 0.00))
            posList.Add(pos2);

        if (posList.Count >2)
            polyLine.Positions.Add(pos2);

        map.Polylines.Add(polyLine);
        double zoom = map.CameraPosition.Zoom;
        map.AnimateCamera(CameraUpdateFactory.NewPositionZoom(new Position(e.Position.Latitude, e.Position.Longitude),zoom),null);

    }
davidbuckleyni commented 4 years ago

Does nobody reply to this repo at all but frustrating