---
# System prepended metadata

title: HitTest v4.25 Funbag
tags: [R4MP]

---

###### tags: `R4MP`

# HitTest v4.25 Funbag

## Testing Code

### Config

`simple-feature.js`

```js
{
    id: 'Water',
    layerType: 'esri-feature',
    url: 'https://section917.canadacentral.cloudapp.azure.com/arcgis/rest/services/TestData/EcoAction/MapServer/8',
    drawOrder: [
        {
            field: 'Year_',
            ascending: true
        }
    ]
}
```

### Identify

`ramp-map.ts`

```js
if (hitTest.results.length === 0) return;

console.log('HIT TEST');
console.log(hitTest.results);
console.log(
    hitTest.results
        .map(
            ht =>
                `${ht.layer.id.substring(0, 1)}-${
                    ht.graphic.attributes.OBJECTID
                }`
        )
        .join()
);
```

## Data Stuff

Zoom to Winnipeg.

Three water points

| Pos on Map | OID | Name | Sort Val | Draw Order |
| -------- | -------- | -------- | --- | --- |
| North     | 260     | Lake Peg Shared Solution     | 2011 | Middle |
| Center     | 390     | Protect our Water     | 2012 | Bottom |
| South     | 585     | Rain Soak     | 2014-2015 | Top |


## Retort To ESRI

### Orig post

https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/clarification-on-4-23-hittest-return-value/m-p/1157844

Suggested the result array might be ordered by drawing sequence on the map for 4.24. It is still random in 4.25.

- Is this still something planned? If so is there a timeline?
- Is there an alternate way to derive this information (mainly, the order features are drawn in the map view for a feature layer). Even if it means inspecting some of the more forbidden properties of the API classes?

### Content

This is a follow-up of sorts to this post:

https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/clarification-on-4-23-hittest-return-value/m-p/1157844

It was hinted (not promised) that hitTest results would be sorted by draw order by v4.24. As of v4.25 the result array is still random. I can get around this if all layers have an orderBy applied to a field with unique values, but I don't always have that luxury. Otherwise, as far as I can tell, the ability to get the "top most" hit has been gone since v4.23.

I'm curious if the enhancement to sort the hitTest array is scheduled for a release yet. If it's still marinating in the backlog I feel I'm going to have to start exploring alternative approaches. I'd be all ears if there are ways to derive this by digging into the innards of various API objects; my prodding around hasn't been able to find anything.

Appreciate any responses, good day.



Wanting to know what feature a user can visually see under the mouse seems like a common use-case.