开发者

TrackballGestureDetector instantiation

I am developing a few location-based apps on android using google maps.

I am currently struggling for, how can I obtain an object instance for the TrackballGestureDetector class which is part of the google maps API?

Appreciating any help in that reg开发者_JAVA技巧ard. Hass.


TrackballGestureDetector can't be instantiated directly. But if you're trying to find out when the map is updated (panned or zoomed in/out), then you need to extend the MapView class and add your own change event handler. A great example that worked for me is here: http://bricolsoftconsulting.com/extending-mapview-to-add-a-change-event/

Note that I got a ClassCastException when I followed the instructions, so I created a MyMapView object instead of a MapView object and programmatically added it to the layout, and that worked great.

    MyMapView mapView = new MyMapView(this, this.getString(R.string.APIMapKey));
    mapView.displayZoomControls(false);
    mapView.setClickable(true);
    FrameLayout item = (FrameLayout) findViewById(R.id.getlocationmap);
    item.addView((MapView)mapView);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