<?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 Android Studio throws &amp;quot;Val cannot be reassigned.&amp;quot; in Kotlin Maps SDK Questions</title>
    <link>https://community.esri.com/t5/kotlin-maps-sdk-questions/android-studio-throws-quot-val-cannot-be/m-p/1316487#M193</link>
    <description>&lt;P&gt;// create a map with the BasemapStyle topographic&lt;BR /&gt;val map = ArcGISMap(BasemapStyle.ArcGISImagery)&lt;/P&gt;&lt;P&gt;// Create an ArcGIS Map Image Layer for the ESRI map server layer&lt;BR /&gt;val mapServiceUrl = "https://.../MapServer"&lt;BR /&gt;val mapImageLayer = ArcGISMapImageLayer(mapServiceUrl)&lt;/P&gt;&lt;P&gt;// load sublayers of mapServiceUrl&lt;BR /&gt;val hospitalSublayer = ArcGISMapImageSublayer(1).apply {&lt;STRONG&gt;name&lt;/STRONG&gt; = "Hospital"}&lt;/P&gt;&lt;P&gt;.......list of 35 sublayers&lt;/P&gt;&lt;P&gt;// create a group layer from scratch by adding the Sublayers as children&lt;BR /&gt;val mapSublayers = GroupLayer().apply {&lt;BR /&gt;&lt;STRONG&gt;name&lt;/STRONG&gt; ="Group Base Map"&lt;BR /&gt;addAll(arrayListOf(, hospitalSublayer, ...35 sublayers listed out))&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;basemap.operationalLayers.add(mapImageLayer)&lt;BR /&gt;basemap.operationalLayers.add(mapSublayers)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm getting an error at "name ='Group Base Map'" where Android Studio throws "Val cannot be reassigned." Android Studio highlights "name" in the list block of 35 sub-layers where I load sublayers of mapServiceUrl.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 08 Aug 2023 15:55:01 GMT</pubDate>
    <dc:creator>klebercj</dc:creator>
    <dc:date>2023-08-08T15:55:01Z</dc:date>
    <item>
      <title>Android Studio throws "Val cannot be reassigned."</title>
      <link>https://community.esri.com/t5/kotlin-maps-sdk-questions/android-studio-throws-quot-val-cannot-be/m-p/1316487#M193</link>
      <description>&lt;P&gt;// create a map with the BasemapStyle topographic&lt;BR /&gt;val map = ArcGISMap(BasemapStyle.ArcGISImagery)&lt;/P&gt;&lt;P&gt;// Create an ArcGIS Map Image Layer for the ESRI map server layer&lt;BR /&gt;val mapServiceUrl = "https://.../MapServer"&lt;BR /&gt;val mapImageLayer = ArcGISMapImageLayer(mapServiceUrl)&lt;/P&gt;&lt;P&gt;// load sublayers of mapServiceUrl&lt;BR /&gt;val hospitalSublayer = ArcGISMapImageSublayer(1).apply {&lt;STRONG&gt;name&lt;/STRONG&gt; = "Hospital"}&lt;/P&gt;&lt;P&gt;.......list of 35 sublayers&lt;/P&gt;&lt;P&gt;// create a group layer from scratch by adding the Sublayers as children&lt;BR /&gt;val mapSublayers = GroupLayer().apply {&lt;BR /&gt;&lt;STRONG&gt;name&lt;/STRONG&gt; ="Group Base Map"&lt;BR /&gt;addAll(arrayListOf(, hospitalSublayer, ...35 sublayers listed out))&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;basemap.operationalLayers.add(mapImageLayer)&lt;BR /&gt;basemap.operationalLayers.add(mapSublayers)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm getting an error at "name ='Group Base Map'" where Android Studio throws "Val cannot be reassigned." Android Studio highlights "name" in the list block of 35 sub-layers where I load sublayers of mapServiceUrl.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2023 15:55:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/kotlin-maps-sdk-questions/android-studio-throws-quot-val-cannot-be/m-p/1316487#M193</guid>
      <dc:creator>klebercj</dc:creator>
      <dc:date>2023-08-08T15:55:01Z</dc:date>
    </item>
    <item>
      <title>Re: Android Studio throws "Val cannot be reassigned."</title>
      <link>https://community.esri.com/t5/kotlin-maps-sdk-questions/android-studio-throws-quot-val-cannot-be/m-p/1316554#M194</link>
      <description>&lt;P&gt;To try and remove the error I rewrote to the following&lt;/P&gt;&lt;P&gt;// create a map with the BasemapStyle topographic&lt;BR /&gt;val map = ArcGISMap(BasemapStyle.ArcGISImagery)&lt;/P&gt;&lt;P&gt;// Create an ArcGIS Map Image Layer for the ESRI map server layer&lt;BR /&gt;val mapServiceUrl = "https://.../MapServer"&lt;BR /&gt;val mapImageLayer = ArcGISMapImageLayer(mapServiceUrl)&lt;/P&gt;&lt;P&gt;// load sublayers of mapServiceUrl&lt;BR /&gt;val sublayersWithNames = listOf(&lt;BR /&gt;"Hospital" to ArcGISMapImageSublayer(0),&lt;BR /&gt;.... list of 35 sublayers)&lt;/P&gt;&lt;P&gt;// create a group layer from scratch by adding the Sublayers as children&lt;BR /&gt;val mapSublayers = GroupLayer().apply {&lt;BR /&gt;name = "BaseMap Sublayers"&lt;BR /&gt;sublayersWithNames.forEach { (name, sublayer) -&amp;gt;&lt;BR /&gt;add(sublayer)&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;basemap.operationalLayers.add(mapImageLayer)&lt;BR /&gt;basemap.operationalLayers.add(mapSublayers)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now "name" is not called out in any other function except the group layer.&amp;nbsp; But the error is still there&amp;nbsp; and now there is a second regarding add(sublayer)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be appreciated&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2023 18:14:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/kotlin-maps-sdk-questions/android-studio-throws-quot-val-cannot-be/m-p/1316554#M194</guid>
      <dc:creator>klebercj</dc:creator>
      <dc:date>2023-08-08T18:14:28Z</dc:date>
    </item>
    <item>
      <title>Re: Android Studio throws "Val cannot be reassigned."</title>
      <link>https://community.esri.com/t5/kotlin-maps-sdk-questions/android-studio-throws-quot-val-cannot-be/m-p/1317180#M198</link>
      <description>&lt;P&gt;I tired the first code snippet to load the ArcGISMapImageLayer with its subLayers and I see the map being loaded successfully. I'm using the latest 200.2.0 SDK version, which will release in a few days.&lt;BR /&gt;Code I tried is below:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;// create and add a map with a navigation night basemap style&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;val &lt;/SPAN&gt;map = ArcGISMap(BasemapStyle.ArcGISNavigationNight)&lt;BR /&gt;activityMainBinding.&lt;SPAN&gt;mapView&lt;/SPAN&gt;.&lt;SPAN&gt;map &lt;/SPAN&gt;= map&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;// create and add a map image layer to the map&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;val &lt;/SPAN&gt;mapImageLayer = ArcGISMapImageLayer(&lt;SPAN&gt;"URL"&lt;/SPAN&gt;)&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;// load sublayers of mapServiceUrl&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;val &lt;/SPAN&gt;citiesSublayer = ArcGISMapImageSublayer(&lt;SPAN&gt;0&lt;/SPAN&gt;).&lt;SPAN&gt;apply &lt;/SPAN&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;SPAN&gt;name &lt;/SPAN&gt;= &lt;SPAN&gt;"Cities"&lt;/SPAN&gt;&lt;SPAN&gt;}&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;val &lt;/SPAN&gt;highwaysSublayer = ArcGISMapImageSublayer(&lt;SPAN&gt;1&lt;/SPAN&gt;).&lt;SPAN&gt;apply &lt;/SPAN&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;SPAN&gt;name &lt;/SPAN&gt;= &lt;SPAN&gt;"Highways"&lt;/SPAN&gt;&lt;SPAN&gt;}&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;val &lt;/SPAN&gt;statesSublayer = ArcGISMapImageSublayer(&lt;SPAN&gt;2&lt;/SPAN&gt;).&lt;SPAN&gt;apply &lt;/SPAN&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;SPAN&gt;name &lt;/SPAN&gt;= &lt;SPAN&gt;"States"&lt;/SPAN&gt;&lt;SPAN&gt;}&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;val &lt;/SPAN&gt;countiesSublayer = ArcGISMapImageSublayer(&lt;SPAN&gt;3&lt;/SPAN&gt;).&lt;SPAN&gt;apply &lt;/SPAN&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;SPAN&gt;name &lt;/SPAN&gt;= &lt;SPAN&gt;"Counties"&lt;/SPAN&gt;&lt;SPAN&gt;}&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;// create a group layer from scratch by adding the Sublayers as children&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;val &lt;/SPAN&gt;mapSublayers = GroupLayer().&lt;SPAN&gt;apply &lt;/SPAN&gt;&lt;SPAN&gt;{&lt;BR /&gt;&lt;/SPAN&gt;    &lt;SPAN&gt;name &lt;/SPAN&gt;=&lt;SPAN&gt;"Group Base Map"&lt;BR /&gt;&lt;/SPAN&gt;    addAll(&lt;SPAN&gt;arrayListOf&lt;/SPAN&gt;(citiesSublayer,highwaysSublayer, statesSublayer,countiesSublayer ))&lt;BR /&gt;&lt;SPAN&gt;}&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;map.&lt;SPAN&gt;operationalLayers&lt;/SPAN&gt;.add(mapImageLayer)&lt;BR /&gt;map.&lt;SPAN&gt;operationalLayers&lt;/SPAN&gt;.add(mapSublayers)&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;I believe you are using 200.1.0 SDK version?&lt;BR /&gt;&lt;BR /&gt;In 200.1.0 version, I see that "name" is a val. That is updated in 200.2.0 version to be a var. That's why it works in latter case.&lt;BR /&gt;&lt;BR /&gt;To make it work in 200.1.0 version, you can remove the assignment to "name" altogether, and you should see the map layers load.&lt;BR /&gt;Something like this,&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;val &lt;/SPAN&gt;mapSublayers = GroupLayer().&lt;SPAN&gt;apply &lt;/SPAN&gt;&lt;SPAN&gt;{&lt;BR /&gt;&lt;/SPAN&gt;    Collections.addAll(&lt;BR /&gt;        &lt;SPAN&gt;arrayListOf&lt;/SPAN&gt;(&lt;BR /&gt;            citiesSublayer,&lt;BR /&gt;            highwaysSublayer,&lt;BR /&gt;            statesSublayer,&lt;BR /&gt;            countiesSublayer&lt;BR /&gt;        )&lt;BR /&gt;    )&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;Hope this was helpful.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2023 22:06:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/kotlin-maps-sdk-questions/android-studio-throws-quot-val-cannot-be/m-p/1317180#M198</guid>
      <dc:creator>PriyankaRupani</dc:creator>
      <dc:date>2023-08-09T22:06:19Z</dc:date>
    </item>
  </channel>
</rss>

