I have a following problem:
For my bachelor thesis I make a program that intercepts gestures from the touchscreen and zooms in Google Maps. The problem: How can I intercept the gestures was solved in Google Maps Android API v2 - detect touch on map?
Here is the complete code:
http://dimitar.me/how-to-detect-a-user-pantouchdrag-on-android-map-v2/
Because I have to zoom the map, I created an object Google Map in my Activity:
public class Zoom2Activity extends FragmentActivity implements UpdateMapAfterUserInterection
{
private GoogleMap mMap;
float xMid;
float yMid;
float zoom;
double angle;
int zoomCounter;
boolean threadLifeFlag;
PointFloat dSize= new PointFloat();
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_zoom2);
mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.mapFragment)).getMap();
}
// Implement the interface method
//@Override
public void onUpdateMapAfterUserInterection(double angle, int zoomCounter) {
// Here I zoom the map
zoom = (float) (3+((zoomCounter*45+angle)/30));
mMap.animateCamera(CameraUpdateFactory.zoomTo(zoom));
}
}
Now the code is working, but the zoom is to slow during the touchscreen works. Then I take away the finger and the map zooms all the rest. I have no idea how can I make the own thread for the touchscreen or for view with map.
Assuming your onUpdateMapAfterUserInterection
is called on every MotionEvent
I suggest calling moveCamera
instead of animateCamera
. It will zoom instantly to desired zoom level.