Quantcast
Viewing all articles
Browse latest Browse all 2341

New Post: Troubles with removing layer

Hi
I load the "France" map using the AxMapWinGIS.AxMap control :
 private void Form1_Load(object sender, EventArgs e)
        {
            this.axMap1.Projection = tkMapProjection.PROJECTION_GOOGLE_MERCATOR;
            this.axMap1.TileProvider = tkTileProvider.OpenStreetMap;
            this.axMap1.KnownExtents = tkKnownExtents.keFrance;
            this.axMap1.SendMouseUp = true;
            this.axMap1.MouseUpEvent += axMap1_MouseUpEvent;
           
        }
It works fine... then I draw a polyline using a "memory" shapefile :
 var sf = new Shapefile();
                bool result = sf.CreateNew("", ShpfileType.SHP_POLYLINE);
                if (!result)
                {
                    MessageBox.Show(sf.ErrorMsg[sf.LastErrorCode]);
                }
                else
                {
                    //Ajoute un champ à la table des attributs de
                    int fldTrain = sf.EditAddField("Train", FieldType.STRING_FIELD, 0, 6);

                    //creation d'une forme (shape) de type Polyline.
                    Shape shpPolyline = new Shape();
                    shpPolyline.Create(ShpfileType.SHP_POLYLINE);

                    //Création de deux points
                    Point p1 = new Point();
                    p1.x = -912938.91809663945;
                    p1.y = 5230755.5954941958;
                    shpPolyline.InsertPoint(p1, 0);

                    Point p2 = new Point();
                    p2.x = 1430314.6210137249;
                    p2.y = 6693454.56875933;
                    shpPolyline.InsertPoint(p2, 1);

                    //Insertion de la forme dans le fichier
                    sf.EditInsertShape(shpPolyline, 0);

                    //Mise à jour de la table attribut pour donner un nom à la forme nouvellement créée
                    sf.EditCellValue(fldTrain, 0, numeroTrain);

                    //Ajout du contenu du fichier "Shapefile" dans une nouvelle couche de la carte
                    int handle = carte.AddLayer(sf, true);

                    //carte.ZoomToLayer(handle);

                    carte.Redraw();

                    //Ajout de la couche du train au dictionnaire des couches
                    dicoCouches.Add(numeroTrain, handle);
In the code : "carte" is "axMap" control... and "dicoCouches" is a Dictionary<string,int> to manage my layers..
This works fine and a black line appears across France Map !

But when I try to remove the layer, everything disappear, I got a white area with only coordonates and scale...
public bool SupprimerTronconsTrain(string numeroTrain)
        {
            if (dicoCouches.ContainsKey(numeroTrain))
            {
                int handle = dicoCouches[numeroTrain];
                //this.carte.set_LayerVisible(handle, false); // OK                
                int position = this.carte.get_LayerPosition(handle);
                this.carte.MoveLayerBottom(position);
                this.carte.RemoveLayer(handle);
                
                this.dicoCouches.Remove(numeroTrain);
                return true;
            }
            else
            {
                return false;
            }
        }
I tried to put the layer on bottom before removing it, I tried to set its visibility to false before removing it... (If the visibility is false, the line disappears and I still have the map in the control) ...
But when i call :
this.carte.RemoveLayer(handle);
I always get the blank map !!

So I need some help here :-)
Thanks you

Viewing all articles
Browse latest Browse all 2341

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>