MultiLayerPointSymbol containing SimpleMarkerSymbol not visualized in Runtime 100.11+ versions

1833
27
09-27-2022 04:18 AM
stuartkerkhof
New Contributor

Hi,

In my application I am using multilayerpointsymbols to create complex symbols. Sometimes one of these layers may even contain a simplemarkersymbol.  This is for example useful if the symbol should contain one or more circles, connected by lines for example.

Below code shows how I use the simplemarkersymbol combined with multilayerpointsymbols. This used to work fine. For readability I simplified a bit of the code. In the actual code I read symbol geometry elements from a JSON file, but that will be harder to analyze. 

            SolidStrokeSymbolLayer lineSymbol = new SolidStrokeSymbolLayer(1, Color.Black);

            List<SymbolLayer> symbolLayers = new List<SymbolLayer>
                {
                    lineSymbol
                };

            MultilayerPolylineSymbol multilayerPolylineSymbol = new MultilayerPolylineSymbol(symbolLayers);

            List<MapPoint> mapPoints = new List<MapPoint>();

            Coordinate[] coordinatesArray = new Coordinate[] { new Coordinate(0, 0), new Coordinate(5, 0), new Coordinate(5, 2), new Coordinate(5, -2) };

            foreach (Coordinate coordinate in coordinatesArray)
            {
                mapPoints.Add(new MapPoint(coordinate.X, coordinate.Y));
            }

            VectorMarkerSymbolElement symLyrEl = new VectorMarkerSymbolElement(new Polyline(mapPoints), multilayerPolylineSymbol);

            List<VectorMarkerSymbolElement> vectorMarkerSymbolElements = new List<VectorMarkerSymbolElement>();

            //add custom element to vectormarker symbol
            vectorMarkerSymbolElements.Add(symLyrEl);

            SimpleMarkerSymbol pointSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, Color.Transparent, 5)
            {
                Color = Color.Transparent,
                Outline = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.Black, 1)
            };

            pointSymbol.Style = SimpleMarkerSymbolStyle.Circle;
            MultilayerPointSymbol multilayerPointSymbol = pointSymbol.ToMultilayerSymbol();

            VectorMarkerSymbolElement vectorMarkerSymbolElement = new VectorMarkerSymbolElement(new MapPoint(0, 10), multilayerPointSymbol);

            //add circle symbol to vectormarker symbol
            vectorMarkerSymbolElements.Add(vectorMarkerSymbolElement);

            VectorMarkerSymbolLayer symLyr = new VectorMarkerSymbolLayer(vectorMarkerSymbolElements);

            List<VectorMarkerSymbolLayer> vectorMarkerSymbolLayers = new List<VectorMarkerSymbolLayer>();

            vectorMarkerSymbolLayers.Add(symLyr);

            MultilayerPointSymbol sym = new MultilayerPointSymbol(vectorMarkerSymbolLayers)
            {
                AngleAlignment = SymbolAngleAlignment.Map,
            };

When updating to runtime versions above 100.11 the symbols are no longer visualized in the map. Though they are still 'renderable', as I am able to visualize them as a separate picture in a non-map environment using the "GetSymbol" function.

 

Has anybody else run into this problem? Did the SDK change on this subject?

 

Tags (1)
0 Kudos
27 Replies
stuartkerkhof
New Contributor

Hi Preeti,

I've responded to Priyanka with more detailed code. Also I now believe we've found the cause of the problem. But I'm not sure how to solve it. Please see my response to Priyanka.

0 Kudos
PriyankaRupani
Esri Contributor

Closing the issue, as this is working as per design

0 Kudos
stuartkerkhof
New Contributor

please don't close the issue. This is not working by design

0 Kudos
PreetiMaske
Esri Contributor

Hi Stuart,

