Hi,
I've added the MiniMapAdornmentLayout example to my application, and I noticed a significant performance degradation when zooming and panning. This is most likely due to the fact that my layer has 18,000 features to render, and now those points are being rendered twice (once in the map's main layer, and again for the mini map)! I was thinking that to improve performance, perhaps I could render a cached image of my feature layer into the mini map adornment.
I've attempted to do this, with the code below, but am failing to see my image in the mini map.
Are there any examples for how to render a layer to an image, and then the image back to a canvas? Or perhaps someone has some other ideas around this. Also, How do I make my code look like code in this editor?
My code is below, and like I said is based on the MiniMapAdornmentLayout example.
Thanks,
Greg
private GeoImage miniImage;
private GeoImage GetPointsImage(Layer layer, GeographyUnit mapUnit, RectangleShape scaledWorldExtent, Collection<SimpleCandidate> labelsInAllLayers)
{
if (miniImage == null) {
miniImage = new GeoImage(width, height);
GdiPlusGeoCanvas miniCanvas = new GdiPlusGeoCanvas();
miniCanvas.BeginDrawing(miniImage, scaledWorldExtent, mapUnit);
layer.Draw(miniCanvas, labelsInAllLayers);
miniCanvas.EndDrawing();
}
return miniImage;
}
protected override void DrawCore(GeoCanvas canvas, Collection<SimpleCandidate> labelsInAllLayers)
{
GeoImage miniImage = new GeoImage(width, height);
RectangleShape scaledWorldExtent = MapEngine.GetDrawingExtent(canvas.CurrentWorldExtent, width, height);
scaledWorldExtent.ScaleUp(300);
GdiPlusGeoCanvas minCanvas = new GdiPlusGeoCanvas();
minCanvas.BeginDrawing(miniImage, scaledWorldExtent, canvas.MapUnit);
ScreenPointF drawingLocation = GetDrawingLocation(canvas, width, height);
foreach (Layer layer in layers) {
GeoImage pointImage = GetPointsImage(layer, canvas.MapUnit, scaledWorldExtent, labelsInAllLayers);
if (pointImage != null) {
minCanvas.DrawScreenImageWithoutScaling(
pointImage,
(width / 2),
(height / 2),
DrawingLevel.LevelOne,
0,
0,
0);
}
}
minCanvas.DrawArea(RectangleShape.ScaleDown(minCanvas.CurrentWorldExtent, 1), new GeoPen(GeoColor.StandardColors.Gray, 2), DrawingLevel.LevelOne);
minCanvas.DrawArea(canvas.CurrentWorldExtent, new GeoPen(GeoColor.StandardColors.Gray, 2), DrawingLevel.LevelOne);
minCanvas.EndDrawing();
canvas.DrawScreenImageWithoutScaling(miniImage, (drawingLocation.X + width / 2) + 10, (drawingLocation.Y + height / 2) - 10, DrawingLevel.LevelOne, 0, 0, 0);
}