Select to view content in your preferred language

Maptip issue (FeatureLayer onMouseOver event)

1085
2
Jump to solution
04-03-2012 10:00 AM
JonathanBurns
New Contributor
Hello,

I have a weird issue with a maptips event handler I've been using. It works fine, but every so often it will create a random maptip, while seemingly not firing an event.
It's hard to explain so I've included some pictures as well as the code;

Basically what happens is this. A point is hovered over, the event fires. Is caught by the dojo.connect which calls a function creating the maptip. This works fine, however, seemingly randomly a maptip will be created when the mouse leaves the map. No event is caught by the dojo.connect, which makes the problem weird.

Here a point has been hovered on, firebug shows the breakpoint being hit inside the dojo.connect.
[ATTACH=CONFIG]13215[/ATTACH]

Here, a random maptip appears. No breakpoint is hit;
[ATTACH=CONFIG]13216[/ATTACH]

My first inclination was that it was just a weird bug that had to deal with leaving the map, so I created a boolean to track whether the mouse was on the map or not. (Hence the IsMapOnMap variable) it's connected to the events for hovering and leaving the map. This didn't change anything, and I've actually never seen the else hit (See code below)

I'd be thankful for any advice

Mouse on map tracking code;

dojo.connect(rampMap.esriMap, 'onMouseOver', function (evt) {         isMouseOnMap = true;         console.log("On");     });     dojo.connect(rampMap.esriMap, 'onMouseOut', function (evt) {         isMouseOnMap = false;         console.log("Off");     });


The actual mouse hover over point event handler;

dojo.connect(featureLayer, "onMouseOver", function (evt) {         if (isMouseOnMap == true) {             clearTimeout(maptipTimer);             maptipTimer = setTimeout(function () {                 mTips.closeDialog();                 mTips.showMapTips(evt)             },             1500             );         }         else {             console.log("MapTips tried to fire off of map");         }     });


Maptip creation code;

mTips.showMapTips = function (evt) {      if (!rampMap.identifyMode) {         console.log("No layer to identify");         return;     }     else {         if (!rampMap.clickMode) {             //When the measure is toggled, disable click events for identify tool             return;         }         else {                       rampMap.esriMap.graphics.clear();                                    mTips.createMapTip(evt);                        rampMap.clickMode = true;         }     } };  /* Create map tips */ mTips.createMapTip = function (evt) {      var viewField;     var maptipContent = '<ul id="hover_Popup_List">';      if (rampMap.lang == "fr") {         viewField = "F1_STATION_NAME";     } else {         viewField = "E1_STATION_NAME";     }      //Code to create the path to the image     var pictureID = evt.graphic.attributes.OBS_NETWORK_1 + evt.graphic.attributes.OBS_NETWORK_2;     pictureID = "<img src = './App_Themes/images/MapIconImages/" + pictureID + ".PNG'/>";      //Setup the content for the maptips popup dialog     maptipContent += "<li>" + pictureID + " " + evt.graphic.attributes[viewField] + "</li>";      maptipContent += "</ul>";     console.log(evt.pageX);     console.log(evt.pageY);     mTips.dialog.setContent(maptipContent);     dijit.popup.open({ popup: mTips.dialog, x: evt.pageX + 10, y: evt.pageY - 38 });   };
0 Kudos
1 Solution

Accepted Solutions
derekswingley1
Deactivated User
map.onMouseOut fires reliably in this simple example (messages logged to your browser's console):  http://jsfiddle.net/23x7t/

Why do you use setTimeout to delay the opening of your maptip?

View solution in original post

0 Kudos
2 Replies
derekswingley1
Deactivated User
map.onMouseOut fires reliably in this simple example (messages logged to your browser's console):  http://jsfiddle.net/23x7t/

Why do you use setTimeout to delay the opening of your maptip?
0 Kudos
by Anonymous User
Not applicable
Original User: JonBurns

The delay was from when we had to use a server to get information about a point being clicked. Removing it seems to fix the issue, oddly enough. Thanks for your help!
0 Kudos