Dear James,
InMemoryMarkerOverlay is an answer for my question.
But when I used InMemoryMarkerOverlay, there are some problems with picture display. Some vessel viewed ok, someone is viewed a small part, someone cannot view.
My code:
Code for add MarkerOverlay:
InMemoryMarkerOverlay vesselMarker = new InMemoryMarkerOverlay("VesselMarker");
vesselMarker.ZoomLevelSet.ZoomLevel01.CustomMarkerStyle = new ValueMarkerStyle("MMSI");
vesselMarker.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
vesselMarker.Click += new EventHandler<MarkerOverlayClickEventArgs>(markerOverlay_Click);
vesselMarker.FeatureSource.Open();
vesselMarker.Columns.Add(new FeatureSourceColumn("MMSI"));
vesselMarker.Columns.Add(new FeatureSourceColumn("IMO"));
vesselMarker.Columns.Add(new FeatureSourceColumn("DisplayName"));
vesselMarker.Columns.Add(new FeatureSourceColumn("COG"));
vesselMarker.Columns.Add(new FeatureSourceColumn("ROT"));
vesselMarker.Columns.Add(new FeatureSourceColumn("SOG"));
vesselMarker.Columns.Add(new FeatureSourceColumn("TypeId"));
vesselMarker.Columns.Add(new FeatureSourceColumn("TypeDesc"));
vesselMarker.Columns.Add(new FeatureSourceColumn("StatusId"));
vesselMarker.Columns.Add(new FeatureSourceColumn("StatusDesc"));
vesselMarker.Columns.Add(new FeatureSourceColumn("Draugth"));
vesselMarker.Columns.Add(new FeatureSourceColumn("Destination"));
vesselMarker.Columns.Add(new FeatureSourceColumn("ETA"));
vesselMarker.Columns.Add(new FeatureSourceColumn("LastReceived"));
vesselMarker.FeatureSource.Close();
vesselMarker.IsBaseOverlay = false;
//vesselMarker.Opacity = 1;
Map1.CustomOverlays.Add(vesselMarker);
Code for add Marker:
private void addMarkers(Collection<Feature> features) {
InMemoryMarkerOverlay vesselMarker = (InMemoryMarkerOverlay)Map1.CustomOverlays["VesselMarker"];
vesselMarker.Features.Clear();
ValueMarkerStyle markerStyle = (ValueMarkerStyle)vesselMarker.ZoomLevelSet.ZoomLevel01.CustomMarkerStyle;
markerStyle.ValueItems.Clear();
foreach (Feature feature in features)
{
Feature targetFeature = convertProjection(feature);
vesselMarker.Features.Add(targetFeature.Id, targetFeature);
MarkerValueItem vessel = new MarkerValueItem(targetFeature.Id);
int statusId = int.Parse(targetFeature.ColumnValues["StatusId"]);
int vesselTypeId = int.Parse(targetFeature.ColumnValues["TypeId"]);
vessel.DefaultMarkerStyle.WebImage = new WebImage(getPathIcon(statusId, vesselTypeId), 18, 18, -9, -9);
vessel.DefaultMarkerStyle.WebImage.RotationAngle = -float.Parse(targetFeature.ColumnValues["Cog"]);
StringBuilder contentHtml = new StringBuilder();
contentHtml.Append("")
.Append(feature.ColumnValues["DisplayName"]);
vessel.DefaultMarkerStyle.Popup.ContentHtml = contentHtml.ToString();
vessel.DefaultMarkerStyle.Popup.Width = 100;
vessel.DefaultMarkerStyle.Popup.Height = 20;
markerStyle.ValueItems.Add(vessel);
}
}