Hi Don,
We made sure our packages are all up to date. We have not tried the work around but I was able to replicate it in a sample project. You will need to put your Bing Key for that BingMapsLayer. I will look into the work around and see if I can create a sample project of it happening on our Printing page if I have time.
Default.aspx
<%@ Page Title=“Home Page” Language=“C#” MasterPageFile="~/Site.Master" AutoEventWireup=“true” CodeBehind=“Default.aspx.cs” Inherits=“Test._Default” %>
<%@ Register Assembly=“ThinkGeo.MapSuite.WebForms” Namespace=“ThinkGeo.MapSuite.WebForms” TagPrefix=“cc1” %>
<asp:Content ID=“BodyContent” ContentPlaceHolderID=“MainContent” runat=“server”>
<div>
<cc1:Map ID="Map1" runat="server" Height="600px" Width="800px"></cc1:Map>
</div>
<asp:Button ID="Button" runat="server" OnClick="Button_Click" Text="Add Layer"/>
</asp:Content>
Default.aspx.cs
using System;
using ThinkGeo.MapSuite.WebForms;
using ThinkGeo.MapSuite.Drawing;
using ThinkGeo.MapSuite.Layers;
using ThinkGeo.MapSuite.Shapes;
using ThinkGeo.MapSuite.Styles;
using ThinkGeo.MapSuite.Serialize;
using ThinkGeo.MapSuite;
using System.IO;
using System.Drawing;
using System.Web;
using System.Web.UI;
namespace Test
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Init(object sender, System.EventArgs e)
{
}
protected void Page_Load(object sender, EventArgs e)
{
try
{
if (!IsPostBack)
{
// Set the Map Unit. The reason for setting it to DecimalDegrees is that is what the shapefile’s unit of measure is inherently in.
Map1.MapUnit = GeographyUnit.DecimalDegree;
LayerOverlay layerOverlay = new LayerOverlay();
InMemoryFeatureLayer imf = new InMemoryFeatureLayer();
imf.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1;
imf.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
imf.InternalFeatures.Add(new Feature(new RectangleShape(-100, 50, -80, 30)));
layerOverlay.Layers.Add(imf);
Map1.CustomOverlays.Add(layerOverlay);
FeatureOverlay featureOverlay = Map1.HighlightOverlay;
//Adds the States Shapefile
ShapeFileFeatureLayer shapeFileLayer = new ShapeFileFeatureLayer(MapPath(@"App_Data\states.shp"), MapPath(@"App_Data\states.idx"), GeoFileReadWriteMode.Read, System.Text.Encoding.Default);
ZoomLevel objZoom = shapeFileLayer.ZoomLevelSet.ZoomLevel01;
objZoom.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
AreaStyle objStyle = default(AreaStyle);
objStyle = new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(100, GeoColor.StandardColors.DarkBlue)));
objZoom.CustomStyles.Add(objStyle);
objZoom.CustomStyles.Add(GetHaloLabelRender(6.5F, "FULLNAME", GeoColor.StandardColors.DarkBlue));
//-- Add layer to map
shapeFileLayer.ZoomLevelSet.CustomZoomLevels.Add(objZoom);
layerOverlay.Layers.Add(shapeFileLayer);
//Adds a FeatureOverlay Point that represents the Highlight Overlay
PointShape objPoint = new PointShape(-100, 45);
GeoColor objPointColor = new GeoColor(255, 0, 0);
PointStyle objPointStyle = new PointStyle((PointSymbolType)0, new GeoSolidBrush(objPointColor), 6);
Feature pointmap = new Feature(objPoint);
featureOverlay.Features.Add(pointmap);
Map1.CurrentExtent = new RectangleShape(-178.215027, 71.406647, -66.969849, 18.924782);
Session.Remove("layerOverlay");
Session.Add("layerOverlay", layerOverlay);
Session.Remove("featureOverlay");
Session.Add("featureOverlay", featureOverlay);
}
}
catch (Exception ex)
{
}
}
private TextStyle GetHaloLabelRender(float FontWidth, string strRenderField, GeoColor TextColor, bool blnOnTop = false)
{
if (blnOnTop == true)
{
return TextStyles.CreateSimpleTextStyle(strRenderField, "Arial", FontWidth, DrawingFontStyles.Bold, TextColor, GeoColor.StandardColors.White, 3, 10, 10);
}
else
{
return TextStyles.CreateSimpleTextStyle(strRenderField, "Arial", FontWidth, DrawingFontStyles.Bold, TextColor, GeoColor.StandardColors.White, 3, -10, -10);
}
}
//The process is to build a bitmap
protected void Button_Click(object sender, EventArgs e)
{
Bitmap objBitMap = null;
try
{
objBitMap = new Bitmap((int)Map1.WidthInPixels, (int)Map1.HeightInPixels);
PlatformGeoCanvas objGeoCanvas = new PlatformGeoCanvas();
objGeoCanvas.BeginDrawing(objBitMap, Map1.CurrentExtent, Map1.MapUnit);
System.Collections.ObjectModel.Collection<SimpleCandidate> colLayers = new System.Collections.ObjectModel.Collection<SimpleCandidate>();
BackgroundLayer objBackground = new BackgroundLayer(new GeoSolidBrush(GeoColor.SimpleColors.White));
BingMapsLayer objBingLayer = new BingMapsLayer("YOUR KEY HERE", ThinkGeo.MapSuite.Layers.BingMapsMapType.Road);
objBingLayer.Open();
//Issue Happens HERE
objBingLayer.Draw(objGeoCanvas, colLayers);
objBingLayer.Close();
for (int i = 0; i <= Map1.CustomOverlays.Count - 1; i++)
{
if (Map1.CustomOverlays[i].GetType() != typeof(BingMapsOverlay))
{
Layer objTemp;
LayerOverlay objOverlay = (LayerOverlay)Map1.CustomOverlays[i];
foreach (Layer objLayer in objOverlay.Layers)
{
if (objLayer.IsVisible == true)
{
objTemp = objLayer;
objLayer.Open();
objLayer.Draw(objGeoCanvas, colLayers);
objLayer.Close();
}
}
}
}
objGeoCanvas.EndDrawing();
string strFilePath = Request.PhysicalApplicationPath + "App_Data";
SaveGISMapToImage(objBitMap, strFilePath);
}
catch (Exception ex)
{
//Put a Stop Here
string errorMessage = ex.Message;
}
}
public void SaveGISMapToImage(Bitmap objImage, String strMapPath)
{
string strError = "";
string strFullPath = "";
try
{
strFullPath = strMapPath;
//Exit if they cancel
if (strFullPath.Length == 0)
return;
string strFileName = "";
bool blnFinished = true;
string strFormat = "";
try
{
strFileName = "GIS.bmp";
objImage.Save(strFullPath + strFileName);
System.Diagnostics.Process.Start(strFullPath + strFileName);
System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
response.ClearContent();
response.Clear();
response.ContentType = "text/plain";
response.AddHeader("Content-Disposition", "attachment; filename=" + strFileName + ";");
response.TransmitFile(strFullPath + strFileName);
response.Flush();
File.Delete(strFullPath + strFileName);
System.Web.HttpContext.Current.ApplicationInstance.CompleteRequest();
}
catch (Exception ex)
{
blnFinished = false;
strError = ex.Message;
}
}
catch (Exception ex)
{
}
}
}
}
Web.config
<?xml version="1.0" encoding="utf-8"?>
<sessionState mode="StateServer" customProvider="DefaultSessionProvider" timeout="120" stateNetworkTimeout="20">
<providers>
<add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" />
</providers>
</sessionState>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<httpHandlers>
<add path="*_GeoResource.axd" verb="*" type="ThinkGeo.MapSuite.WebForms.GeoResourceFactory" />
</httpHandlers>
</system.web>
> <system.webServer>
> <validation validateIntegratedModeConfiguration="false" />
> <handlers>
> <add name="GeoResource" preCondition="integratedMode" path="*_GeoResource.axd" verb="*" type="ThinkGeo.MapSuite.WebForms.GeoResourceFactory" />
> </handlers>
> </system.webServer>
> <system.codedom>
> <compilers>
> <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" />
> <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+" />
> </compilers>
> </system.codedom>
> <runtime>
> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
> <dependentAssembly>
> <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
> <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
> </dependentAssembly>
> <dependentAssembly>
> <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
> <bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
> </dependentAssembly>
> </assemblyBinding>
> </runtime>
> </configuration>
Thanks,
Neil