AnsweredAssumed Answered

display infowindow when mouse hover over a specific point graphic

Question asked by lkoumis on Jul 18, 2015
Latest reply on Jul 18, 2015 by lkoumis

I have several graphics but I want to display an info window only when the mouse hover one specific graphic point.

So, I modified a code from a sample, to initiate the display only if the mouse location is the same as the point location (mypoint.lon,mypoint.lat).

When I use accuracy to 3 decimals for the lat lon, it works but it displays the infowindow when the mouse is nearby the point. If I increase the accuracy to 4 decimals, then the infowindow never displays unless you hit the exact location which is difficult. Suggestions? Do you have another approach to show the info window only for selected graphics?

 

Thank you.

 

var mp = webMercatorUtils.webMercatorToGeographic(event.mapPoint);

  if ((mp.x.toFixed(3) === mypoint.lon.toFixed(3)) && (mp.y.toFixed(3) === mypoint.lat.toFixed(3))){

                map.graphics.clear();  //use the maps graphics layer as the highlight layer

               // var graphic = event.graphic;

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

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

                var highlightGraphic = new Graphic(myGraphicMarker.geometry, pointSymbol);

                map.graphics.add(highlightGraphic);

                map.infoWindow.show(event.screenPoint,

                  map.getInfoWindowAnchor(event.screenPoint));

  }

Outcomes