<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Retrieve layer simple line symbol color in Qt Maps SDK Questions</title>
    <link>https://community.esri.com/t5/qt-maps-sdk-questions/retrieve-layer-simple-line-symbol-color/m-p/1139210#M4481</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/7317"&gt;@DavidPuckett&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Looks like you're on the right track. Take a look at our QML BuildLegend sample for some guidance.&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Esri/arcgis-runtime-samples-qt/tree/main/ArcGISRuntimeSDKQt_QMLSamples/DisplayInformation/BuildLegend" target="_blank"&gt;https://github.com/Esri/arcgis-runtime-samples-qt/tree/main/ArcGISRuntimeSDKQt_QMLSamples/DisplayInformation/BuildLegend&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A few things you want to check for are to be sure that the autoFetchLegendInfos property on the map is set to true. That will make sure all the legend infos came down automatically without extra work on your part.&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Esri/arcgis-runtime-samples-qt/blob/main/ArcGISRuntimeSDKQt_QMLSamples/DisplayInformation/BuildLegend/BuildLegend.qml#L38" target="_blank"&gt;https://github.com/Esri/arcgis-runtime-samples-qt/blob/main/ArcGISRuntimeSDKQt_QMLSamples/DisplayInformation/BuildLegend/BuildLegend.qml#L38&lt;/A&gt;&lt;/P&gt;&lt;P&gt;After that, if your symbol types in the model are SimpleLineSymbol types, you should be able to pull out the color.&lt;/P&gt;&lt;P&gt;Here's a minor tweak I added to the sample I mentioned. It shows the basic idea of accessing each LegendInfo from the model's delegate and printing the color if it's a SimpleLineSymbol.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Create a list view to display the legend
