iosandroiddev / osmdroid

Automatically exported from code.google.com/p/osmdroid
0 stars 0 forks source link

Map "jumps" during scroll and onFling() Event #457

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hello :)

I managed to run osmdroid in offline mode with tiles created with Mobile Atlas 
Creator. My problem now is that the map "jumps" when I try to scroll the map. 
Especially onFling() event seems not to work. In the OSMdroid Demo on playstore 
it seems to work. I tried to override the onFling() method from the Class 
MapViewGestureDetectorListener in MapView in order to turn it off but it's 
private.

I only have this code to run the map in my MainActivity, nothing special:

        @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        MapView mapView = new MapView(this, 256);
        mapView.setTileSource(TileSourceFactory.MAPQUESTOSM);
                mapView.setBuiltInZoomControls(true);
                mapView.getController().setZoom(2);
                mapView.getController().setCenter(new GeoPoint(52.221, 6.893));
                mapView.setUseDataConnection(false);
        setContentView(mapView);
    }

Any Ideas? :/ Thanks for your help!

Best Regards

Artur

Original issue reported on code.google.com by white.wh...@gmail.com on 1 Aug 2013 at 9:55

GoogleCodeExporter commented 8 years ago
What version of osmdroid? What version of Android are you targeting and what 
version are you running on?

Original comment by kurtzm...@gmail.com on 1 Aug 2013 at 1:24

GoogleCodeExporter commented 8 years ago
Hello,

osmdroid version is 3.0.10, target SDK Version is 17, I'm running on SDK 
Version 15.

Currently I'm aiming at disabling the fling-Event because I really don't know 
why it jumps randomly from one corner to another (I limited the scroll area).

What I did for now is I extended the MapView class and implemented the 
GestureDetector.SimpleOnGestureListener on that class in order to catch the 
onFling-Event (it works). Then I call mapView.getScroller().abortAnimation() 
but it seems to be ignored. Intercepting the onDown() gesture and aborting the 
animation seems to work for "small flings"  but when I swipe across the whole 
screen onFling animation starts and again the animation "jumps" randomly.

Another way was to intercept touchevents with the dispatchTouchEvent method 
from a parent framelayout in which the MapView lies. Here I'm catching the 
ACTION_UP event and returning true so that the child MapView doesn't receive 
any Touch event. This works well for disabling the fling, but it also disables 
other gestures and touch events. So it's not an adequate solution.

Overriding the MapViews MapViewGestureDetectorListener Class onFling-Method 
would be really nice. 

Original comment by white.wh...@gmail.com on 1 Aug 2013 at 9:52

GoogleCodeExporter commented 8 years ago
What about if you don't limit the scroll area? Does it still cause problems. 
Please try to isolate what is different in your application and the sample 
application which has a limited scroll area demo that does not exhibit this 
behavior for me.

Original comment by kurtzm...@gmail.com on 1 Aug 2013 at 9:56

GoogleCodeExporter commented 8 years ago
Without limited scroll area it's the same behaviour. Can I somewhere get the 
sourcecode of the sample application? I didn't find it in the repository. 
Beside that I'd like to know how to disable fling. It can't be that 
difficult... But I don't get it.

Original comment by white.wh...@gmail.com on 1 Aug 2013 at 10:13

GoogleCodeExporter commented 8 years ago
The source code is available in the project's SVN repository under 
trunk/OpenStreetMapViewer

Original comment by kurtzm...@gmail.com on 2 Aug 2013 at 2:15

GoogleCodeExporter commented 8 years ago
Also make sure you have hardware acceleration turned off.

Original comment by kurtzm...@gmail.com on 2 Aug 2013 at 2:16

GoogleCodeExporter commented 8 years ago
Hey, I found a solution that works for me. I still don't know why it crashes 
but I disabled the fling successfully. I'm overriding the onTouchEvent from my 
extended MapView class and returning true if onFling Gesture occurs (from my 
SimpleOnGestureListener).

In my extended MapView Class I only do this:

@Override
public boolean onTouchEvent(MotionEvent event) {
    //Call onTouchEvent from the GestureDetector, returns true on fling
    if(gd.onTouchEvent(event))
       return true;

    return super.onTouchEvent(event);
}

Original comment by white.wh...@gmail.com on 2 Aug 2013 at 7:53

GoogleCodeExporter commented 8 years ago
If this fixes your issue then close the ticket, but there is no reason that the 
MapView should be displaying this behavior and you shouldn't have to disable 
flinging. If you find any more information, please post it here.

Original comment by kurtzm...@gmail.com on 2 Aug 2013 at 1:48

GoogleCodeExporter commented 8 years ago
Hey, sorry I have no Idea how to close tickets, it's my first post here..

Original comment by white.wh...@gmail.com on 4 Aug 2013 at 1:35

GoogleCodeExporter commented 8 years ago
I am closing this ticket but if you have any more information then please post 
it here.

Original comment by kurtzm...@gmail.com on 6 Aug 2013 at 3:26