onmouseover on esri js api 4

09-14-2016 03:49 PM
New Contributor

How to handle the mouseover on mapview, map any object and use event.x and y to display the map info 

i tried the following 

view.container.onmouseover = function (event) {
var sp = new ScreenPoint();
sp.x = event.x;
sp.y = event.y;
view.hitTest(sp).then(function (response) {
var graphics = response.results;
graphics.forEach(function (graphic) {

but if the map is contained on page.that has header or another html element the event of x ,y is not correct

Tags (1)
0 Kudos
1 Reply
Esri Regular Contributor

This is what I do before calling 'toMap()'...

toMapPoint: function (evt) {
var adjustedX = evt.clientX - this.view.position[0];
var adjustedY = evt.clientY - this.view.position[1];
return this.view.toMap(adjustedX, adjustedY);