Hi,
We used an InMemoryMarkerOverlay with an WebImage of a vehicle to represent the location of vehicles for our customer.
We need to display a label for the truck registration on the map so the plan was to place this over the icon for the vehicle.
This turned out not to be possibe as the label was clipped as we used the offset to move the label towards the top of the image. There was no issue in placeing the label over the icon for the vehicle but this would not do for our requirements.
This left 2 other options to consider
- Change the InMemoryMarkerOverlay to an InMemoryFeatureLayer and have more percise control over the labellling
- Retain the InMemoryMarkerOverlay and add a seperate inMemoryFeature layer for the labels only
There was an issue with option 1. I could get PointShapes displaying on the map without any problems but was not sucessful in changing the image of the PointFeature to the required image that we need.
Can you have a brief look and let me know where I've gone wrong [The code below is taken from 2 different methods but joined here for the purpose of the post]
// Create Layer
LayerOverlay overLayer = new LayerOverlay(layerName);
overLayer.IsBaseOverlay = false;
overLayer.IsVisibleInOverlaySwitcher = true;
InMemoryFeatureLayer vehicleLayer = new InMemoryFeatureLayer();
vehicleLayer.Name = "Vehicles";
vehicleLayer.FeatureSource.Open();
vehicleLayer.Columns.Add(new FeatureSourceColumn(VEHICLEREG_LABEL_COLUMN, "string", 100));
vehicleLayer.FeatureSource.Close();
GeoImage truck = new GeoImage(markerWidth, markerHieght);
string fullpath = MapPath(iconUrl);
truck.PathFilename = fullpath;
vehicleLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.Image = truck;
// vehicleLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = new PointStyle(truck);
vehicleLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
vehicleLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.IsActive = true;
vehicleLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.BestPlacement = true;
vehicleLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.RequiredColumnNames.Add(VEHICLEREG_LABEL_COLUMN);
vehicleLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.TextColumnName = VEHICLEREG_LABEL_COLUMN;
vehicleLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.XOffsetInPixel = markerImageOffsetX;
vehicleLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.YOffsetInPixel = markerImageOffsetY;
vehicleLayer.IsVisible = true;
overLayer.Layers.Add("Vehicles", vehicleLayer);
this.Map1.CustomOverlays.Add(overLayer);
///////////////////////////////////////////
// Code in Seperate method to add the features
LayerOverlay overlay = (LayerOverlay)this.Map1.CustomOverlays[targetLayer];
InMemoryFeatureLayer vehicleLayer = (InMemoryFeatureLayer)overlay.Layers["Vehicles"];
Feature vehicle = new Feature(longitude.Value, lattitude.Value, id);
vehicle.ColumnValues[VEHICLEREG_LABEL_COLUMN] = "vehicle reg";
vehicleLayer.InternalFeatures.Add(vehicle);
vehicleLayer.IsVisible = true;
overlay.Redraw();
With respect to Option 2 above - Is this a viable option.
What would the impact of creating a InMemoryFeatureLayer seperate layer for labels be [outside from the fact that the layers could be switched on or off as required and also that that the Vehcile layer is independant fromthe labels]. Are there performance considerations.
We have to take into account with the decision above that we will proablably be adding a vehicle breadcrumb also but there are some fairly good samples on this in your site,
Rgds,
Liam