在Android设备中显示MapView

时间:2013-07-27 08:02:29

标签: android google-maps android-mapview

实际上我在这里使用谷歌播放服务跟踪了android sdk中谷歌地图的教程。但是在我的真实设备中没有得到任何MapView。请帮助解决这个问题。

2 个答案:

答案 0 :(得分:2)

Android的谷歌地图是地图v2。谷歌地图v2不再支持mapview(如果你有一个旧的api键,它将适用于地图v1,但如果你需要一个新的密钥,他们就停止了服务)。所以我建议你继续使用地图v2并使用下面的代码或者使用下面提到的代码

// Getting Google Play availability status
int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getBaseContext());                
if(status!=ConnectionResult.SUCCESS){ // Google Play Services are not available
int requestCode = 10;
Dialog dialog = GooglePlayServicesUtil.getErrorDialog(status, this, requestCode);
dialog.show();
}

else 
{ // Google Play Services are available     

// Getting reference to the SupportMapFragment
SupportMapFragment fragment = ( SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.mapfragment);

// Getting Google Map
mGoogleMap = fragment.getMap();

=============================================

您也可以按照本教程http://www.vogella.com/articles/AndroidGoogleMaps/article.html

进行操作

答案 1 :(得分:2)

您必须检查设备中是否安装了Google Play服务

Google Play服务用于从Google Play更新Google应用和应用。通过此组件,您可以访问Google设置并帮助应用加快离线搜索速度,提供更具沉浸感的地图并提高效果。 如果您卸载Google Play服务,应用可能无法使用。你可能需要这个组件。

获取here