ThinkGeo.com    |     Documentation    |     Premium Support

Displaying Labels on a highlighted InMemoryFeatureLayer

Hi,


I am doing something very similar to the code in diplay a particular country map but I want to display a label on what is highlighted.


Here is a snippet of the code I am using:


 



LabelStyle = TextStyles.CreateSimpleTextStyle("Label", "Arial", 8, DrawingFontStyles.Italic, GeoColor.StandardColors.Black, 3, 3);
...
// Add Hilighted feature layer
InMemoryFeatureLayer hiliteShapeLayer = new InMemoryFeatureLayer();
hiliteShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = thisAreaStyle;
hiliteShapeLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = LabelStyle;
hiliteShapeLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

LayerOverlay dynamicOverlay = new LayerOverlay("HiLighted" + (LayerCount + 1));
dynamicOverlay.Layers.Add("InMemoryFeatureLayer" + LayerCount, hiliteShapeLayer);
dynamicOverlay.IsBaseOverlay = false;
dynamicOverlay.TileType = TileType.SingleTile;

Map1.CustomOverlays.Add(dynamicOverlay);

Collection<string> listOfColumsToReturn = new Collection<string>();
listOfColumsToReturn.Add("IDColumn");
listOfColumsToReturn.Add("Label");



foreach(string strID in ListOfIDs) {
Collection<Feature> features = myBaseLayer.QueryTools.GetFeaturesByColumnValue("IDColumn", strID, listOfColumsToReturn);
listOfFeatures.Add(features);
}

hiliteShapeLayer.InternalFeatures.Clear();

foreach(Collection<Feature> features in listOfFeatures) {
foreach(Feature feature in features) {
if(!hiliteShapeLayer.InternalFeatures.Contains(feature.Id)) hiliteShapeLayer.InternalFeatures.Add(feature.Id, feature);
}
}

((LayerOverlay)Map1.CustomOverlays[LayerCount + 1]).Redraw();

I just can't seem to get the Labels to show.  They do show up on myBaseLayer if I apply the text style there, but not on the hiliteShapeLayer.  What am I doing wrong?



David,


I checked your code and found out you missed one thing in your code, you didn't add the display column to the InMemoryFeatureLayer, please add the following code to your application and try again:


 



  hiliteShapeLayer.Open();
  hiliteShapeLayer.Columns.Add(new FeatureSourceColumn("Label"));
  hiliteShapeLayer.Close();
Please notice, the code above you should be in front of the add feature operations for the hiliteShapeLayer.


Any more questions please let me know,


Thanks,


Scott,



That solved it.  Thank you so much!



David, 
  
 That’s great!  
  
 Any more questions please let us know, 
  
 Thanks, 
  
 Scott,