Restrict Mouse Hover to layer extent

735
4
04-07-2018 07:25 AM
VeenaHosur
New Contributor II

I am using mouse hover event to display information,Below code is working but i want restrict mouse hovering to layer extent.If mouse cursor is out of layer extent also graphics and pop is not clearing.Can any help to restrict this

PollingLayer.on("mouse-over", function (evt) { Assemblymap.infoWindow.hide(); dijitPopup.close(dialog); var t = "${POLIN_STATN_NAME}" var content = esriLang.substitute(evt.graphic.attributes, t); highlightGraphic = new Graphic(evt.graphic.geometry, highlightSymbol); Assemblymap.graphics.add(highlightGraphic); dialog.setContent(content); domStyle.set(dialog.domNode, "opacity", 0.85); dijitPopup.open({ popup: dialog, x: evt.pageX, y: evt.pageY }); }); dojo.connect(Assemblymap.graphics, "onMouseOut", function (evt) { dijitPopup.close(dialog); Assemblymap.graphics.clear(); // Assemblymap.setMapCursor("default"); });

0 Kudos
4 Replies
RobertScheitlin__GISP
MVP Emeritus

Veena,

  You are listening for mouse-over on the PollingLayer and then adding a graphic and setting the onMouseOut event to close the popup when leaving the graphic. So your issue is that as soon as you leave the graphic you are likely over the PollingLayer still and the popup is fired again. Why not use mouse-out event on the PolingLayer to close the popup?

0 Kudos
VeenaHosur
New Contributor II

 PollingLayer.graphics.on("mouse-out", closeDialog); 

I have tried with this but its not firing closedDialog

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Venna,

  Can you provide all of your code.

0 Kudos
VeenaHosur
New Contributor II

PollingLayer.setDefinitionExpression("ASBLY_CSTNY_NUM ='" + assemblycode + "'"); Assemblymap.addLayer(PollingLayer); dialog = new TooltipDialog({ id: "tooltipDialog1", style: "position: absolute; width: 250px; font: normal normal normal 10pt Helvetica;z-index:100" }); dialog.startup(); Assemblymap.on("load", function () { Assemblymap.graphics.enableMouseEvents(); Assemblymap.graphics.on("mouse-out", closeDialog); }); PollingLayer.on("mouse-over", function (evt) { $('#ContentPlaceHolder1_lblmyEPIC').hide(); $('#ContentPlaceHolder1_lblPSName').hide(); Assemblymap.infoWindow.hide(); var pscd = evt.graphic.attributes.PSCode; var assemblycode = evt.graphic.attributes.ASBLY_CSTNY_NUM; var t ="M:" + Male + "  " + "F:" + Female + "
" + "Total:" + Total + "
" var content = esriLang.substitute(evt.graphic.attributes, t); highlightGraphic = new Graphic(evt.graphic.geometry, highlightSymbol); Assemblymap.graphics.add(highlightGraphic); dialog.setContent(content); domStyle.set(dialog.domNode, "opacity", 0.85); dijitPopup.open({ popup: dialog, x: evt.pageX, y: evt.pageY }); }); function closeDialog() { // alert('hi'); Assemblymap.graphics.clear(); Assemblymap.setMapCursor("default"); dijitPopup.close(dialog); }

I am adding Polling layer after setDefinitionExpression  not whole layer

0 Kudos