Programmatically Creating a LineString

Aug 26, 2010 at 4:34 AM
Edited Aug 26, 2010 at 4:34 AM

If I modify the SL4 branch example to this:

            var line1 = new LineStringControl { Locations = new ObservableCollection<Location>() };

            line1.Locations.Add(new Location { Latitude = 15, Longitude = 15 });
            line1.Locations.Add(new Location { Latitude = 30, Longitude = -15 });
            line1.Locations.Add(new Location { Latitude = 45, Longitude = -15 });
            line1.Locations.Add(new Location { Latitude = 15, Longitude = 15 });

            geometryLayer.Add(line1);

It throws an exception. This is because after adding the first point the geometry is automatically updated but doesn't like lines with one point.

Andy