I’m showing vehicle locations on a map, and I’m now trying to add labels to the points. I’ve created a second EditInteractiveOverlay layer in order to hold the labels. I’m setting it up as follows:
01.
EditInteractiveOverlay labelOverlay =
new
EditInteractiveOverlay();
02.
interactiveOverlay.DragControlPointsLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.IsActive =
false
;
03.
interactiveOverlay.EditShapesLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle.IsActive =
false
;
04.
interactiveOverlay.EditShapesLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.IsActive =
false
;
05.
06.
//ValueStyle used for displaying the feature according to the value of the column “Type” for displaying with a bus or car icon.
07.
ValueStyle labelValueStyle =
new
ValueStyle();
08.
labelValueStyle.ColumnName =
“UnitLabel”
;
09.
10.
// AVL
11.
TextStyle unitTextStyle =
new
TextStyle(
“UnitLabel”
,
new
GeoFont(
this
._settings.UnitTextFont,
this
._settings.UnitTextSize, DrawingFontStyles.Regular),
new
GeoSolidBrush(GeoColor.FromHtml(
this
._settings.UnitTextColor)));
12.
unitTextStyle.XOffsetInPixel = 20;
13.
labelValueStyle.ValueItems.Add(
new
ValueItem(
“U”
, unitTextStyle));
14.
15.
// Calls
16.
TextStyle callTextStyle =
new
TextStyle(
“CallLabel”
,
new
GeoFont(
this
._settings.UnitTextFont,
this
._settings.UnitTextSize, DrawingFontStyles.Regular),
new
GeoSolidBrush(GeoColor.FromHtml(
this
._settings.UnitTextColor)));
17.
callTextStyle.XOffsetInPixel = 20;
18.
labelValueStyle.ValueItems.Add(
new
ValueItem(
“C”
, callTextStyle));
19.
20.
labelOverlay.EditShapesLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(labelValueStyle);
21.
labelOverlay.EditShapesLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
22.
23.
labelOverlay.EditShapesLayer.Open();
24.
labelOverlay.EditShapesLayer.Columns.Add(
new
FeatureSourceColumn(
“LabelType”
));
25.
labelOverlay.EditShapesLayer.Columns.Add(
new
FeatureSourceColumn(
“UnitLabel”
));
26.
labelOverlay.EditShapesLayer.Columns.Add(
new
FeatureSourceColumn(
“CallLabel”
));
27.
labelOverlay.EditShapesLayer.Close();
28.
29.
labelOverlay.EditShapesLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.IsActive =
false
;
30.
labelOverlay.EditShapesLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle.IsActive =
false
;
31.
labelOverlay.EditShapesLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.IsActive =
false
;
32.
labelOverlay.EditShapesLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.IsActive =
false
;
33.
34.
this
.map.InteractiveOverlays.Add(
“Labels”
, labelOverlay);
When I try to place the label on the map, I use the following:
01.
PointShape pointShape =
new
PointShape(unit.Status.Longitude, unit.Status.Latitude);
02.
pointShape.Tag = unit;
03.
04.
if
(feature !=
null
)
05.
{
06.
caOverlay.EditShapesLayer.InternalFeatures.Remove(feature);
07.
}
08.
if
(labelFeature !=
null
)
09.
{
10.
labelOverlay.EditShapesLayer.InternalFeatures.Remove(labelFeature);
11.
}
12.
13.
Feature f =
new
Feature(pointShape);
14.
Feature fl =
new
Feature(pointShape);
15.
16.
System.Diagnostics.Debug.WriteLine(
"X: "
+ pointShape.X +
", Y: "
+ pointShape.Y +
", Tag: "
+ unit.UnitId);
17.
f.ColumnValues[
“Type”
] = unit.Agency.AgencyType +
“-”
+ unit.Status.UnitStatusIndicator;
18.
19.
fl.ColumnValues[
“UnitLabel”
] = unit.UnitId;
20.
fl.ColumnValues[
“LabelType”
] =
“U”
;
21.
22.
caOverlay.EditShapesLayer.InternalFeatures.Add(unit.UnitId, f);
23.
labelOverlay.EditShapesLayer.InternalFeatures.Add(unit.UnitId, fl);
I’m not certain why the labels don’t display. The values are being added to the labelOverlay layer because I can see them listed in the collection but they don’t show up on the map. Any suggestions?