Gets the index of a given object in a collection.
Namespace: MindFusion.Mapping
Package: IEnumerable.js
JavaScript Copy Code |
---|
function indexOfItem (obj, [fromIndex]) |
Object. The object to look for.
Number. The starting index to search from.
Number. The index of the object, or -1 if the object is not present in the collection.
The following code creates a DecorationLayer and adds Marker instances to it. Then it gets the index of an item and if it not found issues a warning. The decorations property is of type ObservableCollection, which derives from IEnumerable.
JavaScript Copy Code |
---|
var m = MindFusion.Mapping; var markers = new m.DecorationLayer("Images"); // create some markers with images mark = new m.Marker(); if(markers.indexOf(mark) < 0) |