我开始执行Activity时只看到白屏:
public class MapActivity extends AppCompatActivity implements OnMapReadyCallback {
SupportMapFragment mapFragment;
public static final String DISPLAY_MARKERS_LIMIT = "map_activity_display_markers_limit";
public static final int MARKERS_LIMIT = 1000;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
@Override
public void onMapReady(GoogleMap googleMap) {
googleMap.addMarker(new MarkerOptions()
.position(new LatLng(37.4233438, -122.0728817))
.title("LinkedIn")
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)));
googleMap.addMarker(new MarkerOptions()
.position(new LatLng(37.4629101,-122.2449094))
.title("Facebook")
.snippet("Facebook HQ: Menlo Park"));
googleMap.addMarker(new MarkerOptions()
.position(new LatLng(37.3092293, -122.1136845))
.title("Apple"));
googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(37.4233438, -122.0728817), 10));
}
}
我看到的是logis
10-25 11:01:52.090 13971-13971/pl.. W/DisplayListCanvas: DisplayListCanvas is started on unbinded RenderNode (without mOwningView)
10-25 11:01:53.030 13971-13971/pl.. D/AbsListView: viewType is heaer or footer
10-25 11:01:53.040 13971-13971/pl.. D/AbsListView: viewType is heaer or footer
10-25 11:01:53.100 13971-13971/pl. W/DisplayListCanvas: DisplayListCanvas is started on unbinded RenderNode (without mOwningView)
10-25 11:01:53.580 13971-15476/pl. I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
10-25 11:01:53.580 13971-15476/pl. I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
10-25 11:01:53.610 13971-15476/pl. I/qtaguid: Tagging socket 38 with tag 3000110100000000{805310721,0} uid -1, pid: 13971, getuid(): 10720
10-25 11:01:53.640 13971-15476/pl. I/qtaguid: Untagging socket 38
这是我的布局
<include layout="@layout/content_main" />
这是content_main
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context=".activities.MapActivity"
tools:showIn="@layout/activity_main">
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_gravity="center"
android:layout_height="match_parent"
/>
</RelativeLayout>
activity_main ::
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".activities.MapActivity">
<include layout="@layout/content_main" />
</RelativeLayout>
答案 0 :(得分:0)
我认为这导致海湾地区没有Google地图的api键。 (如果尚未将SHA-1添加到密钥,则将新的SHA-1证书指纹添加到地图)。 您可能会在下面的链接中找到帮助 https://developers.google.com/maps/documentation/android-sdk/signup