Select to view content in your preferred language

Merge MultilayerPointSymbol's with a yoffset on one of the symbols

382
2
Jump to solution
12-27-2024 11:07 AM
KarenRobine1
Regular Contributor

I've got 2 MultilayerPointSymbols that I extracted from CIM Json.  I want to merge the 2 symbols together so that the actSymbol is on top of the mapMarkerSymbol and the actSymbol has a Y offset so that it's pushed up a bit (that way it'll fit better).. But I don't see anyway to give it a yoffset?

In the picture below, you can see the motorcycle and the EyeDrop symbol. I want to push the motorcyle up a bit.

Code and Image Follows:

string cimJson = "{\"type\":\"CIMPointSymbol\",\"symbolLayers\":[{\"type\":\"CIMVectorMarker\",\"enable\":true,\"anchorPointUnits\":\"Relative\",\"dominantSizeAxis3D\":\"Z\",\"size\":24,\"billboardMode3D\":\"FaceNearPlane\",\"frame\":{\"xmin\":0,\"ymin\":0,\"xmax\":24,\"ymax\":24},\"markerGraphics\":[{\"type\":\"CIMMarkerGraphic\",\"geometry\":{\"rings\":[[[12,2],[14.92,5.69],[17.19,9.3],[17.98,10.91],[18.54,12.41],[18.89,13.77],[19,15],[18.97,15.63],[18.94,15.95],[18.88,16.27],[18.81,16.6],[18.73,16.93],[18.63,17.25],[18.51,17.58],[18.37,17.9],[18.22,18.22],[18.05,18.53],[17.86,18.83],[17.65,19.13],[17.43,19.41],[17.2,19.69],[16.95,19.95],[16.69,20.2],[16.41,20.43],[16.13,20.65],[15.83,20.86],[15.53,21.05],[15.22,21.22],[14.9,21.37],[14.58,21.51],[14.25,21.63],[13.93,21.73],[13.6,21.81],[13.27,21.88],[12.95,21.94],[12.63,21.97],[12.31,21.99],[12,22],[10.78,21.89],[9.61,21.58],[8.5,21.06],[7.5,20.36],[6.64,19.5],[5.94,18.5],[5.42,17.39],[5.11,16.22],[5,15],[5.11,13.77],[5.46,12.41],[6.02,10.91],[6.81,9.3],[9.08,5.69],[12,2]]]},\"symbol\":{\"type\":\"CIMPolygonSymbol\",\"symbolLayers\":[{\"type\":\"CIMSolidFill\",\"enable\":true,\"color\":[0,0,0,255]}],\"angleAlignment\":\"Map\"}}],\"scaleSymbolsProportionally\":true,\"respectFrame\":true,\"clippingPath\":{\"type\":\"CIMClippingPath\",\"clippingType\":\"Intersect\",\"path\":{\"rings\":[[[0,0],[24,0],[24,24],[0,24],[0,0]]]}}}],\"haloSize\":1,\"scaleX\":1,\"angleAlignment\":\"Display\"}";
string actJson = "{\"type\":\"CIMPointSymbol\",\"symbolLayers\":[{\"type\":\"CIMVectorMarker\",\"enable\":true,\"anchorPointUnits\":\"Relative\",\"dominantSizeAxis3D\":\"Z\",\"size\":11,\"billboardMode3D\":\"FaceNearPlane\",\"frame\":{\"xmin\":0.0,\"ymin\":0.0,\"xmax\":24.0,\"ymax\":24.0},\"markerGraphics\":[{\"type\":\"CIMMarkerGraphic\",\"geometry\":{\"rings\":[[[20.0,7.0],[19.24,7.15],[18.59,7.59],[18.15,8.24],[18.0,9.0],[18.15,9.76],[18.59,10.41],[19.24,10.85],[20.0,11.0],[20.76,10.85],[21.41,10.41],[21.85,9.76],[22.0,9.0],[21.85,8.24],[21.41,7.59],[20.76,7.15],[20.0,7.0]],[[4.0,7.0],[3.24,7.15],[2.59,7.59],[2.15,8.24],[2.0,9.0],[2.15,9.76],[2.59,10.41],[3.24,10.85],[4.0,11.0],[4.76,10.85],[5.41,10.41],[5.85,9.76],[6.0,9.0],[5.85,8.24],[5.41,7.59],[4.76,7.15],[4.0,7.0]],[[4.0,5.0],[5.53,5.3],[6.83,6.17],[7.7,7.47],[8.0,9.0],[10.0,7.0],[13.0,7.0],[16.5,13.1],[17.5,12.1],[16.88,11.49],[16.41,10.72],[16.1,9.87],[16.0,9.0],[16.3,7.47],[17.17,6.17],[18.47,5.3],[20.0,5.0],[21.53,5.3],[22.83,6.17],[23.7,7.47],[24.0,9.0],[23.7,10.53],[22.83,11.83],[21.53,12.7],[20.0,13.0],[19.5,12.9],[17.4,15.0],[20.0,15.0],[20.0,18.0],[16.3,16.1],[13.4,19.0],[9.0,19.0],[9.0,17.0],[12.6,17.0],[14.6,15.0],[11.0,15.0],[7.0,13.0],[5.0,15.0],[0.0,15.0],[0.0,13.0],[4.0,13.0],[2.47,12.7],[1.18,11.82],[0.3,10.53],[0.0,9.0],[0.3,7.47],[1.18,6.18],[2.47,5.3],[4.0,5.0]]]},\"symbol\":{\"type\":\"CIMPolygonSymbol\",\"symbolLayers\":[{\"type\":\"CIMSolidFill\",\"enable\":true,\"color\":[0,0,0,255]}],\"angleAlignment\":\"Map\"}}],\"scaleSymbolsProportionally\":true,\"respectFrame\":true,\"clippingPath\":{\"type\":\"CIMClippingPath\",\"clippingType\":\"Intersect\",\"path\":{\"rings\":[[[0.0,0.0],[24.0,0.0],[24.0,24.0],[0.0,24.0],[0.0,0.0]]]}}}],\"haloSize\":1,\"scaleX\":1,\"angleAlignment\":\"Display\"}";
var mapMarkerSymbol = Symbol.FromJson(cimJson) as MultilayerPointSymbol;
var actSymbol = Symbol.FromJson(actJson) as MultilayerPointSymbol;
 
IList<SymbolLayer> newSymbolLayers = new List<SymbolLayer>();
 
foreach (SymbolLayer lyr in mapMarkerSymbol.SymbolLayers)
{
newSymbolLayers.Add(lyr); //VectorMarkerSymbolLayer, 
}
foreach (SymbolLayer lyr in actSym.SymbolLayers)
{
newSymbolLayers.Add(lyr);
}
 
var finalSym = new MultilayerPointSymbol(newSymbolLayers);
 

actSymbol.PNG 

0 Kudos
1 Solution

Accepted Solutions
pnarkhede
Esri Contributor

Hello Karen,

Thank you for your query.

To adjust the vertical position of the motorcycle symbol, you can modify the VectorMarkerSymbolLayer's OffsetY property before adding it to the combined symbol. Here's how to modify your code:

 

IList<SymbolLayer> newSymbolLayers = new List<SymbolLayer>();

foreach (SymbolLayer lyr in mapMarkerSymbol.SymbolLayers)
{
    newSymbolLayers.Add(lyr); //VectorMarkerSymbolLayer, 
}
foreach (SymbolLayer lyr in actSym.SymbolLayers)
{
    if (lyr is VectorMarkerSymbolLayer vectorLayer)
    {
        vectorLayer.OffsetY = 5; // Adjust Y offset to move the motorcycle up
    }
    newSymbolLayers.Add(lyr);
}

var finalSym = new MultilayerPointSymbol(newSymbolLayers);

 

The key change is checking if each layer is a VectorMarkerSymbolLayer and setting its OffsetY property. You can adjust the value of 5 up or down to fine-tune the positioning of the motorcycle symbol. A positive value moves it up, while a negative value would move it down.

Let me know if this clarifies your situation.

View solution in original post

2 Replies
pnarkhede
Esri Contributor

Hello Karen,

Thank you for your query.

To adjust the vertical position of the motorcycle symbol, you can modify the VectorMarkerSymbolLayer's OffsetY property before adding it to the combined symbol. Here's how to modify your code:

 

IList<SymbolLayer> newSymbolLayers = new List<SymbolLayer>();

foreach (SymbolLayer lyr in mapMarkerSymbol.SymbolLayers)
{
    newSymbolLayers.Add(lyr); //VectorMarkerSymbolLayer, 
}
foreach (SymbolLayer lyr in actSym.SymbolLayers)
{
    if (lyr is VectorMarkerSymbolLayer vectorLayer)
    {
        vectorLayer.OffsetY = 5; // Adjust Y offset to move the motorcycle up
    }
    newSymbolLayers.Add(lyr);
}

var finalSym = new MultilayerPointSymbol(newSymbolLayers);

 

The key change is checking if each layer is a VectorMarkerSymbolLayer and setting its OffsetY property. You can adjust the value of 5 up or down to fine-tune the positioning of the motorcycle symbol. A positive value moves it up, while a negative value would move it down.

Let me know if this clarifies your situation.

KarenRobine1
Regular Contributor

That was it. Thank you.

0 Kudos