View on GitHub Sample viewer app

Change the appearance of a feature layer with a renderer.

Image of Apply simple renderer to feature layer sample

Use case

A feature layer hosted on ArcGIS Online has a preset renderer and will display in an application with that renderer. However, for example, the color associated with the original renderer may be unsuitable for a company with staff or clients who are color blind, or for presentation with a different set of basemap and operational layers. In these cases, the renderer on the feature layer’s data can be set to a more suitable color.

How to use the sample

Use the button to change the renderer on the feature layer. The original renderer displays orange circles, the diameters of which are proportional to carbon storage of each tree. When the simple renderer is applied, it displays the location of the trees simply as points with random color.

How it works

  1. Create a FeatureLayer from a portal item.
  2. Create a new SimpleRenderer.
  3. Change the feature layer’s renderer.

Relevant API

  • FeatureLayer
  • SimpleRenderer

About the data

This sample displays a Landscape Trees feature layer in Warren Wilson College, North Carolina, showing carbon storage of trees on campus. The size of each circle is proportional to that particular tree’s carbon storage total.

Tags

feature layer, renderer, visualization

Sample Code

MainActivity.kt MainActivity.kt ApplySimpleRendererToFeatureLayerViewModel.kt ApplySimpleRendererToFeatureLayerScreen.kt
/* Copyright 2025 Esri
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.esri.arcgismaps.sample.applysimplerenderertofeaturelayer
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import com.arcgismaps.ApiKey
import com.arcgismaps.ArcGISEnvironment
import com.esri.arcgismaps.sample.sampleslib.theme.SampleAppTheme
import com.esri.arcgismaps.sample.applysimplerenderertofeaturelayer.screens.ApplySimpleRendererToFeatureLayerScreen
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// authentication with an API key or named user is
// required to access basemaps and other location services
ArcGISEnvironment.apiKey = ApiKey.create(BuildConfig.ACCESS_TOKEN)
enableEdgeToEdge()
setContent {
SampleAppTheme {
ApplySimpleRendererToFeatureLayerApp()
}
}
}
@Composable
private fun ApplySimpleRendererToFeatureLayerApp() {
Surface(color = MaterialTheme.colorScheme.background) {
ApplySimpleRendererToFeatureLayerScreen(
sampleName = getString(R.string.apply_simple_renderer_to_feature_layer_app_name)
)
}
}
}