I have a custom pointstyle where extra shapes are drawn around the point (an ellipse, a line through the point, etc.) in the overriden DrawCore function. I noticed that the canvas.DrawArea + canvas.DrawLine functions are very slow when used together. Sometimes it takes >5 seconds to refresh the map when the point is in the current extent.
Below is the overriden DrawCore function in my custom pointstyle class.
I loop through the features, check if the feature is of my custom class type, and then draw a line on the map from the feature to 0, 0 as well as an ellipse around the feature.
protected override void DrawCore(IEnumerable<Feature> features, GeoCanvas canvas, Collection<SimpleCandidate> labelsInThisLayer, Collection<SimpleCandidate> labelsInAllLayers)
{
foreach (Feature feature in features)
{
if (feature is VehicleFeature) //if the feature is my custom type VehicleFeature which inherits from Feature
{
PointShape location = (PointShape)feature.GetShape(); //get the pointshape from the feature
var packageColor = new GeoPen(GeoColors.Red)
{
DashStyle = LineDashStyle.Dash
};
Collection<Vertex> vertices = new Collection<Vertex> { new Vertex(location), new Vertex(0, 0) };
LineShape connectingLine = new LineShape(vertices); //create the connecting line
//draw to the map
canvas.DrawLine(connectingLine, packageColor, DrawingLevel.LevelOne);
EllipseShape es = new EllipseShape(location, 30, ThinkGeo.MapSuite.GeographyUnit.DecimalDegree, DistanceUnit.Meter);
canvas.DrawArea(es, packageColor, DrawingLevel.LevelOne);
}
}
base.DrawCore(features, canvas, labelsInThisLayer, labelsInAllLayers);
}
Now, if I remove either the DrawLine or DrawArea function so only one Draw function is there, it’s plenty fast enough.
Update: I tested with multiple DrawArea functions and it is fast. As soon as I add in a DrawLine function it’s slow.