Register  |  Login   Search
ThinkGeo - GPS Tracking and Mapping Solutions  |  Home  |  Cygnus Track  |  Developer Community
 
LivePerson Chat

Discussion Forums

The online community for users of Map Suite GIS components

Possible bug found. re: Layers.Clear()
Last Post 10-08-2008 10:37 AM by Ryan. 4 Replies.
Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
TimothyUser is Offline
Level 1
Level 1
Posts:6

--
07-15-2008 12:12 PM

If you have shapefiles loaded and you use Map.Layers.Clear(); and then try to reload the same shapefile you get an error.

To overcome this I had to use

for(int i=0;i

Map.Layers.Remove(Map.Layers[i]);

 

Also, Map.Layers.RemoveAt[i] did not work.

TimothyUser is Offline
Level 1
Level 1
Posts:6

--
07-15-2008 05:03 PM

 

of course there was a bug in that code the real code would look like:

 

int counter=Map.Layers.Count;

for(int i=0;i

Map.Layers.Remove(Map.Layers[0]);

 

 

 

 

ValUser is Online
MVP
MVP
Posts:69
Avatar

--
07-16-2008 12:35 PM
We tested the functions Layers.Clear and Layers.RemoveAt() as you described but we did not find any problem. We would need more information on how you are using those functions. Thank you.
TimothyUser is Offline
Level 1
Level 1
Posts:6

--
07-22-2008 04:22 PM

Assuming you have a Form with a Map control containing no layers setup to display on the form.....

 

This does not work(Clear()):

            Layer l = new Layer(@"\My Documents\shps\Test.shp");
            mapdisplay.Layers.Add(l);
            mapdisplay.Layers.Clear();
            Layer l2 = new Layer(@"\My Documents\shps\Test.shp");
            mapdisplay.Layers.Add(l2);

 

This does not work(RemoveAt()):

           Layer l = new Layer(@"\My Documents\shps\Test.shp");
            mapdisplay.Layers.Add(l);
            mapdisplay.Layers.RemoveAt(0);
            Layer l2 = new Layer(@"\My Documents\shps\Test.shp");
            mapdisplay.Layers.Add(l2);

 

This does work(Remove()):

            Layer l = new Layer(@"\My Documents\shps\Test.shp");
            mapdisplay.Layers.Add(l);
            mapdisplay.Layers.Remove(mapdisplay.Layers[0]);
            Layer l2 = new Layer(@"\My Documents\shps\Test.shp");
            mapdisplay.Layers.Add(l2);

 

For the code that does not work, I get an Argument Exception: "Value does not fall within the expected range" .

 

I hope this is helpful.

Thanks again.

 

 

RyanUser is Offline
ThinkGeo Support
MVP
MVP
Posts:176
Avatar

--
10-08-2008 10:37 AM
Timothy,

The reason these functions are not working is due to a lack of a defined MapUnit. Please added the following line of code to your app:

map1.MapUnit = MapLengthUnits.DecimalDegrees;

ThinkGeo Support
You are not authorized to post a reply.

Active Forums 4.1