O'Reilly logo

Pro Android 4 by Satya Komatineni, Dave MacLean

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Touches with Maps

Maps can receive touch events as well. You have already seen how touching a map can bring up a zoom control or allow us to pan the map sideways. These are built-in functions of maps. But what if we want to do something different? We’re going to show you how to implement some interesting functionality with maps, including the ability to click a location and get its latitude and longitude. From there, we can do lots of very useful things.

One of the main classes for maps is MapView. This class has an onTouchEvent() method just like the Views we covered earlier and takes a MotionEvent object as its only argument. We can also use the setOnTouchListener() method to set up a callback handler for touch events on a MapView. Other main ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required