Hi,
I created a custom layer as well and overrided DrawCore(). My desktop application gets the map in bitmap format from a centralized server which hosts the map data. The GeoCanvas size is smaller than the size of my map control. What do I need to do to make my map occupies the full extent of the map control?
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Collections.ObjectModel;
using MapApplication.MapWebService;
using System.IO;
// What this sample does is creates your own layer. You can use this layer just like any other layers
// in the system. The advantage is that you can place it where you want and it will seamlessly integrate
// with the rest of the system. As you can see it is really easy to create your own layers.
// The basic flow of events is that when the map needs to draw it will first call the OpenCore.
// This is where you do anything special to get your source ready. Then it will call the GetBoundingBox
// method to make sure the current extent of the map is within the are you have data. If not then it will
// never call the DrawCore because there is no need. Then if you are int he extent it wil call the DrawCore.
// The DrawCore is where you place your code that need to do the drawing on the canvas. As you can see below
// it is faily simple.
namespace ThinkGeo.MapSuite.Core
{
class SimpleCustomLayer : Layer
{
private Service1SoapClient imageServiceSoapClient = new Service1SoapClient();
protected override void OpenCore()
{
}
protected override void CloseCore()
{
}
protected override RectangleShape GetBoundingBoxCore()
{
return new RectangleShape(-143.4, 109.3, 116.7, -76.3);
}
protected override void DrawCore(GeoCanvas canvas, Collection<SimpleCandidate> labeledInLayers)
{
Bitmap customImage = GetImage(canvas.CurrentWorldExtent.UpperLeftPoint.X, canvas.CurrentWorldExtent.UpperLeftPoint.Y, canvas.CurrentWorldExtent.LowerRightPoint.X, canvas.CurrentWorldExtent.LowerRightPoint.Y, (int)canvas.Width, (int)canvas.Height);
canvas.DrawWorldImageWithoutScaling(canvas.ToGeoImage(customImage), canvas.CurrentWorldExtent.GetCenterPoint().X, canvas.CurrentWorldExtent.GetCenterPoint().Y, DrawingLevel.LevelOne);
customImage.Dispose();
}
private Bitmap GetImage(double upperLeftX, double upperLeftY, double lowerRightX, double lowerRightY, int screenWidth, int screenHeight)
{
byte[] byteArray = imageServiceSoapClient.GetMapImage(upperLeftX, upperLeftY, lowerRightX, lowerRightY, screenWidth, screenHeight, "Overlay1");
MemoryStream memoryStream = new MemoryStream(byteArray);
Bitmap customImage = new Bitmap(memoryStream);
Graphics g = Graphics.FromImage(customImage);
g.Dispose();
return customImage;
}
}
}
Thanks