ThinkGeo.com    |     Documentation    |     Premium Support

Zooming of zedgraph with zooming of winformMap all overlays

Hello,


I am displaying Bargraph on particular layer on winform map control..It display the proper bargraph.but when i apply zooming on map,it goes off.I want that bargraph on inmemoryfeaturelayer.I created inmemoryFeatureLayer constructor.Actually i am using mainform as MDI form where my winformmap control is there.ANd i have another form called Symbology where i am calling Mainform's WinformMap control.Even i am passing Shape file name (which i have selected) to symology form so it open that layer file.


I have attached the source code.While running i am getting error as you cant type cast layer from Shapefilefeatuer layer to InmemoryFeature layer eventhough i have used typecasting.Please refer code and help me.


 



zedgraph.txt (5.62 KB)

ashwini,


From your code snippet we found that you wanted to cast ShapeFileFeatureLayer into InMemoryFeatureLayer, unfortunately you can't do this because ShapeFileFeatureLayer and InMemoryFeatureLayer don't have direct relationship, they are just concreted-classes which inherit from FeatureLayer. You should do the follwing steps to copy features from ShapeFileFeatureLayer to InMemoryFeatureLayer:


1. Get ShapeFileFeatureLayer's column structure and add columns to InMemoryFeatureLayer


2. Get ShapeFileFeatureLayer's features and add them into InMemoryFeatureLayer


Please let us know if you have further questions.


Regards,


Ivan



 thank you for reply.


Will you just elaborate on that plz.i didnt get how to map ShapeFilefeaturelayer's Column to InmemoryFeatureLayer?



Ashwini,


Here is the code snippet for guiding you how to get all of the features and columns from ShapeFileFeatureLayer and create the spectial InMemoryFeatureLayer below:


 



   InMemoryFeatureLayer inMemoryFeatureLayer = new InMemoryFeatureLayer();
            
            worldLayer.Open();
            Collection<Feature> features = worldLayer.FeatureSource.GetAllFeatures(ReturningColumnsType.AllColumns);
            Collection<FeatureSourceColumn> columns = worldLayer.FeatureSource.GetColumns();
            worldLayer.Close();

            foreach (FeatureSourceColumn column in columns)
            {
                inMemoryFeatureLayer.Columns.Add(column);
            }

            foreach(Feature feature in features)
            {
                inMemoryFeatureLayer.InternalFeatures.Add(feature);
            }

Thanks,


Scott,