문제

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 regard. 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);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top