Hi, I have a live map which updates on events being fired from business objects that are being run on background threads. In 2.0 this seemed like a rather simple task but I am struggling to figure out how to get it to work in 3.0. Below is the 2.0 code and I have also attached what I have for the same method in 3.0, 3.0 is giving me fits with it's validation so there might be some stuff in here that looks odd at the moment. I had to add the synchronized hashtable in 3.0 because it won't allow me to add a lineshape feature with only 1 point in it, validation issues. Anyway, the vertex collection seems to be getting updated but nothing draws on the screen, any ideas at the moment or any suggestions on better ways to implement this in 3.0? This just seems clunky to me...
Thanks.
Curtis
private void asset_PositionAdded(object sender, AssetPositionAddedEventArgs e) { GeoPen pen = new GeoPen(new GeoSolidBrush(GeoColor.GetRandomGeoColor(ColorType.Bright)), 6); pen.SetLineCap(LineCap.Round, LineCap.Round); if(enableTruckTrack) { LineMapShape lineMapShape = (LineMapShape)Map1.MapShapes[e.Position.Asset.AssetId.ToString()]; if(lineMapShape == null) { LineShape lineShape = new LineShape(); lineShape.Points.Add(new PointShape(e.Position.convertToDecimalDegrees(e.Position.Longitude), e.Position.convertToDecimalDegrees(e.Position.Latitude))); lineMapShape = new LineMapShape(lineShape); lineMapShape.Symbols.Add(new LineSymbol(pen)); Map1.MapShapes.Add(e.Position.Asset.AssetId.ToString(), lineMapShape); } else { LineShape lineShape = (LineShape)lineMapShape.Shape; lineShape.Points.Add(new PointShape(e.Position.convertToDecimalDegrees(e.Position.Longitude), e.Position.convertToDecimalDegrees(e.Position.Latitude))); } } DrawTruck(e.Position); Map1.RefreshDynamic(); }
private void asset_PositionAdded(object sender, AssetPositionAddedEventArgs e) { GeoPen pen = new GeoPen(new GeoSolidBrush(GeoColor.StandardColors.Blue)); pen.SetLineCap(DrawingLineCap.Round, DrawingLineCap.Round, GeoDashCap.Round); pen.Width = 6; Hashtable synchronizedAssetLines = Hashtable.Synchronized(assetLines); if (enableTruckTrack) { InMemoryFeatureLayer truckTrackLayer = (InMemoryFeatureLayer)Map.FindFeatureLayer(e.Position.Asset.AssetId.ToString() + "|Track"); if (truckTrackLayer == null) { LineShape lineShape = new LineShape(); lineShape.Vertices.Add(new Vertex(e.Position.convertToDecimalDegrees(e.Position.Longitude), e.Position.convertToDecimalDegrees(e.Position.Latitude))); synchronizedAssetLines.Add(e.Position.Asset.AssetId.ToString(), lineShape); truckTrackLayer = new InMemoryFeatureLayer(); truckTrackLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = new LineStyle(pen); truckTrackLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; Map.DynamicOverlay.Layers.Add(e.Position.Asset.AssetId.ToString() + "|Track", truckTrackLayer); } else { // If the hashtable contains the asset then we need to generate the layer and remove the asset from the hashtable. if (synchronizedAssetLines.ContainsKey(e.Position.Asset.AssetId.ToString())) { LineShape lineShape = (LineShape)synchronizedAssetLines[e.Position.Asset.AssetId.ToString()]; synchronizedAssetLines.Remove(e.Position.Asset.AssetId.ToString()); lineShape.Vertices.Add(new Vertex(e.Position.convertToDecimalDegrees(e.Position.Longitude), e.Position.convertToDecimalDegrees(e.Position.Latitude))); truckTrackLayer.InternalFeatures.Add("Track", new ThinkGeo.MapSuite.Core.Feature(lineShape)); } else { LineShape lineShape = (LineShape)truckTrackLayer.InternalFeatures["Track"].GetShape(); lineShape.Vertices.Add(new Vertex(e.Position.convertToDecimalDegrees(e.Position.Longitude), e.Position.convertToDecimalDegrees(e.Position.Latitude))); truckTrackLayer.InternalFeatures["Track"] = new ThinkGeo.MapSuite.Core.Feature(lineShape); } } } DrawTruck(e.Position); Map.RefreshDynamic(); }