nikhilk/scriptsharp — Issue #141: BingMaps - Missing EntityCollection events
Author: simardo
Created: 2012-01-16 16:46:10+00:00
State: open

It seems that the MapEntityCollection (Script.Microsoft.BingMaps) event handlers are missing in the Bing Maps API.

The actual workaround is to do some casting that will produce valid javascript:

object entities = myMap.Entities;
MapEvents.AddHandler((MapEntity)entities, "entityadded", myHandler);

Same thing for the event handler where I will cast the MapEventArgs object to a class that will match the event arguments

Script.Alert(((MapEntityCollectionEventArgs)args).Entity.Data.ToString());

public sealed class MapEntityCollectionEventArgs
{
public MapEntityCollection Collection;
public MapEntity Entity;
}