Displaying MapView in an android device [closed]

Deadly 提交于 2019-12-14 03:38:54

问题


Actually here I have followed tutorial for Google maps in android sdk using Google play service. But did not get any MapView in my real device.please help to solve this issue.


回答1:


You must check if Google Play Service is installed in your device

Google Play services is used to update Google apps and apps from Google Play. This component gives you access to Google Settings and helps apps speed up offline searches, provide more immersive maps, and improve performance. Apps may not work if you uninstall Google Play services. You probably need this component.

Get it here




回答2:


Google maps for android is maps v2. Google maps v2 does not suppot mapview anymore(if you have an old api key it will work for maps v1, but if you need a new key they stopped the service). So I suggest you move on to maps v2 and make use of the below code or make use of the tutorial mentioned below the code

// 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();

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

you may also follow this tutorial http://www.vogella.com/articles/AndroidGoogleMaps/article.html



来源:https://stackoverflow.com/questions/17895658/displaying-mapview-in-an-android-device

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!