Hi Ethan,
We attempted setting the Client Cache to null and it is not possible to set it to null. Also thank you for the clarification on the ServerCache.
I completed a test project to show the issue with GenerateCacheImages. I created a sample Shapefile that matched the project of our clients shapefiles. Here are some images below showing the issue.
When the ServerCache is built by GenerateCacheImages:
https://www.screencast.com/t/zcEx5mkbhhE
https://www.screencast.com/t/FoEJBd7oX8m
https://www.screencast.com/t/aEEN4f67vr
When the ServerCache is built on the fly without GenerateCacheImages:
https://www.screencast.com/t/8y97BPr8
https://www.screencast.com/t/9DRdy0hIyCGr
https://www.screencast.com/t/XTaucm5qimN
Here is the code:
WebForm1.aspx.cs
using System;
using System.Web.UI;
using System.IO;
using ThinkGeo.MapSuite.WebForms;
using ThinkGeo.MapSuite.Drawing;
using ThinkGeo.MapSuite.Layers;
using ThinkGeo.MapSuite.Shapes;
using ThinkGeo.MapSuite.Styles;
using ThinkGeo.MapSuite;
namespace Test
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string strFile = @“C:\GIS”; //Local File Path for testing
try
{
if (!Page.IsPostBack)
{
Map1.MapBackground = new GeoSolidBrush(GeoColor.FromHtml("#E5E3DF"));
string applicationID = “Your Key Here”;
BingMapsOverlay mobjBingsOverlay = new BingMapsOverlay("ROADS", applicationID);
mobjBingsOverlay.MapStyle = BingMapsStyle.Road;
mobjBingsOverlay.Name = "Roads";
Map1.CustomOverlays.Add(mobjBingsOverlay);
Map1.MapUnit = GeographyUnit.Meter;
ShapeFileFeatureLayer objLayer = new ShapeFileFeatureLayer(strFile + "TestShape.shp");
//Set's the Style
objLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1;
objLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
//Works with the projection
Proj4Projection objProjectionJUR = new Proj4Projection();
string strProjection = null;
string strFileFull = strFile + "TestShape.shp";
ShapeFileFeatureLayer.BuildIndexFile(strFileFull);
strProjection = File.ReadAllText(strFileFull.Replace(".shp", ".prj")); //Obtains all prj files matching the reference.
//strProjection = ReadAllText(strFile.Replace(".shp", ".prj")); //Obtains all prj files matching the reference.
objProjectionJUR.InternalProjectionParametersString = Proj4Projection.ConvertPrjToProj4(strProjection);
objProjectionJUR.ExternalProjectionParametersString = Proj4Projection.GetBingMapParametersString();
objProjectionJUR.Open();
objLayer.FeatureSource.Projection = objProjectionJUR;
LayerOverlay objOverlay = new LayerOverlay();
objOverlay.Layers.Add("Test", objLayer);
Map1.CustomOverlays.Add(objOverlay);
objLayer.Open();
Map1.CurrentExtent = objLayer.GetBoundingBox();
objOverlay.ServerCache.CacheDirectory = Path.GetDirectoryName(strFile);
objOverlay.ServerCache.CacheId = "Main";
//Comment out GenerateCacheImages and remove the cached folder to test ServerCaching loading on the fly.
objOverlay.GenerateCacheImages(Map1.ZoomLevelSet.ZoomLevel10, objOverlay.GetBoundingBox(), Map1.MapUnit);
objOverlay.GenerateCacheImages(Map1.ZoomLevelSet.ZoomLevel11, objOverlay.GetBoundingBox(), Map1.MapUnit);
objOverlay.GenerateCacheImages(Map1.ZoomLevelSet.ZoomLevel12, objOverlay.GetBoundingBox(), Map1.MapUnit);
objOverlay.GenerateCacheImages(Map1.ZoomLevelSet.ZoomLevel13, objOverlay.GetBoundingBox(), Map1.MapUnit);
objOverlay.GenerateCacheImages(Map1.ZoomLevelSet.ZoomLevel14, objOverlay.GetBoundingBox(), Map1.MapUnit);
objOverlay.GenerateCacheImages(Map1.ZoomLevelSet.ZoomLevel15, objOverlay.GetBoundingBox(), Map1.MapUnit);
objOverlay.GenerateCacheImages(Map1.ZoomLevelSet.ZoomLevel16, objOverlay.GetBoundingBox(), Map1.MapUnit);
objOverlay.GenerateCacheImages(Map1.ZoomLevelSet.ZoomLevel17, objOverlay.GetBoundingBox(), Map1.MapUnit);
objOverlay.GenerateCacheImages(Map1.ZoomLevelSet.ZoomLevel18, objOverlay.GetBoundingBox(), Map1.MapUnit);
}
}
catch (Exception ex)
{
lblSuccess.Text = ex.Message;
}
}
}
}
WebForm1.aspx
> <%@ Page Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="Test.WebForm1" %>
> <%@ Register Assembly="ThinkGeo.MapSuite.WebForms" Namespace="ThinkGeo.MapSuite.WebForms" TagPrefix="cc1" %>
> <asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
> <script type="text/javascript">
> var OnMapCreating = function (map) {
> }
> </script>
> <div>
> <asp:Label ID="lblExists" runat="server"></asp:Label>
> <asp:Label ID="lblSuccess" runat="server"></asp:Label>
> <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>
Thank you,
Neil TestShape.zip (2.3 KB)