0
我正在學習谷歌地圖API。當我運行應用程序時,我看到地圖,但沒有看到標記,我等了一小會兒,但沒有發生任何事情。這裏是我的代碼:谷歌地圖標記不顯示在地圖上
MapApp.java
public class MapApp extends SupportMapFragment {
private static LatLng mPosFija;
public MapApp(){
super();
}
public static MapApp newInstance(LatLng posicion){
MapApp frag = new MapApp();
frag.mPosFija = posicion;
return frag;
}
View rootView;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
rootView = inflater.inflate(R.layout.map_app, container, false);
mPosFija = new LatLng(37.4005502611301, -5.98233461380005);
setUpMapIfNeeded();
return rootView;
}
public void setUpMapIfNeeded(){
UiSettings settings = getMap().getUiSettings();
settings.setAllGesturesEnabled(false);
settings.setMyLocationButtonEnabled(false);
getMap().moveCamera(CameraUpdateFactory.newLatLngZoom(mPosFija, 16));
getMap().addMarker(new MarkerOptions().position(mPosFija).icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_launcher)));
}
}
mapp_app.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
檢查:https://developers.google。 com/maps/documentation/android/start –