AnsweredAssumed Answered

MapView toScreen returns wrong screenpoint

Question asked by eemeli.pyottio on Sep 11, 2019
Latest reply on Sep 11, 2019 by eemeli.pyottio

Hi,

 

I have an application that loads a Webmap from portal using ArcGIS JS version 4.12. Then I navigate to certain point with MapView goTo function. That works fine. Then I need to convert the Point into ScreenPoint in order to do a hittest. When I do the "toScreen" conversion it returns a point on screen that is not on the right place.

 

Am I missing something here, or should somehow take the spatial reference of the map into account. The Point I create from x and y coordinates points into the right place. Why does the "toScreen" point into a wrong place even though the goto leads into right place? I have tried to change or set different spatial references for the point before "toScreen" but it does not seem to help.

 

Example:

var point = new Point();
point.longitude = "-2.12953405978807";
point.latitude = "50.6877745154717";

// screenPt is x: 1210, y: 416 although it should be something like x: 959  & y: 528.
var screenPt = _view.basemapView.view.toScreen( point );

Outcomes