We have been trying different ways to reproduce the problem but can't get the problem to occur at our end. Thanks for sharing the code but it's hard because we can't use your code as is. I even tried using FeatureCollection to match closely with your code , but still could not reproduce the problem. If you can tweak code attached in this post to reproduce the problem, we will be more than happy to look into it further. I would also suggest considering to contact esri Technical support to get help in troubleshooting the issue at your app level.

 private async void addGraphics_Click(object sender, RoutedEventArgs e)
        {
            
            SolidStrokeSymbolLayer lineSymbol = new SolidStrokeSymbolLayer(1, Color.Black);
            List<SymbolLayer> symbolLayers = new List<SymbolLayer>
                {
                    lineSymbol
                };
            MultilayerPolylineSymbol multilayerPolylineSymbol = new MultilayerPolylineSymbol(symbolLayers);
            List<MapPoint> mapPoints = new List<MapPoint>();
            MapPoint[] coordinatesArray = new MapPoint[] { new MapPoint(0, 0), new MapPoint(5, 0), new MapPoint(5, 2), new MapPoint(5, -2) };
            foreach (MapPoint coordinate in coordinatesArray)
            {
                mapPoints.Add(coordinate);
            }
            VectorMarkerSymbolElement symLyrEl = new VectorMarkerSymbolElement(new Polyline(mapPoints), multilayerPolylineSymbol);
            List<VectorMarkerSymbolElement> vectorMarkerSymbolElements = new List<VectorMarkerSymbolElement>();
            //add custom element to vectormarker symbol
            vectorMarkerSymbolElements.Add(symLyrEl);
            SimpleMarkerSymbol pointSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, Color.Transparent, 5)
            {
                Color = Color.Transparent,
                Outline = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.Black, 1)
            };
            pointSymbol.Style = SimpleMarkerSymbolStyle.Circle;
            MultilayerPointSymbol multilayerPointSymbol = pointSymbol.ToMultilayerSymbol();
            VectorMarkerSymbolElement vectorMarkerSymbolElement = new VectorMarkerSymbolElement(new MapPoint(0, 10), multilayerPointSymbol);

            //add circle symbol to vectormarker symbol
            vectorMarkerSymbolElements.Add(vectorMarkerSymbolElement);
            VectorMarkerSymbolLayer symLyr = new VectorMarkerSymbolLayer(vectorMarkerSymbolElements);
            List<VectorMarkerSymbolLayer> vectorMarkerSymbolLayers = new List<VectorMarkerSymbolLayer>();
            vectorMarkerSymbolLayers.Add(symLyr);

            MultilayerPointSymbol sym = new MultilayerPointSymbol(vectorMarkerSymbolLayers)
            {
                AngleAlignment = SymbolAngleAlignment.Map,
            };
            var sr = SpatialReference.Create(4839);
            
            var map = new Map(BasemapStyle.ArcGISLightGray);
            map.ReferenceScale = 445;
            mapview.Map = map;

            var UVrenderer = new UniqueValueRenderer()
            {
                RotationExpression = "[RotationField]",
                RotationType = RotationType.Arithmetic,
            };
            UVrenderer.FieldNames.Add("Asset_Type");
            UVrenderer.UniqueValues.Add(new UniqueValue("Asset_Type", "Asset_Type", sym, "whatever"));
            UVrenderer.DefaultSymbol = new SimpleMarkerSymbol(style: SimpleMarkerSymbolStyle.Cross, Color.Red, size: 20);

            Field f1 = new Field(FieldType.Int32, "RotationField", "RotationField", 0, null, true, true);
            Field f2 = new Field(FieldType.Text, "Asset_Type", "Asset_Type", 16, null, true, true);
            var ftable = new FeatureCollectionTable(new Field[] { f1, f2 }, GeometryType.Point,sr );
            FeatureCollection fcoll = new FeatureCollection();
            fcoll.Tables.Add(ftable);
            
           
            FeatureCollectionLayer fcollayer = new FeatureCollectionLayer(fcoll);

            var f = ftable.CreateFeature();
            f.Geometry = new MapPoint(0, 0, ftable.SpatialReference);
            f.Attributes["RotationField"] = 140;
            f.Attributes["Asset_Type"] = "whatever";
            await ftable.AddFeatureAsync(f);

            var f0 = ftable.CreateFeature();
            f0.Geometry = new MapPoint(10, 10, ftable.SpatialReference);
            f0.Attributes["RotationField"] = 240;
            f0.Attributes["Asset_Type"] = "whatever2";
            await ftable.AddFeatureAsync(f0);
            ftable.Renderer = UVrenderer;
            await fcoll.LoadAsync();
                        
            map.OperationalLayers.Add(fcollayer);
}

And here is the output of code : one feature rendering with default symbol and other using the multilayer symbol.

PreetiMaske_0-1665613523118.png

 

0 Kudos
stuartkerkhof
New Contributor

Hi Preeti,

 

thanks for trying. I saw that the order of your code is somewhat different than mine. So I changed my code to make it more similar.

that didn't provide a solution.

however, I did some new debugging, and finally figured out what the problem is. RenderingMode can somehow not be set to "Automatic" or "Dynamic". When I change it to 'static' it works as before. 

I don't know why this is happening, and I don't believe this is by design (right?)

 

anyway, thanks for putting me on the right track 🙂

 

conclusion, for now:

Setting map reference scale only works with renderingmode set to "Static".

 

kind regards,

Stuart

0 Kudos
stuartkerkhof
New Contributor

It is not as responsive as before. and the simplemarker symbols render quite bad:

stuartkerkhof_0-1665737493092.png

 

does this give more information about what's going wrong?

 

0 Kudos
PreetiMaske
Esri Contributor

What is incorrect in image above? are circles missing? Can you please share images of how it use to render before 100.11? Also please elaborate what does "It is not as responsive as before" mean?

As I said earlier, I can't really look into the problem until I have a repro code. May be you can create a simple reproducer if you try moving code around in my last sample to match your workflow?

