I have some drawing tools and I have added a custom style. The shapes are added to the layer one at a time so the last one added is the one on top.
When the style is applied and DrawCore method is called the IEnumerable<Feature> features is not in the order that it was added but instead is grouped with the line shapes together even though they had a polygon in between them.
The layer had line, polygon, line; added in that order and I can verify that is correct when I look at that layers internal features. When the style is applied the collection of features is line, line, polygon and now the polygon coveres both of the lines. They look like they are in the wrong order.
My style override class:
publicclassGranularStyle : Style{#region StyleOverrides
protectedoverridevoidDrawCore(IEnumerable<Feature> features, GeoCanvas canvas, System.Collections.ObjectModel.Collection<SimpleCandidate> labelsInThisLayer, System.Collections.ObjectModel.Collection<SimpleCandidate> labelsInAllLayers){foreach(Feature featureinfeatures){var style =newStyleFactory().CreateStyle(feature);style.DrawShape(canvas);}}
#endregion}
The shapes are added to my drawing layer from the track layer after the shape has finished drawing when the TrackEnded event fires
privatevoidHandleDrawEnded(objectsender, TrackEndedTrackInteractiveOverlayEventArgs e){MoveTrackOverlayToDrawingLayer();}
privatevoidMoveTrackOverlayToDrawingLayer(TextBoxDrawingControlViewModel textProperties =null,stringshapeId =null){LayerOverlay layerOverlay = NewOrExistingLayerOverlay(_drawingGroup);//FeatureLayer featureLayer = (FeatureLayer)layerOverlay.Layers[_drawingLayer];InMemoryFeatureLayer featureLayer = (InMemoryFeatureLayer)layerOverlay.Layers[_drawingLayer];
GeoCollection<Feature> featureCollection = _mapControl.TrackOverlay.TrackShapeLayer.InternalFeatures;featureLayer.FeatureSource.Open();featureLayer.FeatureSource.BeginTransaction();
foreach(Feature featureinfeatureCollection){
if(feature !=null&& feature.ColumnValues !=null){
feature.ColumnValues.Add(MapStyleAttributes.WidthColumnName, _lineWidth.ToString());feature.ColumnValues.Add(MapStyleAttributes.ColorColumnName, _lineColor);feature.ColumnValues.Add(MapStyleAttributes.TransparencyColumnName,string.Format("{0}", _fillOpacity));if(textProperties !=null){feature.ColumnValues.Add(MapStyleAttributes.TextColumnName,string.Format("{0}", textProperties.Text));feature.ColumnValues.Add(MapStyleAttributes.RotationColumnName,string.Format("{0}", textProperties.Rotation));feature.ColumnValues.Add(MapStyleAttributes.FontFamilyColumnName,string.Format("{0}", textProperties.FontFamily));feature.ColumnValues.Add(MapStyleAttributes.FontStyleColumnName,string.Format("{0}", textProperties.FontStyle));feature.ColumnValues.Add(MapStyleAttributes.FontSizeColumnName,string.Format("{0}", textProperties.FontSize));feature.ColumnValues.Add(MapStyleAttributes.ShapeIdColumnName, shapeId);}//featureLayer.FeatureSource.AddFeature(feature);featureLayer.InternalFeatures.Add(feature);featureLayer.FeatureSource.UpdateFeature(feature);
}}featureLayer.FeatureSource.CommitTransaction();featureLayer.FeatureSource.Close();_mapControl.TrackOverlay.TrackShapeLayer.InternalFeatures.Clear();_mapControl.Refresh(newOverlay[] {_mapControl.EditOverlay, _mapControl.TrackOverlay});_mapControl.Refresh(layerOverlay);}
Is there a way to force the custom style’s feature collection to be in the correct order?