ThinkGeo.com    |     Documentation    |     Premium Support

Style not being applied to Features in Layer

I am building a map with InMemoryFeatureLayers that were saved in an XML file. I read the LayerDescriptors (one of my classes) from the XML and then reconstitute the layer based on the descriptor.

InMemoryFeatureLayer imfl;
foreach (var layer in xmlView.LayerDescriptors)
{
    imfl = new InMemoryFeatureLayer();
    imfl.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = (AreaStyle)layer.DefaultAreaStyleDescriptor.ToInstance();
    imfl.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = (LineStyle)layer.DefaultLineStyleDescriptor.ToInstance();
    imfl.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
    imfl.Name = layer.LayerName;
    foreach (string f in layer.ShapeTexts)
    {
        var nf = new Feature(f);
        imfl.InternalFeatures.Add(nf);
    }
                
    this.Layers.Add(imfl);
}

The shapes are appearing on the map, but the pen and area brush are always black and the area is set to 100% transparent even tho the AreaStyle FIllSolidBrush is not set to black nor transparent. Am I applying the Default Styles incorrectly?

Dave

Hi Dave,

I think maybe the areastyle from your XML hadn’t been assigned to the default style succeed.

Please do some test like this:

  1. Assign a style to InMemoryFeatureLayer, the style should be created by AreaStyles.CreateSimpleAreaStyle. You can see whether that works for the InMemoryFeatureLayer. I think it should works well. And please don’t modify the IsActive for zoomlevel01 when test.

  2. Compare the (AreaStyle)layer.DefaultAreaStyleDescriptor.ToInstance() and your built area style, we need to know whether they are the same one.

If you hadn’t found the problem after the test, please built a simple sample and upload here, we can help you do some research about it.

Regards,

Don

It looks like the InMemoryFeatureLayer is getting set to me. Here is my latest code, using AreaStyles.CreateSimpleAreaStyle() as directed.

InMemoryFeatureLayer imfl;
foreach (var layer in xmlView.LayerDescriptors)
{
	imfl = new InMemoryFeatureLayer();                    
	imfl.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle((layer.DefaultAreaStyleDescriptor.ToInstance() as AreaStyle).FillSolidBrush.Color);
	imfl.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = (LineStyle)layer.DefaultLineStyleDescriptor.ToInstance();
	imfl.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
	imfl.Name = layer.LayerName;
	foreach (string f in layer.ShapeTexts)
	{
		var nf = new Feature(f);
		imfl.InternalFeatures.Add(nf);
	}		
	this.Layers.Add(imfl);		
}

And here is the state of both layer.DefaultAreaStyleDescriptor.ToInstance() and imfl.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle from the VS2015 Immediate window.

layer.DefaultAreaStyleDescriptor.ToInstance()
{ThinkGeo.MapSuite.Core.AreaStyle}
	Advanced: {ThinkGeo.MapSuite.Core.AreaStyleAdvanced}
	CustomAreaStyles: Count = 0
	FillSolidBrush: {ThinkGeo.MapSuite.Core.GeoSolidBrush}
	IsActive: true
	Name: ""
	OutlinePen: {ThinkGeo.MapSuite.Core.GeoPen}
	PenBrushDrawingOrder: BrushFirst
	RequiredColumnNames: Count = 0
	XOffsetInPixel: 0
	YOffsetInPixel: 0
imfl.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle
{ThinkGeo.MapSuite.Core.AreaStyle}
	Advanced: {ThinkGeo.MapSuite.Core.AreaStyleAdvanced}
	CustomAreaStyles: Count = 0
	FillSolidBrush: {ThinkGeo.MapSuite.Core.GeoSolidBrush}
	IsActive: true
	Name: ""
	OutlinePen: {ThinkGeo.MapSuite.Core.GeoPen}
	PenBrushDrawingOrder: BrushFirst
	RequiredColumnNames: Count = 0
	XOffsetInPixel: 0
	YOffsetInPixel: 0
(layer.DefaultAreaStyleDescriptor.ToInstance() as AreaStyle).FillSolidBrush.Color
{ThinkGeo.MapSuite.Core.GeoColor}
	AlphaComponent: 180
	BlueComponent: 225
	GreenComponent: 105
	Hue: 225
	IsTransparent: false
	Luminance: 0.5686275
	RedComponent: 65
	Saturation: 0.727272749
imfl.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.FillSolidBrush.Color
{ThinkGeo.MapSuite.Core.GeoColor}
	AlphaComponent: 180
	BlueComponent: 225
	GreenComponent: 105
	Hue: 225
	IsTransparent: false
	Luminance: 0.5686275
	RedComponent: 65
	Saturation: 0.727272749

If nothing looks wrong with this code I’ll create a simple sample in the morning. (+6 GMT here)

Hi Dave,

Please attach your sample here or upload that into our FTP if it’s private or big. You can get the FTP account from your sales.

Regards,

Don

My bad… the most recent code I posted does work.

Thank you for the help.

Dave

Hi Dave,

I am glad to hear that works.

Any question please let us know.

Regards,

Don