how sharpmap supports reflection

Aug 10, 2009 at 5:38 AM

Hi ,

I am very enthusiastic to know how well sharpmap supports the reflection concepts.

Suppose, if there are layers of kind vectorlayer,label layer in sharpmap.map object. And I want to know the type of layers present in a sharpmap.map object using reflection concepts. How can I use the Reflection on sharpmap. Please suggest appropriate solution

Thanks,

RK

Coordinator
Aug 10, 2009 at 12:43 PM

Hi ram282, reflection isn't supported by sharpmap as such - it is an inherent property of the clr type system - each object has the GetType method which gets the Type information for the instance.

I guess the underlying question is along the lines of  "How do I determine the layer type of an arbitary layer in a map's layers collection" 

one way would be along the lines of :

for (ILayer lyr in myMap.Layers)
{
if(lyr is VectorLayer)
{
DoSomethingWithVectorLayer((VectorLayer)lyr);

}
else if (lyr is LabelLayer)
{
DoSomethingWithLabelLayer((LabelLayer)lyr);
}
......

}
or you can safe cast like so :
foreach(ILayer lyr in myMap.Layers)
{
VectorLayer vector = lyr as VectorLayer;
if(vector !=null)
{
DoSomethingWithVectorLayer(vector);
}
}
hth jd
Aug 10, 2009 at 12:57 PM

Thanks Johndiss for ur information.

Aug 10, 2009 at 1:19 PM

I have one more question for you john.

I am using ajax slider extender for controlling the color transparency level of a map. But I am unable to set the transparency of a map. Could u please tell which property in rendering class  or any other class could be used for setting the transparency level.

Thanks in advance

RK

 

Coordinator
Aug 10, 2009 at 1:33 PM

you will need to use colors with an alpha component i.e use Color.FromArgb .The A component controls alpha and is in the range 0 (invisible) to 255(opaque). the rgb components control red green blue and also range 0-255

Aug 10, 2009 at 2:14 PM

Thanks John.

I am using Fill property for rendering color to my map layer. For example here layCountries is a vectorlayer of countries.

<font size="2">

layCountries.Style.Fill =

</font>

new SolidBrush(Color.FromName(Color.Beige))

As you had said, to use Color.FromArgb. Should I use Color.FromArgb method for the fill property ? Or Is there any other property for Color.FromArgb.

If Fill property is used for Color.FromArgb, Should I use either one of the methods ( Color.FromName or Color.FromArgb). Because When I tried to use both these two methods for the Style.Fill property simultaneously I am not getting the correct results.  Could u please post an example on this context.

Thanks,

RK

Coordinator
Aug 10, 2009 at 2:46 PM

try:

layCountries.Style.Fill = new SolidBrush(Color.FromArgb(100, Color.Biege));

hth jd