I am trying to set up my program so that user input is reflected by changes to the map overlays, however the map.overlay collection is empty such that I cannot edit my existing layers/overlays. I have no idea why this is happening.
In the code below int c and int s both have values of zero. However, the map itself has 7 overlays, including the static overlay, all added under the page_load method. Why when accessed under the callback are the collections empty??
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Services;
using ThinkGeo.MapSuite.Core;
using ThinkGeo.MapSuite.WebEdition;
namespace Market_Share_IQ
{
public partial class MainPage : System.Web.UI.Page, ICallbackEventHandler
{
Map_Overlays OverlayClass;
protected void Page_Load(object sender, EventArgs e)
{
OverlayClass = new Map_Overlays();
lblSession.Text = Session["SessionId"].ToString();
if (!IsPostBack)
{
String cbReference = Page.ClientScript.GetCallbackEventReference(this, "arg", "ReceiveServerData", "context");
String callbackScript = "function CallServer(arg, context)" + "{ " + cbReference + ";}";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "CallServer", callbackScript, true);
Map1.CurrentExtent = OverlayClass.GetExtent(Session["SessionId"].ToString());
Map1.MapUnit = GeographyUnit.DecimalDegree;
Map1.StaticOverlay.Layers.Add(OverlayClass.DefineBaseMap());
GeoCollection<Overlay> MapOverlays = OverlayClass.GetOverlays(Session["SessionId"].ToString());
foreach (Overlay mapLOLs in MapOverlays)
{
Map1.CustomOverlays.Add(mapLOLs);
}
}
}
#region ICallbackEventHandler Members
string clearEditOverlayResult = string.Empty;
public string GetCallbackResult()
{
return clearEditOverlayResult;
}
public void RaiseCallbackEvent(string eventArgument)
{
clearEditOverlayResult = string.Empty;
if (eventArgument == "ClearEditOverlay")
{
int c = Map1.CustomOverlays.Count;
int s = Map1.StaticOverlay.Layers.Count;
Map1.CustomOverlays.Clear();
GeoCollection<Overlay> MapOverlays = OverlayClass.GetOverlays(Session["SessionId"].ToString());
LayerOverlay PenetrationOverlay = new LayerOverlay();
PenetrationOverlay.Redraw();
clearEditOverlayResult = "ClearEditOverlaySuccess";
}
}
#endregion