Start a new topic

How to get x,y position of geoObject clicked on screen?

How to get x,y position of geoObject clicked on screen?

Hi

  I am wondering if it's possible to get the x,y position (not lat,lng) of a geoObject on screen when my user clicks the object on phone screen? If possible, how to do that? Thanks in advance.

-Eric
Hi Eric,

getting the projected screen coordinates of an object is currently not possible. Is there anything specific you want to accomplish and what usecase do you have in mind? This would help us in evaluating if we should add such a feature in an upcoming version.

Thanks!
Hi

  I am trying to achieve to react to the click event only when the object is on center of the screen.  It's like giving an illusion of aiming the target (phone is facing the right direction and in proper angle).  This make sure users see what I want them to see on screen (kind of positioning them in right direction). If getting x,y of object not feasible, is it possible for me to know by any kind of tricks/hacks whether it's on center of screen whne click event fire? Thanks for the quick response. -Eric
I might be able to help you out with this. However I need some time to test it and it might break in a future version. Would you be okay with such a "hack"?
Hi Wolfgang

  Yes, I need the hack for me to finish my project. Your kind assisatnce is much appreciated.
  TIA.
-Eric
Hi Wolfgang
  There might be no need to do the hack on sdk. I solve it using jquery to do the trick.
  Steps are below, in case anyone wanted to know.

First,
Second, bind the mouse event to get the X and Y, var mouseX,mouseY;
$(document).bind('mousemove',function(e){
mouseX = e.pageX;
    mouseY = e.pageY;
});
Bingo, I can check the X,Y of click by refering to mouseX and mouseY in the createClickTrigger(id) function call.
-Eric
Login or Signup to post a comment