I have an android app with an activity that swipes (left to right) between 3 views. One of those views displays GoogleMaps. In addition to that I need to have scrolling up and down (not in the map but in the other 2 views) to display all the content. I had some problem to make the app understand the gesture of swiping and not the scrolling when needed but I found a great solution here: http://www.jmstudio.org/archives/391
My problem now is that in my MapView I want to show the position of the user. So I implemented a MapOverlay class like this:
protected class MyLocationOverlay extends com.google.android.maps.Overlay {
@Override
public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when) {
Paint paint = new Paint();
super.draw(canvas, mapView, shadow);
// Converts lat/lng-Point to OUR coordinates on the screen.
Point myScreenCoords = new Point();
mapView.getProjection().toPixels(p, myScreenCoords);
paint.setStrokeWidth(1);
paint.setARGB(255, 255, 255, 255);
paint.setStyle(Paint.Style.STROKE);
Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.positiondot);
canvas.drawBitmap(bmp, myScreenCoords.x, myScreenCoords.y, paint);
return true;
}
}
And then from my activity I call
List<Overlay> mapOverlays;
MyLocationOverlay mapOverlay;
mapOverlays = mapView.getOverlays();
mapOverlay = new MyLocationOverlay();
mapOverlays.add(mapOverlay);
This works, but once the position is shown the swiping is not recognized. And if the user removes the dot (pressing a button mapOverlays.removeAll(mapOverlays); is called) then the swiping works again, but of course the position is not shown anymore. It is like the list disables the swiping for some reason.
So I want to have both the position shown and the swiping working at the same time. My code for the swiping is more or less the one in the link I provided (just implemented my views in the xml). What is wrong and how to fix?
Thank you in advance!