ListView {
    id: legendListView
    anchors.margins: 10
    width: 165
    height: 150
    clip: true
    model: map.legendInfos

    // Create delegate to display the name with an image
    delegate: Item {
        width: parent ? parent.width : 0
        height: 35
        clip: true

        Row {
            Component.onCompleted: {
                if (index !== -1) {
                    let symbol = map.legendInfos.get(index).symbol;
                    if (symbol &amp;amp;&amp;amp; symbol.symbolType === Enums.SymbolTypeSimpleLineSymbol) {
                        // this symbol is a simple line symbol, print the color
                        console.log(symbol.color);
                    }
                }
            }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let us know if this helps.&lt;/P&gt;</description>
    <pubDate>Tue, 01 Feb 2022 00:04:06 GMT</pubDate>
    <dc:creator>JamesBallard1</dc:creator>
    <dc:date>2022-02-01T00:04:06Z</dc:date>
    <item>
      <title>Retrieve layer simple line symbol color</title>
      <link>https://community.esri.com/t5/qt-maps-sdk-questions/retrieve-layer-simple-line-symbol-color/m-p/1138610#M4478</link>
      <description>&lt;P&gt;How do I retrieve the color of a simple line symbol from specific layers in a web map?&lt;/P&gt;&lt;P&gt;I'm using an existing web map and want to create my own symbols for 3 of the layers in the map. I am able to create the full legend via the sample but I'm struggling to simply grab colors. In the image below, the full legend created from the LegendInfoListModel is at the bottom in the tab but I need to color the rectangles at the top according to the legend info (hard coded now). I am a web developer so perhaps am missing a pattern here. Any help?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DavidPuckett_0-1643422460249.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/32650iFEC46AB801A8D98B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="DavidPuckett_0-1643422460249.png" alt="DavidPuckett_0-1643422460249.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 29 Jan 2022 02:19:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/qt-maps-sdk-questions/retrieve-layer-simple-line-symbol-color/m-p/1138610#M4478</guid>
      <dc:creator>DavidPuckett</dc:creator>
      <dc:date>2022-01-29T02:19:05Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve layer simple line symbol color</title>
      <link>https://community.esri.com/t5/qt-maps-sdk-questions/retrieve-layer-simple-line-symbol-color/m-p/1138956#M4479</link>
      <description>&lt;P&gt;Hi David.&lt;/P&gt;&lt;P&gt;If you have the &lt;A href="https://developers.arcgis.com/qt/qml/api-reference/qml-esri-arcgisruntime-legendinfo.html" target="_self"&gt;legend info&lt;/A&gt;, you should have access to the symbol.&lt;/P&gt;&lt;P&gt;How you get the color out of that symbol will depend on the type of symbol and how the web map was authored, but explore the various symbol types (&lt;A href="https://developers.arcgis.com/qt/qml/api-reference/qml-esri-arcgisruntime-simplelinesymbol.html" target="_self"&gt;SimpleLineSymbol&lt;/A&gt;, &lt;A href="https://developers.arcgis.com/qt/qml/api-reference/qml-esri-arcgisruntime-compositesymbol.html" target="_self"&gt;CompositeSymbol&lt;/A&gt;, &lt;A href="https://developers.arcgis.com/qt/qml/api-reference/qml-esri-arcgisruntime-multilayerpolylinesymbol.html" target="_self"&gt;MultilayerPolylineSymbol&lt;/A&gt;) which should eventually lead you to a color.&lt;/P&gt;&lt;P&gt;Hope that helps.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jan 2022 15:54:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/qt-maps-sdk-questions/retrieve-layer-simple-line-symbol-color/m-p/1138956#M4479</guid>
      <dc:creator>Nicholas-Furness</dc:creator>
      <dc:date>2022-01-31T15:54:56Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve layer simple line symbol color</title>
      <link>https://community.esri.com/t5/qt-maps-sdk-questions/retrieve-layer-simple-line-symbol-color/m-p/1139079#M4480</link>
      <description>&lt;P&gt;Thanks for this Nick, I should have provided more detail however. I am having 2 issues that are keeping me from applying colors dynamically:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;The &lt;STRONG&gt;&lt;I&gt;legendInfo.name&lt;/I&gt;&lt;/STRONG&gt; property returns an empty string for every &lt;EM&gt;&lt;STRONG&gt;legendInfo&lt;/STRONG&gt; &lt;/EM&gt;item so I am not able to find specific legend items to grab the color from&lt;/LI&gt;&lt;LI&gt;I cannot capture the &lt;EM&gt;&lt;STRONG&gt;map.legendInfos&lt;/STRONG&gt;&lt;/EM&gt; because the &lt;EM&gt;&lt;STRONG&gt;onFetchLegendInfosStatusChanged&lt;/STRONG&gt;&lt;/EM&gt; signal returns an error (when placed within the Map item).&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;For now I am using the operationalLayers to get the color for specific layers via the renderer like so:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;operationalLayers.forEach(layer =&amp;gt;
    {
        // only way i can see to identify layers is by name, brittle but...
        if(layer.name === "Serviced 3+ Hours Ago") {
          servicedRoute3PlusHoursLayerLegendColor = layer.renderer.symbol.color;
        }
        else if(layer.name === "Serviced 1-3 Hours Ago") {
          servicedRoute1To3HoursLayerLegendColor = layer.renderer.symbol.color;
        }
        else if(layer.name === "Serviced Less Than 1 Hour Ago") {
          servicedRoute1HourLayerLegendColor = layer.renderer.symbol.color;
        }
        else if(layer.name === "Closed Road") {
          closedRoadLayerLegendColor = layer.renderer.symbol.color;
        }
    })&lt;/LI-CODE&gt;&lt;P&gt;I am certainly open to using legendInfos if these issues can be resolved and share with the community here.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jan 2022 19:40:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/qt-maps-sdk-questions/retrieve-layer-simple-line-symbol-color/m-p/1139079#M4480</guid>
      <dc:creator>DavidPuckett</dc:creator>
      <dc:date>2022-01-31T19:40:10Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve layer simple line symbol color</title>
      <link>https://community.esri.com/t5/qt-maps-sdk-questions/retrieve-layer-simple-line-symbol-color/m-p/1139210#M4481</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/7317"&gt;@DavidPuckett&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Looks like you're on the right track. Take a look at our QML BuildLegend sample for some guidance.&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Esri/arcgis-runtime-samples-qt/tree/main/ArcGISRuntimeSDKQt_QMLSamples/DisplayInformation/BuildLegend" target="_blank"&gt;https://github.com/Esri/arcgis-runtime-samples-qt/tree/main/ArcGISRuntimeSDKQt_QMLSamples/DisplayInformation/BuildLegend&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A few things you want to check for are to be sure that the autoFetchLegendInfos property on the map is set to true. That will make sure all the legend infos came down automatically without extra work on your part.&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Esri/arcgis-runtime-samples-qt/blob/main/ArcGISRuntimeSDKQt_QMLSamples/DisplayInformation/BuildLegend/BuildLegend.qml#L38" target="_blank"&gt;https://github.com/Esri/arcgis-runtime-samples-qt/blob/main/ArcGISRuntimeSDKQt_QMLSamples/DisplayInformation/BuildLegend/BuildLegend.qml#L38&lt;/A&gt;&lt;/P&gt;&lt;P&gt;After that, if your symbol types in the model are SimpleLineSymbol types, you should be able to pull out the color.&lt;/P&gt;&lt;P&gt;Here's a minor tweak I added to the sample I mentioned. It shows the basic idea of accessing each LegendInfo from the model's delegate and printing the color if it's a SimpleLineSymbol.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Create a list view to display the legend
ListView {
    id: legendListView
    anchors.margins: 10
    width: 165
    height: 150
    clip: true
    model: map.legendInfos

    // Create delegate to display the name with an image
    delegate: Item {
        width: parent ? parent.width : 0
        height: 35
        clip: true

        Row {
            Component.onCompleted: {
                if (index !== -1) {
                    let symbol = map.legendInfos.get(index).symbol;
                    if (symbol &amp;amp;&amp;amp; symbol.symbolType === Enums.SymbolTypeSimpleLineSymbol) {
                        // this symbol is a simple line symbol, print the color
                        console.log(symbol.color);
                    }
                }
            }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let us know if this helps.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Feb 2022 00:04:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/qt-maps-sdk-questions/retrieve-layer-simple-line-symbol-color/m-p/1139210#M4481</guid>
      <dc:creator>JamesBallard1</dc:creator>
      <dc:date>2022-02-01T00:04:06Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve layer simple line symbol color</title>
      <link>https://community.esri.com/t5/qt-maps-sdk-questions/retrieve-layer-simple-line-symbol-color/m-p/1139528#M4482</link>
      <description>&lt;P&gt;Thank you, yes, this is helpful to get a hook into when I can grab those colors. I didn't know you could add a completed signal to the Row, good to know. I'm still not getting the name property of the legendInfo item back however. It is an empty string which makes me wonder if it has to do with the source web map and\or how it is handled. Any insights there would be much appreciated.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Feb 2022 20:25:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/qt-maps-sdk-questions/retrieve-layer-simple-line-symbol-color/m-p/1139528#M4482</guid>
      <dc:creator>DavidPuckett</dc:creator>
      <dc:date>2022-02-01T20:25:58Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve layer simple line symbol color</title>
      <link>https://community.esri.com/t5/qt-maps-sdk-questions/retrieve-layer-simple-line-symbol-color/m-p/1139562#M4483</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/7317"&gt;@DavidPuckett&lt;/a&gt;&amp;nbsp;interesting, yes could be something with the data. I am getting the name printed out, but it does depend on which legendInfo it is, and it will also depend on the source data online and whether that contains any name info.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Row {
    Component.onCompleted: {
        if (index !== -1) {
            let legendInfo = map.legendInfos.get(index);
            console.log(legendInfo.name);
        }
    }&lt;/LI-CODE&gt;&lt;P&gt;Using that with the sample prints as follows as I scroll through the legend:&lt;/P&gt;&lt;LI-CODE lang="markdown"&gt;qml: 0 - 61
qml: 62 - 264
qml: 265 - 759
qml: 760 - 1900
qml: 1901 - 9409
qml: 
qml: 
qml: 
qml: Camping
qml: Dining
qml: Drinking Water
qml: Medical Facility&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can see that some of the legend entries here don't contain any "label"&lt;/P&gt;&lt;P&gt;&lt;A href="https://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/legend?f=pjson" target="_blank"&gt;https://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/legend?f=pjson&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Feb 2022 20:48:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/qt-maps-sdk-questions/retrieve-layer-simple-line-symbol-color/m-p/1139562#M4483</guid>
      <dc:creator>JamesBallard1</dc:creator>
      <dc:date>2022-02-01T20:48:36Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieve layer simple line symbol color</title>
      <link>https://community.esri.com/t5/qt-maps-sdk-questions/retrieve-layer-simple-line-symbol-color/m-p/1139618#M4484</link>
      <description>&lt;P&gt;Right, this is interesting. First, it appears that the 'name' property in legendInfo is the 'label' in the legend item. And, if there is only a single symbol for the layer, the name is not included in the legendInfo item. This is a good explanation of what's going on albeit a little confusing to navigate. So really what I was after was the layerName and that isn't found within legendInfos. Now if I were using unique symbols for example it would be useful.&lt;/P&gt;&lt;P&gt;So ultimately, for my situation, getting the symbol colors directly from the layer renderers was the solution.&lt;/P&gt;&lt;P&gt;This latest example provided the clarity to get there and hopefully others with issues around legendInfos will find it useful.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Feb 2022 22:44:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/qt-maps-sdk-questions/retrieve-layer-simple-line-symbol-color/m-p/1139618#M4484</guid>
      <dc:creator>DavidPuckett</dc:creator>
      <dc:date>2022-02-01T22:44:30Z</dc:date>
    </item>
  </channel>
</rss>

