Maptip onhover and onclick to edit

629
1
05-12-2011 07:49 AM
WarrenMedernach
Occasional Contributor III
Hello,

I would like to enable a tooltip/maptip when a user hovers over a feature, but then I would like to enable an edit function when the user selects the feature.

All of the samples seem to show one or the other method, so I'm wondering if this is possible, and/or, if there are better design options for something like this?

Thanks so much,

Warren M
0 Kudos
1 Reply
KirillLykov
New Contributor
Yes, It is possible. I did it the following way:
In the constructor or init function you may write
 
                var thisObject = this;
  dojo.connect(operationalFLayer, "onMouseOver", function(evt) {
   thisObject.closeDialog();
   thisObject.showTooltip(evt);
  });
  dojo.connect(this._operationalFLayer, "onMouseOut", this.closeDialog);

And define required methods:
 showTooltip(evt) {
  var dialog = new dijit.TooltipDialog({
     id: "tooltipDialog",
     content: evt.graphic.attributes.Text, //+ "<br />" + addr,
     style: "position: absolute; width: 200px; font: normal normal bold 6pt Tahoma;z-index:100"
  });
  dialog.startup();

  dojo.style(dialog.domNode, "opacity", 0.85);
  dijit.placeOnScreen(dialog.domNode, {x: evt.pageX, y: evt.pageY}, ["TL", "BL"], {x: 10, y: 10});
 }
 
 closeDialog() {
  var widget = dijit.byId("tooltipDialog");
  if (widget) {
     widget.destroy();
  }
 }


For editing you shall use esri.dijit.editing.Editor. You might find the sample code for editor in the esri documentation. It is too cumbersome to write it there.
0 Kudos