mapbox-gl-native icon indicating copy to clipboard operation
mapbox-gl-native copied to clipboard

addOnMapChangedListener() with SupportMapFragment

Open vfaSonnt opened this issue 10 years ago • 1 comments

Method addOnMapChangedListener() is only exist on MapView. How can I use this with MapFragment? Or how can I get the MapView in MapFragment?

vfaSonnt avatar Mar 24 '16 03:03 vfaSonnt

@vfaSonnt Thank you for reaching out. There is a method called:

    /**
     * Sets a callback object which will be triggered when the MapboxMap instance is ready to be used.
     *
     * @param onMapReadyCallback The callback to be invoked.
     */
    public void getMapAsync(@NonNull final OnMapReadyCallback onMapReadyCallback) {
        mOnMapReadyCallback = onMapReadyCallback;
    }

You can use this to get a reference to MapboxMap. From the 4.0.0 release user will no longer interact with the MapView directly, but with the MapboxMap. Look at this as a separation of concerns, MapboxMap is the controller, MapView is the view.

All our activities in our TestApp are updated to reflect these changes:

tobrun avatar Mar 24 '16 07:03 tobrun