MultiLayerPointSymbol containing SimpleMarkerSymbol not visualized in Runtime 100.11+ versions

1995
30
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
30 Replies
PreetiMaske
Esri Contributor

It is difficult to suggest anything without looking at how you are creating your multilayer point symbol. A MultilayerPointSymbol can only be created from a collection of  symbollayers. You can not directly add a simple marker symbol to a Multilayer unless you convert that simple marker symbol to a multilayersymbol.

I am happy to help further if you can provide some code you are using to create multilayerpointsymbol and perhaps some screenshots when those symbols are rendered on the map.

--Preeti

0 Kudos
stuartkerkhof
New Contributor

Hi Preeti, 

thanks for responding. I've updated my post so it now includes my use of the multilayerpointsymbol. I know I have to convert the symbol. That is the method I've been using for a while now. But that used to be ArcGIS runtime 100.11 or below. updating to 100.12 or above is not possible. The multilayerpointsymbols that include simplemarker symbols will not be visualized in the map. Not only the circle becomes invisible, but the whole symbol. When commenting the part that adds the circle, the multilayerpointsymbol is visualized, but without the circle (ofcourse). 

That gave me the impression that something with handling simplemarkersymbols within complex symbols was changed in some release.

0 Kudos
PreetiMaske
Esri Contributor

Hi Stuart,

Thanks for providing the code. I will look into this but before I dive in I wanted to check if you have tested in latest version of ArcGIS Runtime SDK For .NET 100.15?

--Preeti

0 Kudos
stuartkerkhof
New Contributor

Hi Preeti,

 

Yes I have. Thanks in advance.

 

kind regards,

 

Stuart

0 Kudos
PriyankaRupani
Esri Contributor

Hi Stuart,

This seems to be working fine with 100.15.0 for ArcGIS Runtime SDK For Android.

I am able to visualize the MultilayerPointSymbol that includes SimpleMarkerSymbol (converted to multilayersymbol first)

I built up on the code you shared above.
Below is the full code sample:

mapView.map = ArcGISMap(Basemap.createTopographic())
mapView.setViewpoint(Viewpoint(Envelope(-171.941313, -169.034086, 190.151917, 422.384855, SpatialReference.create(3857))))

var y = 200.0
var x = -50.0

// create a MultilayerPolylineSymbol
val strokeSymbolLayer = SolidStrokeSymbolLayer(5.0, Color.RED, LinkedList(), StrokeSymbolLayer.LineStyle3D.TUBE)
strokeSymbolLayer.capStyle = StrokeSymbolLayer.CapStyle.ROUND
var symbolLayer = ArrayList<SymbolLayer>()
symbolLayer.add(strokeSymbolLayer)
val polylineSymbol = MultilayerPolylineSymbol(symbolLayer)

var polylineBuilder = PolylineBuilder(mapView.spatialReference)
polylineBuilder.addPoint(Point(x, y, mapView.spatialReference))
polylineBuilder.addPoint(Point(x + 500, y, mapView.spatialReference))

val vmse_polyline = VectorMarkerSymbolElement(polylineBuilder.toGeometry(), polylineSymbol)
var vmselement: MutableList<VectorMarkerSymbolElement> = ArrayList()
vmselement.add(vmse_polyline)



// create SimpleMarkerSymbol, convert to multilayerSymbol
var vec_elem_geom = Geometry.fromJson("{\"curveRings\" : [[[0.0,5.0],[0.0,5.0],{\"c\":[[0.0,5.0],[0.0,-5.0]]}]] }")
val pointSymbol = SimpleMarkerSymbol(SimpleMarkerSymbol.Style.CIRCLE, Color.BLACK, 300.0f)
val multilayerPointSymbol: MultilayerPointSymbol = pointSymbol.toMultilayerSymbol()
// Create a VectorMarkerSymbolElement using geometry and MultiLayerPointSymbol
var vmse_circle = VectorMarkerSymbolElement(vec_elem_geom, multilayerPointSymbol)
vmselement.add(vmse_circle)


// Create a VectorMarkerSymbolLayer with the VectorMarkerSymbolElement
var vectormarkersymbollayer = VectorMarkerSymbolLayer(vmselement)
// Create a MultilayerPointSymbol from VectorMarkerSymbolLayer
var vectormarkersymbollayers: MutableList<VectorMarkerSymbolLayer> = ArrayList()
vectormarkersymbollayers.add(vectormarkersymbollayer)
var markerSymbol = MultilayerPointSymbol(vectormarkersymbollayers)
// Create Graphic using the MultilayerPointSymbol
var graphic = Graphic(Point(-150.0, 200.0, mapView.spatialReference), markerSymbol)
// Add it to GraphicsOverlay
val graphicsOverlay = GraphicsOverlay()
mapView.graphicsOverlays.add(graphicsOverlay)
graphicsOverlay.graphics.add(graphic)S  

 
I see that in your code, the width of the SolidStrokeSymbolLayer is 1 and the size of SimpleMarkerSymbol is 5. I had to increase the width and size respectively, as I couldn't see them initially on my map.

Another issue could be that we need to set the correct viewpoint to view the symbols.

Priyanka_0-1664939360272.png

 

0 Kudos
stuartkerkhof
New Contributor

Hi Pryanka,

 

thanks for responding. The width and size used to work fine in 100.11, so I doubt that would be the issue for me. Also I'm using UniqueValueRenderer to visualize the symbols. The weird thing is that the symbols are visualized in the Legend:

stuartkerkhof_0-1664964316691.png

The problem only occurs when visualizing the symbol in the map.

 

kind regards,

 

Stuart

0 Kudos
PriyankaRupani
Esri Contributor

Update:

I even applied UniqueValueRenderer to the graphicsOverlay renderer and I still am able to visualize the symbols on the map.

Just curious, what rendering mode are you setting?

Tried with STATIC and DYNAMIC rendering mode and both seem to render in my app.

Modified code:

// 8. Add it to GraphicsOverlay
val graphicsOverlay = GraphicsOverlay(GraphicsOverlay.RenderingMode.STATIC)
// Set a UniqueValueRenderer that uses a SimpleMarkerSymbol
graphicsOverlay.renderer = UniqueValueRenderer()
mapView.graphicsOverlays.add(graphicsOverlay)
graphicsOverlay.graphics.add(graphic)

 

0 Kudos
PriyankaRupani
Esri Contributor

Oh! I don't see a mention of using UniqueValueRenderer before, also I dont see it in the code you shared.
Can you share the complete code/steps you are performing? it becomes easier for us to troubleshoot.

0 Kudos
PriyankaRupani
Esri Contributor

Did you try the exact same code snippet you shared above, in Runtime .NET SDK 100.15.0 and are you able to see the symbols in the map?

Asking because you mentioned, "this used to work" in 100.11 and that "you read symbol geometry elements from a JSON file" but gave us a simplified code snippet. Just curious, if the simplified code snippet works for you, in 100.15? and can you share the complete code snippet are you using in your app?

0 Kudos