2 回答
TA貢獻(xiàn)1830條經(jīng)驗(yàn) 獲得超3個(gè)贊
根據(jù)您的代碼,我沒有發(fā)現(xiàn)任何錯(cuò)誤,但根據(jù)您的屏幕截圖,您的互聯(lián)網(wǎng)連接似乎丟失了,所以您能否先提供正確的互聯(lián)網(wǎng)連接并檢查一下。
TA貢獻(xiàn)1777條經(jīng)驗(yàn) 獲得超10個(gè)贊
在您的片段中使用 MapView:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".HomeFragment">
<com.google.android.gms.maps.MapView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/llSelectDetails" />
</RelativeLayout>
在您的片段中使用:
public class HomeFragment extends Fragment implements OnMapReadyCallback {
private GoogleMap mMap;
private MapView mMapView;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View rootView = inflater.inflate(R.layout.fragment_home, container, false)
/*
* Configure Mapview and sync to google map.
*/
mMapView = rootView.findViewById(R.id.mapView);
mMapView.onCreate(savedInstanceState);
mMapView.getMapAsync(this);
mMapView.onResume(); // needed to get the map to display immediately
//your code
return rootView;
}
@Override
public void onMapReady(GoogleMap googleMap) {
this.mMap = googleMap;
}
}
它會(huì)工作得很好。另外,請檢查您的地圖密鑰和互聯(lián)網(wǎng)連接。
添加回答
舉報(bào)
