2

Please help me with this.

I am creating a right click context menu on a map marker.

See here - http://jsfiddle.net/WEZVX/2/

I need to pass the markers 'id' parameter to the items function.

see lines

// add menu item
menu.add('Request Update', 'update',
function(){
    console.log(id);
    menu.close();
}); 

do i need to wrap this in another function?

Vince Lowe
  • 3,521
  • 7
  • 36
  • 63

1 Answers1

0

Please check this is ok

What i did was wrap it like this

// add menu item
function addmenuitem(id) {
    menu.add('Request Update', 'update',
    function(){
        console.log(id);
        menu.close();
    });
}

this passes the id but keeps adding new items to the list each time the menu is created.

so i added this.items = []; after the overlay is created.

// use menu as overlay
$('#dispatcher').gmap3({
    action:'addOverlay',
    latLng: event.position,
    content: $menu,
    offset: offset
});
// start auto-close
this.initTs(5000);
// clear items after
this.items = [];

seems to be working.

Vince Lowe
  • 3,521
  • 7
  • 36
  • 63