<?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: For-loop range must have an 'iterator()' method when making legend in Kotlin in Kotlin Maps SDK Questions</title>
    <link>https://community.esri.com/t5/kotlin-maps-sdk-questions/for-loop-range-must-have-an-iterator-method-when/m-p/1322133#M215</link>
    <description>&lt;P&gt;This worked thank you&lt;/P&gt;</description>
    <pubDate>Thu, 24 Aug 2023 14:36:39 GMT</pubDate>
    <dc:creator>klebercj</dc:creator>
    <dc:date>2023-08-24T14:36:39Z</dc:date>
    <item>
      <title>For-loop range must have an 'iterator()' method when making legend in Kotlin</title>
      <link>https://community.esri.com/t5/kotlin-maps-sdk-questions/for-loop-range-must-have-an-iterator-method-when/m-p/1321935#M213</link>
      <description>&lt;DIV&gt;&lt;PRE&gt;&lt;SPAN&gt;private fun &lt;/SPAN&gt;&lt;SPAN&gt;showLegendDialog&lt;/SPAN&gt;() {&lt;BR /&gt;    &lt;SPAN&gt;val &lt;/SPAN&gt;dialogView = LayoutInflater.from(&lt;SPAN&gt;this&lt;/SPAN&gt;).inflate(R.layout.&lt;SPAN&gt;legend_dialog&lt;/SPAN&gt;&lt;SPAN&gt;, null&lt;/SPAN&gt;)&lt;BR /&gt;    &lt;SPAN&gt;val &lt;/SPAN&gt;builder = AlertDialog.Builder(&lt;SPAN&gt;this&lt;/SPAN&gt;)&lt;BR /&gt;        .setTitle(&lt;SPAN&gt;"Legend"&lt;/SPAN&gt;)&lt;BR /&gt;        .setView(dialogView)&lt;BR /&gt;        .setPositiveButton(&lt;SPAN&gt;"Close"&lt;/SPAN&gt;) &lt;SPAN&gt;{ &lt;/SPAN&gt;dialog&lt;SPAN&gt;, &lt;/SPAN&gt;_ &lt;SPAN&gt;-&amp;gt; &lt;/SPAN&gt;dialog.dismiss() &lt;SPAN&gt;}&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;    &lt;SPAN&gt;val &lt;/SPAN&gt;dialog = builder.create()&lt;BR /&gt;    dialog.show()&lt;BR /&gt;&lt;BR /&gt;    &lt;SPAN&gt;val &lt;/SPAN&gt;legendLayout: LinearLayout = dialogView.findViewById(R.id.&lt;SPAN&gt;legendLayout&lt;/SPAN&gt;)&lt;BR /&gt;    &lt;SPAN&gt;val &lt;/SPAN&gt;mapImageLayer = &lt;SPAN&gt;mapView&lt;/SPAN&gt;.&lt;SPAN&gt;map&lt;/SPAN&gt;?.&lt;SPAN&gt;operationalLayers&lt;/SPAN&gt;?.get(&lt;SPAN&gt;0&lt;/SPAN&gt;) &lt;SPAN&gt;as? &lt;/SPAN&gt;ArcGISMapImageLayer&lt;BR /&gt;&lt;BR /&gt;    mapImageLayer?.&lt;SPAN&gt;let &lt;/SPAN&gt;&lt;SPAN&gt;{&lt;BR /&gt;&lt;/SPAN&gt;        &lt;SPAN&gt;CoroutineScope&lt;/SPAN&gt;(Dispatchers.&lt;SPAN&gt;Main&lt;/SPAN&gt;).&lt;SPAN&gt;launch &lt;/SPAN&gt;&lt;SPAN&gt;{&lt;BR /&gt;&lt;/SPAN&gt;            &lt;SPAN&gt;for &lt;/SPAN&gt;(sublayer &lt;SPAN&gt;in &lt;/SPAN&gt;&lt;SPAN&gt;it&lt;/SPAN&gt;.&lt;SPAN&gt;mapImageSublayers&lt;/SPAN&gt;) {&lt;BR /&gt;                &lt;SPAN&gt;val &lt;/SPAN&gt;legenddata = sublayer.fetchLegendInfos()&lt;BR /&gt;                &lt;SPAN&gt;for &lt;/SPAN&gt;(legendInfo &lt;SPAN&gt;in &lt;/SPAN&gt;&lt;STRONG&gt;legenddata&lt;/STRONG&gt;) {  // error is here &lt;BR /&gt;                    &lt;SPAN&gt;val &lt;/SPAN&gt;legendImageView = ImageView(&lt;SPAN&gt;this&lt;/SPAN&gt;&lt;SPAN&gt;@MainActivity&lt;/SPAN&gt;)&lt;BR /&gt;&lt;BR /&gt;                    &lt;SPAN&gt;val &lt;/SPAN&gt;symbol = legendInfo.symbol&lt;BR /&gt;                    &lt;SPAN&gt;if &lt;/SPAN&gt;(symbol != &lt;SPAN&gt;null&lt;/SPAN&gt;) {&lt;BR /&gt;                        &lt;SPAN&gt;// Set the symbol directly to the ImageView&lt;BR /&gt;&lt;/SPAN&gt;                        legendImageView.setImageDrawable(symbol.toDrawable(&lt;SPAN&gt;this&lt;/SPAN&gt;&lt;SPAN&gt;@MainActivity&lt;/SPAN&gt;))&lt;BR /&gt;                        legendLayout.addView(legendImageView)&lt;BR /&gt;                    }&lt;BR /&gt;&lt;BR /&gt;                    &lt;SPAN&gt;val &lt;/SPAN&gt;legendName = legendInfo.name&lt;BR /&gt;                    &lt;SPAN&gt;if &lt;/SPAN&gt;(legendName.isNotEmpty()) {&lt;BR /&gt;                        &lt;SPAN&gt;val &lt;/SPAN&gt;legendNameTextView = TextView(&lt;SPAN&gt;this&lt;/SPAN&gt;&lt;SPAN&gt;@MainActivity&lt;/SPAN&gt;)&lt;BR /&gt;                        legendNameTextView.&lt;SPAN&gt;text &lt;/SPAN&gt;= legendName&lt;BR /&gt;                        legendLayout.addView(legendNameTextView)&lt;BR /&gt;                    }&lt;BR /&gt;                }&lt;BR /&gt;            }&lt;BR /&gt;        &lt;SPAN&gt;}&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;    }&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Error is at  for (legendInfo in &lt;STRONG&gt;legenddata&lt;/STRONG&gt;) Android Studio keeps throwing an error stating the "For-loop range must have an 'iterator()' method"&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 23 Aug 2023 21:36:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/kotlin-maps-sdk-questions/for-loop-range-must-have-an-iterator-method-when/m-p/1321935#M213</guid>
      <dc:creator>klebercj</dc:creator>
      <dc:date>2023-08-23T21:36:57Z</dc:date>
    </item>
    <item>
      <title>Re: For-loop range must have an 'iterator()' method when making legend in Kotlin</title>
      <link>https://community.esri.com/t5/kotlin-maps-sdk-questions/for-loop-range-must-have-an-iterator-method-when/m-p/1321957#M214</link>
      <description>&lt;P&gt;&lt;A href="https://developers.arcgis.com/kotlin/api-reference/arcgis-maps-kotlin/com.arcgismaps.mapping.layers/-layer-content/fetch-legend-infos.html?query=abstract%20suspend%20fun%20fetchLegendInfos():%20Result%3CList%3CLegendInfo%3E%3E" target="_self"&gt;fetchLegendInfos()&lt;/A&gt; is a suspending function and all suspending functions in the ArcGIS Maps SDK for Kotlin return a &lt;A href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-result/" target="_self"&gt;Result type&lt;/A&gt;. In this case the result wraps a List&amp;lt;LegendInfo&amp;gt;.&lt;/P&gt;&lt;P&gt;One way to get the list from the result is to write the following&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;val &lt;/SPAN&gt;legenddata = sublayer.fetchLegendInfos().getOrThrow()&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Aug 2023 22:52:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/kotlin-maps-sdk-questions/for-loop-range-must-have-an-iterator-method-when/m-p/1321957#M214</guid>
      <dc:creator>SorenRoth</dc:creator>
      <dc:date>2023-08-23T22:52:32Z</dc:date>
    </item>
    <item>
      <title>Re: For-loop range must have an 'iterator()' method when making legend in Kotlin</title>
      <link>https://community.esri.com/t5/kotlin-maps-sdk-questions/for-loop-range-must-have-an-iterator-method-when/m-p/1322133#M215</link>
      <description>&lt;P&gt;This worked thank you&lt;/P&gt;</description>
      <pubDate>Thu, 24 Aug 2023 14:36:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/kotlin-maps-sdk-questions/for-loop-range-must-have-an-iterator-method-when/m-p/1322133#M215</guid>
      <dc:creator>klebercj</dc:creator>
      <dc:date>2023-08-24T14:36:39Z</dc:date>
    </item>
  </channel>
</rss>

