开发者

how to capture onscroll event of mapview in android?

i wish to make an android applicaiton in which the data to be displayed on the map is dynamically loaded when the user scrolls on the map. For this i need to capture the onscroll event of the mapview. There is no default onscrolllistener for mapview provided in the sdk.

i have found the following solutions:

  1. start a timer task every x seconds to check if the current center of the m开发者_StackOverflowap is the same as its old center. if not load the new markers.

  2. start a ontouchlistener for the map and capture the motion event. The code i am using for this is as following:

        @Override
        public boolean onTouch(View arg0, MotionEvent arg1) {
            if (arg1.getAction() == MotionEvent.ACTION_MOVE) {
                Log.i("rohan", "onmovement captured");
                GeoPoint gp = ((MapView) arg0).getMapCenter();
                int lat = gp.getLatitudeE6();
                int lng = gp.getLongitudeE6();
                view1CustomAddress =(some url)
                new view1GetMapsInformationThread().execute(null);
            }
            return false;
        }
    });
    

but the above is not getting called when i scroll through the map.

3.The last and the most tedious of them all is i extend the mapview and then override the compute scroll method.

i do not wish to resort to sol 3. If anybody could tell me a simpler way to capture when the user has scrolled so that i can dynamically load the overlays(this i know how to do) i would be most obliged.

Also if someone could tell me why my sol 2 is not working, it would also be of help.

Thank you in advance.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