I noticed that inside the click function of a context menu I don't have access to the map object or call a new function outside the context menu.
Are these limitations for the context menus?
for the script below, I get these errors....
Cannot read property 'addLayer' of undefined
this.myfunction is not a function
---------
ctxMenuForGraphics = new Menu({});
ctxMenuForGraphics.addChild(new MenuItem(
{
label: "something",
onClick: function ()
{
this.map.addLayer(xxx);
this.myfunction();
}
}));
ctxMenuForGraphics.startup();
--------
},
myfunction: function(){
----
},
-----------
Solved! Go to Solution.
Lefteris,
This works fine:
var ctxMenuForGraphics = new Menu({}); ctxMenuForGraphics.addChild(new MenuItem({ label: "info", onClick: lang.hitch(this, function (){ console.info(this.map); }) }));
Lefteris,
This works fine:
var ctxMenuForGraphics = new Menu({}); ctxMenuForGraphics.addChild(new MenuItem({ label: "info", onClick: lang.hitch(this, function (){ console.info(this.map); }) }));
Thank you.
How do I access the labels assigned for the context menu of a graphic?
I tried ctxMenuForGraphics.MenuItem.label[0] but it doesn't work.
I notice that when you assigned a menu to a graphic A and then a bigger graphic B with its own menu covers graphic A, even if you remove the graphic B later, the menu A will be changed to the one that graphic B had. Strange and I am trying to keep the menu for graphics A unchanged.
Lefteris,
For the first part of the question:
ctxMenuForGraphics.addChild(new MenuItem({ label: "info", onClick: lang.hitch(this, function (evt){ console.info(evt.target.innerHTML); }) }));
For the second part, I don't have any experience there.