Select to view content in your preferred language

issue with change color on mouse move event

08-03-2023 05:18 PM
New Contributor

I done bellow steps but color doesn't change to the previous after mouse move:

1- created a feature layer with graphic source and set renderer to blue color

2- set green color for specific points on the map after click. I used bellow code for changing to green color: (graphic) {
let stationGraphic = graphic.clone();
stationGraphic.symbol = pointSymbolGreen;

3- set red color on mouse move event as:
if (geometry.type === "point") {

if ( {
for (const mapGraphic of {
if (mapGraphic.geometry.type === "point") {

if (!selectedStaionIds.includes(mapGraphic.attributes.StationID.toString())) { //remove all point colors except green ones;
if (selectedStaionIds.includes(layerAttribute.toString())) { //remove current green color;


graphic.symbol = pointSymbolRed;;

but specific points remain red after mouse move instead of green like bellow. The code works fine for blue points!



0 Kudos
1 Reply
Esri Regular Contributor

Hi there, 

You cannot change a symbol of a feature participating in a FeatureLayer. That needs to happen through layer's renderer. 

If you want to change the color of features that intersect your mouse location you can use the FeatureLayerView.hightlightOptions

This codepen shows how it can be done: