ThinkGeo.com    |     Documentation    |     Premium Support

Province shapefile background color change from database table

Hi,

First of all i wants to thanks to you from your help i done my 80% job now i have another issue which i wants to resolved.

i am going to tell my scenario which is the following

1 i have province shapefile display on my map

2 i have database table which have the following columns

province_name,active

in province name should like name like my shape file. and in active column data will be yes or no

3 i wants to match my shapefile province name with my table province_name and if in active column is there is yes than color that province

for example 

there is a province called ‘kabul’ if in my table column of active if value is yes than kabul all background color change. can you help me in this how should i done this how to match my database table column with my shapefile column ?

so far i done like this.

ShapeFileFeatureLayer province = new ShapeFileFeatureLayer(MapPath("~/Layer/afghanistanprovince.shp"));

       province.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1;

        province.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = new TextStyle(“Prov_Name”, new GeoFont(“Verdana”, 9),

          new GeoSolidBrush(GeoColor.StandardColors.Blue));

            province.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.RequiredColumnNames.Add(“Prov_Name”);

          province.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = new
AreaStyle(new GeoPen(new GeoColor(255, GeoColor.SimpleColors.Blue)));



        province.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;



        province.DrawingFeatures += newLayer_DrawingFeatures;

            Map1.StaticOverlay.Layers.Add(“Province”, province);

           

           

        } 

        }

 

        void newLayer_DrawingFeatures(object sender, DrawingFeaturesEventArgs e)

        {

            ZoomLevel zoomlevel = e.DrawingZoomLevel;

            foreach (Feature feature in e.FeaturesToDraw)

            {

                string provinceName = feature.ColumnValues[“Prov_Name”];

          



                if (provinceName == “Kabul”)

                    {

                    

                 

        

                        zoomlevel.DefaultAreaStyle = new AreaStyle(new GeoPen(new GeoColor(255, GeoColor.SimpleColors.Yellow)));

                    zoomlevel.ApplyUntilZoomLevel=ApplyUntilZoomLevel.Level20;

           

                }

                else

                {

                   

                    zoomlevel.DefaultAreaStyle = new AreaStyle(new GeoPen(new GeoColor(255, GeoColor.SimpleColors.Red)));

                    zoomlevel.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

                }

            }

        }

why my    if (provinceName == “Kabul”) this condition run multiple time i
have only one kabul province in my shape file also my shapefile
defaultareastyle display of else part like this

else

                {

                   

                    zoomlevel.DefaultAreaStyle = new AreaStyle(new GeoPen(new GeoColor(255, GeoColor.SimpleColors.Red)));

                    zoomlevel.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

                }

                    why is that please tell me reason thanks

Hi Raja, 
  
 Please see my reply in other topic. 
  
 thinkgeo.com/forums/tabid/143/aft/12879/Default.aspx 
  
 Regards, 
  
 Don