I have been porting some code from the WpfMap in the Desktop Edition to the WPF Desktop Edition. What's weird is that without changing the logic that is adding several Layers to the LayerOverlay, they are now rendering in a different order than they were in the Desktop Edition. I managed to get it partially fixed by calling Layers.MoveToBottom after I add each layer, but that seemed to only work for my shape file layers. We also have a custom layer that no matter what I do it rendering the points behind the shapefiles lines.
One thing that I did try was to separate the Shapefiles from the custom Layer into different Overlays. This did successfully render the custom layer on top but the performance of the second overlay containing the shapefiles was EXTREMELY slow. Why would this be?
We tested the layer ordering issue you mentioned, but we haven’t reproduced the issue. You can see the result in the screen shot above.
We used the same code to add 3 layers in both of the samples. We added Countries02.shp, USStates.shp and MajorCities.shp; you can find all of them in the install folder of WPF Desktop Edition. As we can see in both of the samples, USStates.shp is covering Countries02.shp and MajorCities.shp is covering USStates.shp, they are rendering in the same order.
So we’d need more information from you, like, what kind of data are you using? Are they lines, polygons or points? It would be ideal if you can send us some sample code and sample data that can precisely reproduce this issue.
Here is some code that reproduces the ordering problem. The way I understand it is that when you add a Layer to an Overlay it is added as the top most layer (at least that's how Desktop Edition used to behave), but in this code, even when calling Layers.MoveToTop(), it still doesn't render the point on top of the shapefile lines.
LayerOverlay layerOverlay = new LayerOverlay(); layerOverlay.Layers.Add("Background", new BackgroundLayer(new GeoSolidBrush(GeoColor.GeographicColors.Sand)));
ShapeFileFeatureLayer austinStreets = new ShapeFileFeatureLayer(@"C:\Program Files (x86)\ThinkGeo\Map Suite Wpf Desktop Evaluation Edition 4.5\Samples\CSharp Samples\SampleData\Data\Austinstreets.shp"); layerOverlay.Layers.Add("Streets", austinStreets);
I’m having the same issue of points behind the lines with 4.5.15.0
This is the code:
Private Sub WpfMap1_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles WpfMap1.Loaded WpfMap1.MapUnit = GeographyUnit.DecimalDegree WpfMap1.CurrentExtent = New RectangleShape(-50, 16, 66, -50)
WpfMap1.BackgroundOverlay.BackgroundBrush = New GeoSolidBrush(GeoColor.FromArgb(255, 198, 255, 255))
Dim worldLayer As ShapeFileFeatureLayer = New ShapeFileFeatureLayer(System.Windows.Forms.Application.StartupPath & “\Data\Countries02.shp”) worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.County1 worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20
Dim layerOverlay As LayerOverlay = New LayerOverlay() layerOverlay.Layers.Add(“worldLayer”, worldLayer)
'Adds the Overlay that contains the lines and points Dim TracksOverlay As New LayerOverlay TracksOverlay.TileType = TileType.SingleTile WpfMap1.Overlays.Add(“TracksOverlay”, TracksOverlay)
Dim InMemoryTrackFeatureLayer As New InMemoryFeatureLayer InMemoryTrackFeatureLayer.ZoomLevelSet.ZoomLevel03.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.StandardColors.Red, 3, True) InMemoryTrackFeatureLayer.ZoomLevelSet.ZoomLevel03.DefaultPointStyle = PointStyles.City2 InMemoryTrackFeatureLayer.ZoomLevelSet.ZoomLevel03.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20 InMemoryTrackFeatureLayer.Open()
Dim LS As New LineShape() LS.Vertices.Add(New Vertex(0, 1)) LS.Vertices.Add(New Vertex(2, 1))
'Adds the point before InMemoryTrackFeatureLayer.InternalFeatures.Add(New Feature(New PointShape(0.5, 1).GetWellKnownText, “Track1Point1”)) 'Adds the line InMemoryTrackFeatureLayer.InternalFeatures.Add(New Feature(LS.GetWellKnownText, “Track1”)) 'Adds the point after InMemoryTrackFeatureLayer.InternalFeatures.Add(New Feature(New PointShape(1, 1).GetWellKnownText, “Track1Point2”))
WpfMap1.CurrentExtent = TracksOverlay.GetBoundingBox() WpfMap1.Refresh() End Sub
As you can see, no mater the order I add the Features to the Layer, the LineShape is always drawn on top. In addition, when this happens and I try to GetFeaturesNearestTo the point, the points are never detected, only the line.
Although it looks like the issue Craig encountered, but it is a whole different situation. Lines and points in the same InMemoryFeatureLayer do tend to overlap each other; it’s caused by some historical reasons. We still haven’t decided if we’ll fix it or not, we’ll let you know when we do.
Before the fix that may or may not come out, we have some workaround for you: 1. Avoid setting inner color and center color for line styles. The outer color of line won’t cover up any points. 2. Use different InMemoryFeatureLayers for points and lines, this way, the lines won’t cover up the points and we have no limitation on using styles.
We are sorry for any inconvenience this may have caused, and we’ll let you know if we’ll fix it.
It surprises me you are not willing to correct any reported bug, even more being such a basic thing. The expected behavior would be to overlap or not depending on the order you add the layers as with the rest of the features/elements. The component model should be coherent.
The problem of lines covering up points is rooted deep down in the Map Suite Core’s drawing logic. It’ not that we don’t want to fix it, it’s just a little bit too risky to do so. If we just simply move the points’ drawing logic to a higher level, it sure will fix this one issue, but we are not sure if it’ll cause some other problems. We’ve done some discussion and tests in the Core team, and we’ll let you know when we got a final solution. We were just being cautious rather than ignoring bugs. Hope you can understand and sorry for the inconvenience.