Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Introduce MapboxMap #3485

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

import com.mapbox.mapboxsdk.utils.ApiAccess;
import com.mapbox.mapboxsdk.views.MapView;
import com.mapbox.mapboxsdk.views.MapboxMap;
import com.mapbox.mapboxsdk.views.OnMapReadyCallback;

public class MapFragment extends Fragment {

Expand All @@ -26,6 +28,8 @@ public class MapFragment extends Fragment {
// The map
private MapView mMap;

private OnMapReadyCallback mMapReadyCallback;

//
// Lifecycle events
//
Expand All @@ -45,6 +49,10 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
// Need to pass on any saved state to the map
mMap.onCreate(savedInstanceState);

if(mMapReadyCallback!=null){
mMapReadyCallback.onMapReady(new MapboxMap(mMap));
}

// Return the map as the root view
return mMap;
}
Expand Down Expand Up @@ -122,8 +130,20 @@ public void onLowMemory() {
//
// Property methods
//

/**
* @deprecated in favor of
*/
@Deprecated
public MapView getMap() {
return mMap;
}

public void getMapAsync(OnMapReadyCallback callback){
if(mMap!=null){
callback.onMapReady(new MapboxMap(mMap));
}else {
mMapReadyCallback = callback;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ public void setMapView(MapView mapView) {
}

protected MapView getMapView() {
if (mapView == null) {
return null;
}
return mapView;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.mapbox.mapboxsdk.R;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.views.MapView;
import com.mapbox.mapboxsdk.views.MapboxMap;

import java.lang.ref.WeakReference;

Expand Down Expand Up @@ -61,7 +62,7 @@ private void initialize(View view, MapView mapView) {
public boolean onTouch(View v, MotionEvent e) {
if (e.getAction() == MotionEvent.ACTION_UP) {
boolean handledDefaultClick = false;
MapView.OnInfoWindowClickListener onInfoWindowClickListener =
MapboxMap.OnInfoWindowClickListener onInfoWindowClickListener =
mMapView.get().getOnInfoWindowClickListener();
if (onInfoWindowClickListener != null) {
handledDefaultClick = onInfoWindowClickListener.onMarkerClick(getBoundMarker());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.mapbox.mapboxsdk.R;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.views.MapView;
import com.mapbox.mapboxsdk.views.MapboxMap;

/**
* A marker is a map overlay that shows an icon image at a specific
Expand Down Expand Up @@ -89,7 +90,7 @@ public InfoWindow showInfoWindow() {
return null;
}

MapView.InfoWindowAdapter infoWindowAdapter = getMapView().getInfoWindowAdapter();
MapboxMap.InfoWindowAdapter infoWindowAdapter = getMapView().getInfoWindowAdapter();
if (infoWindowAdapter != null) {
// end developer is using a custom InfoWindowAdapter
View content = infoWindowAdapter.getInfoWindow(this);
Expand Down
Loading