Register  |  Login
ThinkGeo - GPS Tracking and Mapping Solutions  |  Visit the Wiki  |  Find us on: Twitter Facebook Google+ LinkedIn

Discussion Forums

The online community for users of Map Suite GIS components

Overlay collection
Last Post 07-11-2012 05:51 PM by Gary. 3 Replies.
Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages Not Resolved
PhilUser is Offline
Level 2
Level 2
Posts:33
Avatar

--
07-08-2012 06:49 PM

Hi All,

I have come across something strange and cant explain it.

I was using the following line of code which worked perfectly well for a set of data:

 LayerOverlay staticOverlay = (LayerOverlay)wpfMap1.Overlays[overlayName];

With a different layer it doesnt work. I have found looping though all the overlays and checking if the names match and then assigning the overlay does though??

LayerOverlay staticOverlay = new LayerOverlay();

            foreach (Overlay overlay in wpfMap1.Overlays)
            {

                if (overlay != null)
                {

                    if (overlay.Name == overlayName)
                    {
                        staticOverlay = (LayerOverlay)overlay;
                    }
                }

            }

Isnt this doing exactly the same thing?

thanks

Phil

DavidUser is Offline
MVP
MVP
Posts:1534
Avatar

--
07-08-2012 10:08 PM
Phil,

The two ways of finding the overlay are not the same. When you use the indexer, Overlays["Some Key"] it is searching for the overlay by its string key. It's the string key that was created when you added the overlay to the collection, ie. Overlays.Add("Some Key",overlay). The name on the overlay is just a property that you can optionally set and has nothing to do with the collection look up by string. The name was added so you have along name that can be used for things like legends etc.

Thanks,

David Rehagen
- Need sample code? Check out the Map Suite Code Community at http://code.thinkgeo.com
PhilUser is Offline
Level 2
Level 2
Posts:33
Avatar

--
07-09-2012 05:40 PM
ok thanks David
GaryUser is Offline
MVP
MVP
Posts:1914
Avatar

--
07-11-2012 05:51 PM
Hello Phil.

You are welcome, please feel free to let us know your problems.

Regards,

Gary

Need to know how to do something with Map Suite? Check our Wiki Code Samples Library and view the source code of any sample right in your web browser.

You are not authorized to post a reply.

Active Forums 4.2