0 Kudos
stuartkerkhof
New Contributor

Hi Preeti,

 

thanks for staying on this. I've edited your sample and found out it will have similar results:

    private async void addGraphics_Click(object sender, EventArgs e)
        {

            SolidStrokeSymbolLayer lineSymbol = new SolidStrokeSymbolLayer(1, Color.Black);
            List<SymbolLayer> symbolLayers = new List<SymbolLayer>
                {
                    lineSymbol
                };
            MultilayerPolylineSymbol multilayerPolylineSymbol = new MultilayerPolylineSymbol(symbolLayers);
            List<MapPoint> mapPoints = new List<MapPoint>();
            MapPoint[] coordinatesArray = new MapPoint[] { new MapPoint(0, 0), new MapPoint(5, 0), new MapPoint(5, 2), new MapPoint(5, -2) };
            foreach (MapPoint coordinate in coordinatesArray)
            {
                mapPoints.Add(coordinate);
            }
            VectorMarkerSymbolElement symLyrEl = new VectorMarkerSymbolElement(new Polyline(mapPoints), multilayerPolylineSymbol);
            List<VectorMarkerSymbolElement> vectorMarkerSymbolElements = new List<VectorMarkerSymbolElement>();
            //add custom element to vectormarker symbol
            vectorMarkerSymbolElements.Add(symLyrEl);
            SimpleMarkerSymbol pointSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Circle, Color.Transparent, 5)
            {
                Color = Color.Transparent,
                Outline = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.Black, 1)
            };
            pointSymbol.Style = SimpleMarkerSymbolStyle.Circle;
            MultilayerPointSymbol multilayerPointSymbol = pointSymbol.ToMultilayerSymbol();
            VectorMarkerSymbolElement vectorMarkerSymbolElement = new VectorMarkerSymbolElement(new MapPoint(0, 10), multilayerPointSymbol);

            //add circle symbol to vectormarker symbol
            vectorMarkerSymbolElements.Add(vectorMarkerSymbolElement);
            VectorMarkerSymbolLayer symLyr = new VectorMarkerSymbolLayer(vectorMarkerSymbolElements);
            List<VectorMarkerSymbolLayer> vectorMarkerSymbolLayers = new List<VectorMarkerSymbolLayer>();
            vectorMarkerSymbolLayers.Add(symLyr);

            MultilayerPointSymbol sym = new MultilayerPointSymbol(vectorMarkerSymbolLayers)
            {
                AngleAlignment = SymbolAngleAlignment.Map,
            };
            var sr = SpatialReference.Create(4839);

            var map = new Map(sr);
            map.ReferenceScale = 445;

            GeographicMapView.Map = map;

            var UVrenderer = new UniqueValueRenderer()
            {
                RotationExpression = "[RotationField]",
                RotationType = RotationType.Arithmetic,
            };
            GeographicMap = map;
            UVrenderer.FieldNames.Add("Asset_Type");
            UVrenderer.UniqueValues.Add(new UniqueValue("Asset_Type", "Asset_Type", sym, "whatever"));
            UVrenderer.DefaultSymbol = new SimpleMarkerSymbol(style: SimpleMarkerSymbolStyle.Cross, Color.Red, size: 20);

            Field f1 = new Field(FieldType.Int32, "RotationField", "RotationField", 0, null, true, true);
            Field f2 = new Field(FieldType.Text, "Asset_Type", "Asset_Type", 16, null, true, true);
            var ftable = new FeatureCollectionTable(new Field[] { f1, f2 }, GeometryType.Point, sr);
            FeatureCollection fcoll = new FeatureCollection();
            fcoll.Tables.Add(ftable);


            FeatureCollectionLayer fcollayer = new FeatureCollectionLayer(fcoll);

            var f = ftable.CreateFeature();
            f.Geometry = new MapPoint(0, 0, ftable.SpatialReference);
            f.Attributes["RotationField"] = 140;
            f.Attributes["Asset_Type"] = "whatever";
            await ftable.AddFeatureAsync(f);

            var f0 = ftable.CreateFeature();
            f0.Geometry = new MapPoint(10, 10, ftable.SpatialReference);
            f0.Attributes["RotationField"] = 240;
            f0.Attributes["Asset_Type"] = "whatever2";
            await ftable.AddFeatureAsync(f0);
            ftable.Renderer = UVrenderer;
            await fcoll.LoadAsync();
            fcollayer.Layers[0].RenderingMode = FeatureRenderingMode.Dynamic;
            fcollayer.Layers[0].ScaleSymbols = true;

            map.OperationalLayers.Add(fcollayer);
        }

the difference is that you don't set the "Scale Symbols" property of the feature collection layer's layers. That is crucial for keeping the symbol the correct size when zooming in and out. Size relative to the base map that is. 

please review my changes, and try it out, it does not render at my end. Your sample without my changes does render, but the symbol changes size relative to basemap. 

0 Kudos