【发布时间】:2014-04-04 08:44:07
【问题描述】:
在我的应用程序中,我在底部的活动中使用地图视图。但地图无法正确加载。点击地图 2-3 次后,它会显示清晰的地图。& 当相同的地图以全视图加载时,它正在加载清楚地。 解决办法是什么?
屏幕截图是-
<com.google.android.gms.maps.MapView
android:id="@+id/map"
android:layout_width="fill_parent"
android:layout_height="200dp"
android:layout_margin="10dp" />
java代码-
try {
MapsInitializer.initialize(getApplicationContext());
} catch (GooglePlayServicesNotAvailableException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
switch (GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext()) )
{
case ConnectionResult.SUCCESS:
mapView = (MapView)findViewById(R.id.map);
mapView.onCreate(savedInstanceState);
// Gets to GoogleMap from the MapView and does initialization stuff
if(mapView!=null)
{
map = mapView.getMap();
map.getUiSettings().setMyLocationButtonEnabled(false);
map.setMyLocationEnabled(true);
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(locationPosition, 10);
map.animateCamera(cameraUpdate);
map.setMapType(GoogleMap.MAP_TYPE_NORMAL);
}
break;
case ConnectionResult.SERVICE_MISSING:
break;
case ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED:
break;
default: Toast.makeText(getApplicationContext(), GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext()), Toast.LENGTH_SHORT).show();
}
CameraPosition cameraPosition = new CameraPosition.Builder()
.target(locationPosition).zoom(10).bearing(0) // Sets the orientation of the camera to east
.tilt(70) // Sets the tilt of the camera to 30 degrees
.build(); // Creates a CameraPosition from the builder
map.setBuildingsEnabled(true);
map.setMyLocationEnabled(true);
map.setMapType(GoogleMap.MAP_TYPE_NORMAL);
map.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
map.addMarker(new MarkerOptions() .position(locationPosition).icon(BitmapDescriptorFactory.fromResource(R.drawable.icon_marker)));
【问题讨论】:
-
什么意思地图加载不正确?
-
打开活动后,它在mapview上显示方框。它在地图上点击2-3次后加载地图
-
发布你的所有代码 ppplzz
-
或者您可以在
mMapView.onResume();和pausemMapView.onPause();上恢复mapview -
我没有得到你。我在活动中使用这个
标签: android google-maps map android-activity android-mapview