Success, and is it ever easy.
In your main class: (I am using the DemoMap example)
In your main class: (I am using the DemoMap example)
public FeatureSet dbMarkers = null;
public MapPointLayer dbMarkerLayer;
public MapLabelLayer dbLabelLayer;
In your housekeeping or config section: ProjectionInfo wgs = map1.Projection;
// The FeatureSet starts with no data; be sure to set it to the point featuretype
this.dbMarkers = new FeatureSet ( FeatureType.Point );
this.dbMarkers.Projection = wgs;
this.dbMarkers.DataTable.Columns.Add("label").DataType = System.Type.GetType("System.String");
// The MapPointLayer controls the drawing of the marker features
this.dbMarkerLayer = new MapPointLayer ( this.dbMarkers );
this.dbLabelLayer = new MapLabelLayer ( dbMarkerLayer );
dbMarkerLayer.LabelLayer = this.dbLabelLayer;
// this is the expression for the label drawing
this.dbLabelLayer.Symbology.Categories [ 0 ].Expression = "[label]";
// The Symbolizer controls what the points look like
this.dbMarkerLayer.Symbolizer = new PointSymbolizer ( Color.Blue, DotSpatial.Symbology.PointShape.Star, 15 );
this.dbMarkerLayer.Symbolizer.IsVisible = true;
this.dbLabelLayer.Symbolizer.FontSize = 9F;
//add feature set to map
map1.Layers.Add ( this.dbMarkerLayer );
this.dbMarkerLayer.LegendText = "Points From Sqlite";
this.dbMarkerLayer.ShowLabels = true;
this.dbLabelLayer.LegendText = "Point Labels";
In your database routine, probably the loop where you extract the queried items: coord = MainForm.GeographicToWebMercator ( equipLat, equipLng );
point = new DotSpatial.Topology.Point ( coord );
feature = this.dbMarkers.AddFeature ( point );
label = "[" + equipDescription + "]";
feature.DataRow [ "label" ] = label;
It does not require a Label layer. This method attaches to the marker layer. Deselecting the Marker layer in the legend hides the point graphic and the label. Precisely what I wanted.