ThinkGeo.com    |     Documentation    |     Premium Support

Help me about create dynamic thematic


                MsSql2008FeatureLayer msLayer = ((LayerOverlay)Map1.CustomOverlays[“Province”]).Layers[0] as MsSql2008FeatureLayer;
                msLayer.CommandTimeout = 1200;
                msLayer.Open();
                Collection<Feature> collectFeature = msLayer.QueryTools.GetAllFeatures(new string[] { “PROV_NAME” });
                msLayer.Close();
                LayerOverlay lyOverlay = (LayerOverlay)Map1.CustomOverlays[“ThematicLayer”];
                InMemoryFeatureLayer imf = lyOverlay.Layers[0] as InMemoryFeatureLayer;
                imf.InternalFeatures.Clear();
               
                foreach (DataRow dr in dt.Rows)
                {
                    foreach (Feature ft in collectFeature)
                    {
                        //3.match id
                        if (ft.ColumnValues[“Prov_Name”].ToString() == dr[“PROV_NAME”].ToString())
                        {
                            //4.add value to feature
                            ft.ColumnValues.Add(“thematic”, dr[“AffectAreaByPer”].ToString());
                            //5.add to thematic
                            imf.InternalFeatures.Add(ft);
                            break;
                        }
                    }
                }

                ClassBreakStyle cbs = new ClassBreakStyle(“thematic”);
                cbs.BreakValueInclusion = BreakValueInclusion.IncludeValue;
                cbs.ClassBreaks.Add(new ClassBreak(double.MinValue, AreaStyles.CreateSimpleAreaStyle(GeoColor.SimpleColors.Transparent)));
                cbs.ClassBreaks.Add(new ClassBreak(40, AreaStyles.CreateSimpleAreaStyle(GeoColor.FromHtml("#c0c0c0"), GeoColor.StandardColors.Black)));
                cbs.ClassBreaks.Add(new ClassBreak(60, AreaStyles.CreateSimpleAreaStyle(GeoColor.FromHtml("#ffff99"), GeoColor.StandardColors.Black)));
                cbs.ClassBreaks.Add(new ClassBreak(80, AreaStyles.CreateSimpleAreaStyle(GeoColor.FromHtml("#fcd5b4"), GeoColor.StandardColors.Black)));
                cbs.ClassBreaks.Add(new ClassBreak(double.MaxValue, AreaStyles.CreateSimpleAreaStyle(GeoColor.FromHtml("#ff0000"), GeoColor.StandardColors.Black)));

                imf.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(cbs);
                imf.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
                lyOverlay.Redraw();
                //ScriptManager.RegisterClientScriptBlock(UpdatePanel1, Page.GetType(), “RefreshThematic”, “javascript:Map1.GetMapParser().map.getLayer(‘ThematicLayer’).redraw(true);”, true);
                ScriptManager.RegisterClientScriptBlock(UpdatePanel1, Page.GetType(), “RefreshThematic”, “javascript:RefreshProvinceThematic();”, true);

above code is about create thematic map.


Work flow :


1. select choice from drop down list


2. click for make thematic


3. query report from DB and add to DataTable  (My value is average of area.it’s double type)


4. foreach to add interested column to Layer


5. add it to inmemoryfeature


6. add range style with class brake style.


7. refresh map with javascript.


 end


 


the code isn’ not bug but it not show style.


I think it has problem about column value.it’s string type.  


I think it (column value) can’t use in class break style.because  data type added to Feature is string.


My thematic map need to use ClassBreakStyle for make thematic by range value.


How  do I?   This solution is important for me.


 


another question.


at comment 4 : I have question.


Can Feature.ColumnValues  not add datat type int ?


 I think it should  support another data type to add.


 


 


If you misundertand please tell me


 


thanks so much


 


 


 



Sumeth,


 If you want to have a ClassBreakStyle working with your InMemoryFeatureLayer, you need to add the Column "Thematic" at the level of the InMemoryFeatureLayer itself since you have the ClassBreakStyle for the InMemoryFeatureLayer. I see that you add the value "AffectAreaByPer" to column "thematic" at the feature level, but I don't see in your code where you add the column "thematic" for the InMemoryFeatureLayer.


Add the column "thematic" to the InMemoryFeatureLayer specifying its type. For example:


 


 



imf.Open();
imf.Columns.Add(new FeatureSourceColumn("thematic", DbfColumnType.Integer.ToString(), 10));
imf.Close();


thanks so much.


another question.


 




 Collection<ThinkGeo.MapSuite.Core.Style> coll1 = new Collection<ThinkGeo.MapSuite.Core.Style>();
                coll1.Add(AreaStyles.CreateSimpleAreaStyle(GeoColor.FromHtml("#c0c0c0"), GeoColor.StandardColors.Black));
                coll1.Add(TextStyles.CreateSimpleTextStyle("Prov_Name", "Arial", 12, DrawingFontStyles.Bold, GeoColor.StandardColors.Blue));
                cbs.ClassBreaks.Add(new ClassBreak(double.MinValue, coll1));

                Collection<ThinkGeo.MapSuite.Core.Style> coll2 = new Collection<ThinkGeo.MapSuite.Core.Style>();
                coll2.Add(AreaStyles.CreateSimpleAreaStyle(GeoColor.FromHtml("#ffff99"), GeoColor.StandardColors.Black));
                coll2.Add(TextStyles.CreateSimpleTextStyle("Prov_Name", "Arial", 12, DrawingFontStyles.Bold, GeoColor.StandardColors.Blue));
                cbs.ClassBreaks.Add(new ClassBreak(40, coll2));
                Collection<ThinkGeo.MapSuite.Core.Style> coll3 = new Collection<ThinkGeo.MapSuite.Core.Style>();
                coll3.Add(AreaStyles.CreateSimpleAreaStyle(GeoColor.FromHtml("#fcd5b4"), GeoColor.StandardColors.Black));
                coll3.Add(TextStyles.CreateSimpleTextStyle("Prov_Name", "Arial", 12, DrawingFontStyles.Bold, GeoColor.StandardColors.Blue));
                cbs.ClassBreaks.Add(new ClassBreak(60, coll3));
                Collection<ThinkGeo.MapSuite.Core.Style> coll4 = new Collection<ThinkGeo.MapSuite.Core.Style>();
                coll4.Add(AreaStyles.CreateSimpleAreaStyle(GeoColor.FromHtml("#ff0000"), GeoColor.StandardColors.Black));
                coll4.Add(TextStyles.CreateSimpleTextStyle("Prov_Name", "Arial", 12, DrawingFontStyles.Bold, GeoColor.StandardColors.Blue));
                cbs.ClassBreaks.Add(new ClassBreak(80, coll4));

  I try to add TextStyle and AreaStyle ,but it show area style only.


