ASP.NET Pack Programmer's Guide
IEnumerable.indexOfItem Method
See Also
 





Gets the index of a given object in a collection.

Namespace: MindFusion.Mapping
Package: IEnumerable.js

 Syntax

JavaScript  Copy Code

function indexOfItem (obj, [fromIndex])

 Parameters

obj

Object. The object to look for.

fromIndex
Optional.

Number. The starting index to search from.

 Return Value

Number. The index of the object, or -1 if the object is not present in the collection.

 Example

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
var mark = new m.Marker(new m.LatLong(-22.951916, -43.210487));
mark.imageSrc = "./images/christ_redeemer.png";
mark.text = "Christ the Redeemer";
markers.decorations.add(mark);

mark = new m.Marker();
mark.location = new m.LatLong(41.89021, 12.492231);
mark.imageSrc = "./images/colosseum100.png";
mark.text = "Colloseum";
markers.decorations.add(mark);
...........................

if(markers.indexOf(mark) < 0)
   alert("This place is not found");

 See Also

IEnumerable Members
IEnumerable Class
MindFusion.Mapping Namespace