Hi Gary,
I have to implement a static minimap in my map page. Static in the sense the minimap should not refresh like the map refreshes its tile for every zooming and panning. Could you suggest me an idea so that the minimap does not refreshes when the map is zoomed or panned. I have used the following code.
in aspx.cs
ServerLayerOverlay worldMapKitRenderLayerOverlay = new ServerLayerOverlay("WorldMapKitRenderLayerOverlay");
worldMapKitRenderLayerOverlay.Layers.Add(worldMapKitRenderLayer);
SilverlightMapConnector1.ServerLayerOverlays.Add(worldMapKitRenderLayerOverlay);
MiniMapAdornmentLayer minimap = new MiniMapAdornmentLayer();
minimap.Layers.Add(worldMapKitRenderLayer);
minimap.Location = ThinkGeo.MapSuite.Core.AdornmentLocation.LowerLeft;
in adornmentlayer.cs
public class MiniMapAdornmentLayer : AdornmentLayer
{
private Collection<Layer> layers;
private int width;
private int height;
public MiniMapAdornmentLayer()
: this(new Layer[] { }, 250, 250)
{ }
public MiniMapAdornmentLayer(int width, int height)
: this(new Layer[] { }, width, height)
{ }
public MiniMapAdornmentLayer(IEnumerable<Layer> layers, int width, int height)
{
this.layers = new Collection<Layer>();
foreach (Layer layer in layers)
{
this.layers.Add(layer);
}
this.width = width;
this.height = height;
}
public Collection<Layer> Layers
{
get { return layers; }
}
protected override void DrawCore(GeoCanvas canvas, Collection<SimpleCandidate> labelsInAllLayers)
{
GeoImage miniImage = new GeoImage(width, height);
RectangleShape scaledWorldExtent = MapEngine.GetDrawingExtent(new RectangleShape(-135.7, 83.6, 113.5, -83), 200, 200);
//RectangleShape scaledWorldExtent = MapEngine.GetDrawingExtent(canvas.CurrentWorldExtent, 200, 200);
scaledWorldExtent.ScaleUp(10);
GdiPlusGeoCanvas minCanvas = new GdiPlusGeoCanvas();
minCanvas.BeginDrawing(miniImage, scaledWorldExtent, canvas.MapUnit);
foreach (Layer layer in layers)
{
layer.Draw(minCanvas, labelsInAllLayers);
}
//minCanvas.DrawArea(new RectangleShape(-150.7, 83.6, 123.5, -93), new GeoPen(GeoColor.StandardColors.Gray, 2), DrawingLevel.LevelOne);
minCanvas.DrawArea(canvas.CurrentWorldExtent, new GeoPen(GeoColor.StandardColors.Black, 2), DrawingLevel.LevelOne);
minCanvas.EndDrawing();
ScreenPointF drawingLocation = GetDrawingLocation(canvas, width, height);
canvas.DrawScreenImageWithoutScaling(miniImage, (drawingLocation.X + width / 2) + 10, (drawingLocation.Y + height / 2) - 10, DrawingLevel.LevelOne, 0, 0, 0);
}
}
in xaml.cs
serverLayerOverlay = new ServerLayerOverlay("WorldMapKitRenderLayerOverlay", "SilverlightMapConnector1");
serverLayerOverlay.TileType = TileType.SingleTile;
Map1.Overlays.Add(serverLayerOverlay);
ServerLayerOverlay minimapoverlay = new ServerLayerOverlay("ServerSideMiniMap", "SilverlightMapConnector1");
minimapoverlay.TileType = TileType.SingleTile;
Map1.Overlays.Add(minimapoverlay);