I don't need to add new layer for create Label.


Do you have anyway to add it?



Sumeth,


 I created a simple sample app where I basically do tha same thing as you are doing except that I have only four point based features. This is a very simplified example but I think that you could get inspired by it. You can see how I have my CkassBreakStyle and the TextStyle displaying fine. Please, take a look at my code, I think it is going to help you.



 


 



Map1.MapUnit = GeographyUnit.DecimalDegree;

//Adds the inMemoryFeatureLayer for car icon and label.
InMemoryFeatureLayer inMemoryFeatureLayer = new InMemoryFeatureLayer();
//Adds column to InMemoryFeatureLayer.
inMemoryFeatureLayer.Open();
inMemoryFeatureLayer.Columns.Add(new FeatureSourceColumn("Thematic", DbfColumnType.Integer.ToString(), 10));
inMemoryFeatureLayer.Columns.Add(new FeatureSourceColumn("Prov_Name", DbfColumnType.String.ToString(), 20));
inMemoryFeatureLayer.Close();


Feature feature1 = new Feature(new PointShape(56,56));
feature1.ColumnValues.Add("Thematic", Convert.ToString(25));
feature1.ColumnValues.Add("Prov_Name", "Province 1");

Feature feature2 = new Feature(new PointShape(10, 80));
feature2.ColumnValues.Add("Thematic", Convert.ToString(75));
feature2.ColumnValues.Add("Prov_Name", "Province 2");

Feature feature3 = new Feature(new PointShape(60, 10));
feature3.ColumnValues.Add("Thematic", Convert.ToString(85));
feature3.ColumnValues.Add("Prov_Name", "Province 3");

Feature feature4 = new Feature(new PointShape(5, 50));
feature4.ColumnValues.Add("Thematic", Convert.ToString(49));
feature4.ColumnValues.Add("Prov_Name", "Province 4");

inMemoryFeatureLayer.Open();
inMemoryFeatureLayer.EditTools.BeginTransaction();
inMemoryFeatureLayer.EditTools.Add(feature1);
inMemoryFeatureLayer.EditTools.Add(feature2);
inMemoryFeatureLayer.EditTools.Add(feature3);
inMemoryFeatureLayer.EditTools.Add(feature4);
inMemoryFeatureLayer.EditTools.CommitTransaction();
inMemoryFeatureLayer.Close();

ClassBreakStyle cbs = new ClassBreakStyle("Thematic");
cbs.BreakValueInclusion = BreakValueInclusion.IncludeValue;
cbs.ClassBreaks.Add(new ClassBreak(double.MinValue, PointStyles.CreateSimplePointStyle(PointSymbolType.Circle, GeoColor.StandardColors.LightBlue, 12)));
cbs.ClassBreaks.Add(new ClassBreak(40, PointStyles.CreateSimplePointStyle(PointSymbolType.Circle, GeoColor.StandardColors.Blue, 12)));
cbs.ClassBreaks.Add(new ClassBreak(60, PointStyles.CreateSimplePointStyle(PointSymbolType.Circle, GeoColor.StandardColors.DarkBlue, 12)));
cbs.ClassBreaks.Add(new ClassBreak(80, PointStyles.CreateSimplePointStyle(PointSymbolType.Circle, GeoColor.StandardColors.Purple, 12)));
cbs.ClassBreaks.Add(new ClassBreak(double.MaxValue, PointStyles.CreateSimplePointStyle(PointSymbolType.Circle, GeoColor.StandardColors.Black, 12)));

TextStyle textStyle = new TextStyle("Prov_Name", new GeoFont("Arial",10),new GeoSolidBrush(GeoColor.StandardColors.Black));
textStyle.XOffsetInPixel = 10;

inMemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(cbs);
inMemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(textStyle);
inMemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

LayerOverlay dynamicOverlay = new LayerOverlay();
dynamicOverlay.Layers.Add(inMemoryFeatureLayer);
Map1.Overlays.Add(dynamicOverlay);

Map1.CurrentExtent = new RectangleShape(0, 100, 100, 0);


Thanks Val, 
 I think I forget add column "Prov_Name" to InMemmoryFeature.  
 Ha ha 
  
 sorry for my forgetful.

Sumeth,


 I am glad I could help you figure out how to fix your code. Any other questions, let us know. Good luck in your development.



Hello!


 This is to inform everybody that a sample project in relation to this post was added recently to the Code Community in ThinkGeo Wiki. The sample, Styles With InMemoryFeatureLayer, can be found a the following link:


wiki.thinkgeo.com/wiki/Map_Suite_Wp...atureLayer