-2

i am working on google map. in which i want to perform some click operation on button available on info window. but we can't perform click directly on info window. so i got the link in which we can perform the click on info window. but i am not able to understand how things are happening on this example. and i am not able to understand the how

MotionEvent copyEv = MotionEvent.obtain(ev);
            copyEv.offsetLocation(-point.x + (infoWindow.getWidth() / 2),
                    -point.y + infoWindow.getHeight() + offPXL);

is woking. please any one help me. thanks in advance.

Community
  • 1
  • 1
Umesh Saraswat
  • 560
  • 1
  • 8
  • 22
  • Possibly this will help?: http://stackoverflow.com/questions/20283539/button-onclicklistener-on-infowindow-in-google-map – Andrew V Nov 10 '15 at 05:52
  • It's just a simple calculus that will translate the touch event of your app to the width/height of the info window – Andrew V Nov 10 '15 at 05:57
  • I can explain what every element inside that offsetLocation() means if you want... but the rest is pretty safe explanatory – Andrew V Nov 10 '15 at 05:58

1 Answers1

0
//this line obtains a copy of the MotionEvent that is happening on the screen
MotionEvent copyEv = MotionEvent.obtain(ev);
            /*this line transposes the main motionEvent 
            to the infoWindow's dimensions
            It does this by adding an offset to the original motionEvent data 
            but it saves it into the copy of the MotionEvent

            The algorithm is pretty self explanatory but whatever, here we go:
            It subtracts the X coordinate of the point of the MotionEvent 
            from the infoWindow width which is firstly divided by 2, 
            and it does the same for the y coordinate
            */
            copyEv.offsetLocation(-point.x + (infoWindow.getWidth() / 2),
                    -point.y + infoWindow.getHeight() + offPXL);
Andrew V
  • 522
  • 10
  • 24