在android设备中显示MapView



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

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

Google Play服务用于更新Google应用程序和来自Google Play的应用程序。该组件允许您访问谷歌设置,并帮助应用程序加快离线搜索速度,提供更具沉浸感的地图,并提高性能。如果卸载Google Play服务,应用程序可能无法工作。您可能需要此组件。

在这里获取

android版谷歌地图是maps 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

最新更新