AnsweredAssumed Answered

Can context menu and infotemplate coexist for the same location

Question asked by lkoumis on Nov 16, 2015
Latest reply on Nov 18, 2015 by lkoumis

In flex, I was able to create a context menu and a tooltip (infotemplate) for the same point on a gL.  It seems that in JS is either one or the other. If I script out the infotemplate, the context menu appears, otherwise I will see the tooltip only.

 

so can they coexist?

-----------------------------

 

this.createcontextmenu();

this.setinfotemplate();

  on(myGraphicsLayer, 'mouse-over', lang.hitch(this, function (event)

  {

  this.map.graphics.clear;

  var graphic = event.graphic;

 

  if (graphic.attributes.name === "my point")

  {

 

  this.map.infoWindow.setFeatures([graphic]);

  this.map.infoWindow.setContent(myGraphicMarker.getContent());

  this.map.infoWindow.setTitle(myGraphicMarker.getTitle());

  this.map.infoWindow.show(event.screenPoint,

  this.map.getInfoWindowAnchor(event.screenPoint));

  }

 

  this.map.graphics.on("mouse-out", lang.hitch(this, function ()

  {

  this.map.infoWindow.hide();

  }));

  }));

  },

 

  createcontextmenu: function(){

 

  ctxMenuForGraphics = new Menu({}); 

  ctxMenuForGraphics.addChild(new MenuItem({ 

  label: "info", 

  onClick: lang.hitch(this, function (event)

  { 

  if (selectedGraphic != null)

  {

some code

  }

 

  }) 

  })); 

  ctxMenuForGraphics.addChild(new MenuItem(

  { 

  label: "Delete", 

  onClick: function ()

  { 

some code

  } 

  })); 

  ctxMenuForGraphics.startup();

 

  on(myGraphicsLayer, 'mouse-over', lang.hitch(this, function (evt)

  { 

 

  if (evt.graphic.attributes.name === "my point")

  { 

  selectedGraphic = evt.graphic;

  ctxMenuForGraphics.bindDomNode(evt.graphic.getDojoShape().getNode()); 

  }; 

  }));

  on(myGraphicsLayer, 'mouse-out', lang.hitch(this, function (evt)

  { 

  if (evt.graphic.attributes.name === "my point")

  { 

  ctxMenuForGraphics.unBindDomNode(evt.graphic.getDojoShape().getNode()); 

  } 

  })); 

 

setinfotemplate: function()

  {

  var infotip = new InfoTemplate();

 

  tip = "<font color='#FF0000'>some text</b></font>"; 

  infotip.setContent(tip);

  infotip.setTitle("Location Info");

  myGraphicMarker.setInfoTemplate(infotip);

 

  // }

  },

Outcomes