ThinkGeo.com    |     Documentation    |     Premium Support

Null-Ref Exception when adding ContextMenu in SimpleMarkerOverlay

Hello!



I try to use the SimpleMarkerOverlay and I can add markers and I can add individual popups to the markers. But when I try to add an individual context menu to a marker, I get a null reference exception on loading the view. 


overlays.SimpleMarkerOverlay(“SMO”)
.Markers(markers =>
{
markers.Marker(10.88555, 48.36666, new ThinkGeo.MapSuite.MvcEdition.WebImage(Url.Content("~/Content/images/MyIcon.png")))
  .Popup(p =>
  {
    p.Height(200);
    p.ContentHtml(“This is a popup box”);
  });
  .ContextMenu(m =>
  {
    m.Width(150);
    m.MenuItems(mi => mi.ContextMenuItem(“Context Menu Item!”));
  });
});

When I comment the .ContextMenu lines out, then the view loads with no errors.



Any idea?



Thanks

Karsten



PS: Can someone please explain what’s the generally difference between a SimpleMarkerOverlay and and InMemoryMarkerOverlay?

Hi Karsten, 
  
 I think you should want to initialize the ContextMenu before use it. 
  
 About SimpleMarkerOverlay and InMemoryMarkerOverlay, for simply, the SimpleMarkerOverlay render all marker on client side but InMemoryMarkerOverlay render them server side and it will be drawn on tile image. If your marker number is big, InMemoryMarkerOverlay have better performance. 
  
 Wish that’s helpful. 
  
 Regards, 
  
 Don