How forcing a layer be reloaded ?

Developer
Sep 24, 2010 at 9:54 AM

if I have an external application that modify a single shape of my map how can I force a layer in the map be reloaded ?

I've made this little function but may-be there's a better way !

 

_map is a reference tu a Map Object

 

 

        public static void ReloadLayer(string Name)
        {
            int i = GetLayerIndex(Name);  // this function just return the index of a layer named "Name" in _map.Layers[]

            IDataSet dataSet = DataManager.DefaultDataManager.OpenFile(Name);
            IFeatureSet fs = dataSet as IFeatureSet;

            if (fs.FeatureType == FeatureTypes.Point || fs.FeatureType == FeatureTypes.MultiPoint)
            {
                PointLayer myLayer = _map.Layers[i] as PointLayer;
                PointScheme s = new PointScheme();
                s = (PointScheme)myLayer.Symbology;

                IMapPointLayer pl = new MapPointLayer(fs);
                _map.Layers[i] = pl;

                myLayer = _map.Layers[i] as PointLayer;
                myLayer.Symbology = s;

            }

            if (fs.FeatureType == FeatureTypes.Line)
            {
                LineLayer myLayer = _map.Layers[i] as LineLayer;
                LineScheme s = new LineScheme();
                s = (LineScheme)myLayer.Symbology;

                IMapLineLayer ll = new MapLineLayer(fs);
                _map.Layers[i] = ll;

                myLayer = _map.Layers[i] as LineLayer;
                myLayer.Symbology = s;

            }

            if (fs.FeatureType == FeatureTypes.Polygon)
            {
                PolygonLayer myLayer = _map.Layers[i] as PolygonLayer;
                PolygonScheme s = new PolygonScheme();
                s = (PolygonScheme)myLayer.Symbology;

                IMapPolygonLayer pl = new MapPolygonLayer(fs);
                _map.Layers[i] = pl;

                myLayer = _map.Layers[i] as PolygonLayer;
                myLayer.Symbology = s;
            }


        }

Developer
Sep 24, 2010 at 5:01 PM

There is currently a bug where you may have to use myLayer.DataSet.InitializeVertices(); in order to manually get it to update the layer.  Eventually I plan to hunt down that bug and fix it.

Ted