protected void btnGenerateTiling_Click(object sender, EventArgs e) { Collection zoomLevels = GetAllZoomLevels(); int tileWidth = 256; int tileHeight = 256; ShapeFileFeatureLayer shapeFileFeatureLayer = new ShapeFileFeatureLayer(@"C:\Program Files (x86)\ThinkGeo\Map Suite Desktop Full Edition 4.0\Samples\SampleData\Data\Countries02.shp"); shapeFileFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1; shapeFileFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; shapeFileFeatureLayer.Open(); RectangleShape cacheExtent = shapeFileFeatureLayer.GetBoundingBox(); shapeFileFeatureLayer.Close(); MapEngine mapEngine = new MapEngine(); mapEngine.ShowLogo = false; mapEngine.StaticLayers.Add(shapeFileFeatureLayer); GeographyUnit mapUnit = GeographyUnit.DecimalDegree; for (int i = 0; i < zoomLevels.Count; i++) { MapSuiteTileMatrix tileMatrix = new MapSuiteTileMatrix(zoomLevels[i].Scale, tileWidth, tileHeight, mapUnit); BitmapTileCache tileCache = new FileBitmapTileCache(txtCachePath.Text, string.Empty, TileImageFormat.Png, tileMatrix); RowColumnRange rowColumnRange = tileCache.TileMatrix.GetIntersectingRowColumnRange(cacheExtent); for (long row = rowColumnRange.MinRowIndex; row <= rowColumnRange.MaxRowIndex; row++) { for (long column = rowColumnRange.MinColumnIndex; column <= rowColumnRange.MaxColumnIndex; column++) { RectangleShape tileExtent = tileCache.TileMatrix.GetCell(row, column).BoundingBox; Bitmap bitmap = new Bitmap(tileWidth, tileHeight); mapEngine.CurrentExtent = tileExtent; mapEngine.OpenAllLayers(); mapEngine.DrawStaticLayers(bitmap, mapUnit); mapEngine.DrawDynamicLayers(bitmap, mapUnit); mapEngine.CloseAllLayers(); BitmapTile tile = new BitmapTile(bitmap, tileExtent, zoomLevels[i].Scale); tileCache.SaveTile(tile); bitmap.Dispose(); tile.Dispose(); } } } }