0

I'm having difficulty finding the index of this particular OpenLayers array. The array looks like this.

Array(7)
0: PinchRotate {disposed_: false, pendingRemovals_: {…}, dispatching_: {…}, listeners_: {…}, 
revision_: 0, …}
1: PinchZoom {disposed_: false, pendingRemovals_: {…}, dispatching_: {…}, listeners_: {…}, revision_: 
0, …}
2: KeyboardPan {disposed_: false, pendingRemovals_: {…}, dispatching_: {…}, listeners_: {…}, 
revision_: 0, …}
3: KeyboardZoom {disposed_: false, pendingRemovals_: {…}, dispatching_: {…}, listeners_: {…}, 
revision_: 0, …}
4: MouseWheelZoom {disposed_: false, pendingRemovals_: {…}, dispatching_: {…}, listeners_: {…}, 
revision_: 0, …}
5: DragBox {disposed_: false, pendingRemovals_: {…}, dispatching_: {…}, listeners_: {…}, revision_: 
0, …}
6: PointerInteraction {disposed_: false, pendingRemovals_: {…}, dispatching_: {…}, listeners_: {…}, 
revision_: 0, …}

I'm trying to find the index where the index item = "DragBox"

I've tried both a string and an object i.e.

let index =  MapValues.map.interactions.array_.indexOf("DragBox");

let obj = DragBox
let index =  MapValues.map.interactions.array_.indexOf(obj);

Both have returned -1...i'm really confused as to how to do this with this particular array in typescript.

Any help is greatly appreciated

1 Answer 1

0

To search for an object of a particular type in an array use can use

.findIndex(obj => obj instanceof DragBox)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.