Hi Val,
Now I have another problem.
I am pre-generating tiles using following code.
Following code does work with regular ZoomLevelSet but when I’m switching to GoogleMapZoomLevelSet it generates tiles with wrong row number.
Thanks,
Inna
public static readonly RectangleShape MaxExtentForWrappingDateline = new RectangleShape(-400767557376, 20026376, 400767557376, -20026376);
public static void Generate(ZoomLevelSet zoomLevelSet, FeatureLayer shapeFileFeatureLayer, GeographyUnit mapUnit, int tileWidth, int tileHeight, string cacheDirectory, string cacheId)
{
Collection<ZoomLevel> zoomLevels = GetAllZoomLevels(zoomLevelSet);
foreach (ZoomLevel zoomLevel in zoomLevels)
{
MapSuiteTileMatrix matrix = new MapSuiteTileMatrix(zoomLevel.Scale, tileWidth, tileHeight, mapUnit, MaxExtentForWrappingDateline);
// we need sync the max extent as the sample code we set.
matrix.BoundingBox = MaxExtentForWrappingDateline;
shapeFileFeatureLayer.Open();
Collection<TileMatrixCell> cells = matrix.GetIntersectingCells(shapeFileFeatureLayer.GetBoundingBox());
// create a tile cache object with the cache directory and cache id.
FileBitmapTileCache tileCache = new FileBitmapTileCache(cacheDirectory, cacheId, TileImageFormat.Png, matrix);
foreach (TileMatrixCell cell in cells)
{
// create a bitmap whoes size equals to the tile size.
using (Bitmap bitmap = new Bitmap(tileWidth, tileHeight))
{
// create a GeoCanvas which for drawing the passed layers.
GdiPlusGeoCanvas geoCanvas = new GdiPlusGeoCanvas();
geoCanvas.BeginDrawing(bitmap, cell.BoundingBox, mapUnit);
GeoCollection<SimpleCandidate> candidates = new GeoCollection<SimpleCandidate>();
lock (shapeFileFeatureLayer)
{
if (!shapeFileFeatureLayer.IsOpen) { shapeFileFeatureLayer.Open(); }
shapeFileFeatureLayer.Draw(geoCanvas, candidates);
}
// you can commend this line out because it's just for mark a cache label in order to see if it works with our samples.
geoCanvas.DrawText("Cache", new GeoFont("Arial", 12), new GeoSolidBrush(GeoColor.SimpleColors.Black), new Collection<ScreenPointF>() { new ScreenPointF(128f, 128f) }, DrawingLevel.LabelLevel);
geoCanvas.EndDrawing();
// create tile object to maintain current tile information.
BitmapTile tile = new BitmapTile(bitmap, cell.BoundingBox, zoomLevel.Scale);
tileCache.SaveTile(tile);
}
}
}
}
private static Collection<ZoomLevel> GetAllZoomLevels(ZoomLevelSet zoomLevelSet)
{
zoomLevelSet = new GoogleMapZoomLevelSet();
Collection<ZoomLevel> resultZoomLevels = new Collection<ZoomLevel>();
resultZoomLevels.Add(zoomLevelSet.ZoomLevel01);
resultZoomLevels.Add(zoomLevelSet.ZoomLevel02);
resultZoomLevels.Add(zoomLevelSet.ZoomLevel03);
//resultZoomLevels.Add(zoomLevelSet.ZoomLevel04);
return resultZoomLevels;
}