Skip to content

Instantly share code, notes, and snippets.

@mmowbray
Last active September 24, 2016 19:34
Show Gist options
  • Save mmowbray/6ef1d6be2fe1ecfcff66 to your computer and use it in GitHub Desktop.
Save mmowbray/6ef1d6be2fe1ecfcff66 to your computer and use it in GitHub Desktop.
Get image u,v from screen touch
//put this just before the 'break;' of switch 'case MotionEventActions.Down:' in MapView
float u = (_lastTouchX-_translateX)/(_map.CurrentFloor.Image.IntrinsicWidth*_scaleFactor) + 0.50f;
float v = (_lastTouchY-_translateY)/(_map.CurrentFloor.Image.IntrinsicHeight*_scaleFactor) + 0.50f;
Log.Wtf("map_press", String.Format("Map Touched: (u,v):({0},{1}", u, v));
@mmowbray
Copy link
Author

Updated for WebView-style Map View:

float u = (ev.GetX() + ScrollX) / (Scale * _map.CurrentFloor.Width);
float v = (ev.GetY() + ScrollY) / (Scale * _map.CurrentFloor.Height);
Log.Wtf("map_press", String.Format("Map Touched: (u,v):({0},{1}", u, v));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment