0
我正在製作一個使用android studio的預訂應用程序。我已經添加了一個地圖片段,但是我收到了錯誤消息getmap()已被棄用,我想使用getMapAsync()代替。我試了一下,但得到了更多的錯誤。請幫助我。謝謝。getmap()已被棄用並使用getmapAsync?
public class HomeActivity extends Fragment implements View.OnClickListener,GoogleApiClient.ConnectionCallbacks,GoogleApiClient.OnConnectionFailedListener,GoogleMap.OnMapClickListener,GoogleMap.OnMarkerDragListener,{
private GoogleMap map;
private static View v;
private GoogleApiClient mGoogleApiClient;
double latitude,longitude;
boolean centeronCurrent= true, syncWithServer= true, trackDriverBoolean= true, waitForRideToEnd=true;
TextView selectPickup, statusText;
Button requesttaxi;
LatLng currentLocation;
int shortestTime;
int nearbyTaxis,taxicount;
String driverid="", currentRideid="";
ArrayList<Marker> markers= new ArrayList<Marker>();
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
if (v!= null){
ViewGroup parent= (ViewGroup) v.getParent();
if (parent!= null)
parent.removeView(v);
}
try {
v= inflater.inflate(R.layout.home,container,false);
}
catch (InflateException e){
e.printStackTrace();
}
map= ((SupportMapFragment)getChildFragmentManager().findFragmentById(R.id.map)).getMap();
map.setMyLocationEnabled(true);
map.setMapType(GoogleMap.MAP_TYPE_NORMAL);
map.setOnMapClickListener(this);
map.setOnMarkerDragListener(this);
requesttaxi= (Button) v.findViewById(R.id.request_taxi);
requesttaxi.setOnClickListener(this);
statusText=(TextView) v.findViewById(R.id.status_text);
statusText.setVisibility(View.INVISIBLE);
SharedPreferences sp = getActivity().getSharedPreferences("Session", Context.MODE_PRIVATE);
SharedPreferences.Editor editor;
editor=sp.edit();
String location= sp.getString("location","");
mGoogleApiClient = new GoogleApiClient.Builder(getActivity())
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API)
.build();
selectPickup= (TextView) v.findViewById(R.id.select_location);
selectPickup.setOnClickListener(this);
if (location.equals(""))
{
selectPickup.setText("Select Pick up Location");
}
else {
String latstr= sp.getString("locationlat","");
String longstr= sp.getString("locationlong","");
latitude= Double.parseDouble(latstr);
longitude= Double.parseDouble(longstr);
selectPickup.setText(location);
editor.putString("location","");
editor.putString("locationlat","");
editor.putString("locationlong","");
editor.commit();
centeronCurrent=false;
}
mGoogleApiClient.connect();
return v;
}
你是什麼錯誤?張貼您的logcat請! – alway5dotcom