Open hanilozmen opened 7 years ago
You should refactor View into ViewGroup, and the canvas overlay you added need to change to view. For view, you can implement onClick
2017-05-30 15:56 GMT+07:00 hanilozmen notifications@github.com:
First of all, thanks for this implementation. It is working as expected. By the way, getting gps location one time and making processes according to that fixed location provided me a more stable experience.
My question: I want to add onclick listener for each ARPoint so a detail page of that point will be opened. DO you have any suggestion or code snippet for this?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/dat-ng/ar-location-based-android/issues/4, or mute the thread https://github.com/notifications/unsubscribe-auth/ABOmjEI9C45lLO266jJMGdIJY2oGNXo_ks5r-9mmgaJpZM4NqAKv .
how to get the position in canvas ??
I changed it , but the views are gone, can you change it in your library
It is possible to do this by storing the x/y position of the Circle drawn as well as it's radius and using onTouchEvent to capture the touched location.
Note this is NOT the best way to do this @dat-ng method is the correct way to do it
However if you're interested (sorry this is in Kotlin not Java)
override fun onTouchEvent(event: MotionEvent): Boolean {
when (event.action) {
MotionEvent.ACTION_DOWN -> {
val touchX = event.x
val touchY = event.y
// Calculate the distance from the touch point to the circles center
val distance = Math.sqrt(((touchX - circleX).pow(2) + (touchY - circleY).pow(2)).toDouble())
// Check if the touch is inside the circle
if (distance <= circleRadius) {
// Touch is inside the circle
// Do Something Here
}
}
}
return true
}
First of all, thanks for this implementation. It is working as expected. By the way, getting gps location one time and making processes according to that fixed location provided me a more stable experience.
My question: I want to add onclick listener for each ARPoint so a detail page of that point will be opened. Do you have any suggestion or code snippet for this?