Hi,
All i want to display is countries filled with some colour and with custom data displaying on top of each country name base on some criteria. I have achieved success in fiiling the country with a colour however the custom column fetch event is not getting fired through which i can add custom data.
Here is the code snippet that is not working fine for me:-
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using ThinkGeo.MapSuite.Core;
using ThinkGeo.MapSuite.WebEdition;
using System.Collections.ObjectModel;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Map1.MapBackground.BackgroundBrush = new GeoSolidBrush(GeoColor.FromHtml("#E5E3DF"));
Map1.CurrentExtent = new RectangleShape(-131.22, 55.05, -54.03, 16.91);
Map1.MapUnit = GeographyUnit.DecimalDegree;
WorldMapKitWmsWebOverlay worldMapKitOverlay = new WorldMapKitWmsWebOverlay();
Map1.CustomOverlays.Add(worldMapKitOverlay);
ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(MapPath("~/World/cntry02.shp"));
AreaStyle areaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.SimpleColors.Transparent, GeoColor.FromArgb(100, GeoColor.SimpleColors.Green));
worldLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(areaStyle);
// Draw a feature based on a value
string stt1 = string.Empty, stt2 = string.Empty, stt3 = string.Empty;
stt1 = Request.QueryString["a"];
stt2 = Request.QueryString["b"];
stt3 = Request.QueryString["c"];
string con = ConfigurationManager.ConnectionStrings["lok"].ConnectionString;
SqlConnection sqlcon = new SqlConnection(con);
sqlcon.Open();
SqlCommand cmd = new SqlCommand(@"select distinct " + stt1 + " cntry_name from country_tb where " + stt2 + stt3);
cmd.Connection = sqlcon;
SqlDataReader sdr = cmd.ExecuteReader();
string agent_name = string.Empty;
if (sdr.HasRows)
{
while (sdr.Read())
{
ValueStyle valueStyle = new ValueStyle();
valueStyle.ColumnName = "CNTRY_NAME";
valueStyle.ValueItems.Add(new ValueItem(sdr[0].ToString(), new AreaStyle(new GeoSolidBrush(GeoColor.StandardColors.LightGreen))));
worldLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(valueStyle);
worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
}
}
worldLayer.FeatureSource.CustomColumnFetch += new EventHandler<CustomColumnFetchEventArgs>(FeatureSource_CustomColumnFetch);
worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.RequiredColumnNames.Add("Test");
LayerOverlay staticOverlay = new LayerOverlay();
staticOverlay.IsBaseOverlay = false;
staticOverlay.Layers.Add("worldLayer", worldLayer);
Map1.CustomOverlays.Add(staticOverlay);
}
void FeatureSource_CustomColumnFetch(object sender, CustomColumnFetchEventArgs e)
{
if (e.Id == "135" || e.Id == "47")
{
string columnName = e.ColumnName;
e.ColumnValue = "CountryId:" + e.Id;
}
}
}