Hello all
we have a project that the user want to show number of project based on province for example if New York has 120 project , we should show the map and change the "NY" to "NY(120 Project)" . we have the name of Province in layer file and number of Project in database. how do i change the value of Column in Layer file?
I can show the Province name of layer file with below code. but i wanna change it. is it possible or not?
foreach (var d in collfeatures) // get all Province in Layer file
{
int ID = Convert.ToInt32(d.ColumnValues[ColumnId]); // Get the ID of Province in Layer File
string ProvinceName=d.ColumnValues[ColumnName].ToString(); // Get the Name of Province in Layer file
Collection<Style> stylecoll = new Collection<Style>(); // Create Style
var data = collGraduatedMapData.Where(a => a.ID == ID).FirstOrDefault(); //get the number of Project based on Province ID
stylecoll.Add(new TextStyle(ColumnName, new GeoFont("Arial", 10, DrawingFontStyles.Regular), new GeoSolidBrush(GeoColor.StandardColors.Black)));
classBreakStyle.ClassBreaks.Add(new ClassBreak(Convert.ToDouble( ID), stylecoll));
layer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(classBreakStyle);
}
layer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(AreaStyles.Country1); layer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
layer.DrawingMarginPercentage = 100;
Proj4Projection proj4 = new Proj4Projection();
proj4.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326);
proj4.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString();
layer.FeatureSource.Projection = proj4;
if (!proj4.IsOpen)
proj4.Open();
graduatedoverlay.Layers.Add(layer);
Changing the Value of layer column
Hi Hassan,
Please try the DrawingFeatures event, in this events, we can change the column value dynamically in memory. Some codes as following:
shapeFileFeatureLayer.DrawingFeatures += BackgroundMapsController_DrawingFeatures;
void BackgroundMapsController_DrawingFeatures(object sender, DrawingFeaturesEventArgs e)
{
foreach (Feature item in e.FeaturesToDraw)
{
int ID = Convert.ToInt32(item.ColumnValues[ColumnId]); // Get the ID of Province in Layer File
var data = collGraduatedMapData.Where(a => a.ID == ID).FirstOrDefault(); //get the number of Project based on Province ID
item.ColumnValues[“Name”] = item.ColumnValues[“Name”] + data;
}
}
Any questions, don’t hesitate to let us know.
Thanks,
Troy
Thank you so much it’s working very well
Great!
Don’t hesitate to let us know if any other questions.
Thanks,
Troy