
我在我的android应用程序中添加了一个mapvIEw.我在清单中使用了正确的设置,现在我遇到了问题.当我去我有地图的地方时,它只显示画布而不显示地图.如果我触摸它只开始加载.即使这样它也没有完全加载.它只加载到一定的水平.如果我继续触摸屏幕,它会不断加载.但即使这样我也无法放大或缩小,甚至无法移动地图.这有解决方案吗?我做错了什么吗?
我的守则
MapVIEw mapVIEw; GoogleMap map; mapVIEw = (MapVIEw)vIEw.findVIEwByID(R.ID.map); Bundle savedInstanceState = null; mapVIEw.onCreate(savedInstanceState); // Gets to GoogleMap from the MapVIEw and does initialization stuff map = mapVIEw.getMap(); map.getUiSettings().setMyLocationbuttonEnabled(false); map.setMyLocationEnabled(true); MapsInitializer.initialize(activity); double lat; double lon; lat = Double.parseDouble(theaterDetail.getLatitude()); lon = Double.parseDouble(theaterDetail.getLongitude()); // Updates the location and zoom of the MapVIEw map.addMarker(new MarkerOptions().position( new LatLng(lat, lon)).Title(theaterDetail.getAddress())); final LatLng THEATER_position = new LatLng(lat, lon); Cameraposition cameraposition = new Cameraposition.Builder() .target(THEATER_position) // Sets the center of the map to // THEATER_position .zoom(10) // Sets the zoom .bearing(360) // Sets the orIEntation of the camera to east .tilt(30) // Sets the tilt of the camera to 30 degrees .build(); // Creates a Cameraposition from the builder map.animateCamera(CameraUpdateFactory .newCameraposition(cameraposition));XML
<com.Google.androID.gms.maps.MapVIEw androID:ID="@+ID/map" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:layout_weight="1"/> 表现
<?xml version="1.0" enCoding="utf-8"?><manifest xmlns:androID="http://schemas.androID.com/apk/res/androID" package="com.***.***" androID:versionCode="1" androID:versionname="1.0" > <uses-sdk androID:minSdkVersion="8" androID:targetSdkVersion="18" /> <uses-permission androID:name="androID.permission.INTERNET"/><uses-permission androID:name="androID.permission.ACCESS_NETWORK_STATE"/><uses-permission androID:name="androID.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission androID:name="com.Google.androID.provIDers.gsf.permission.READ_GSERVICES" /><uses-permission androID:name="androID.permission.ACCESS_COARSE_LOCATION"/><uses-permission androID:name="androID.permission.ACCESS_FINE_LOCATION"/> <uses-feature androID:glEsversion="0x00020000" androID:required="true" /> <permission androID:name="com.***.***.permission.MAPS_RECEIVE" androID:protectionLevel="signature" /> <uses-permission androID:name="com.***.***.permission.MAPS_RECEIVE" /> <application androID:name="com.***.***.service.CommonVariable" androID:allowBackup="true" androID:icon="@drawable/ic_launcher" androID:label="@string/app_name" androID:theme="@style/AppBasetheme" androID:harDWareAccelerated="true" > <Meta-data androID:name="com.Google.androID.gms.version" androID:value="@integer/Google_play_services_version" /> <!-- <uses-library androID:name="com.Google.androID.maps" /> --> <activity androID:name="com.***.***.MainActivity" androID:label="@string/app_name" androID:theme="@style/theme.Sherlock.light.DarkActionbar" androID:windowsoftinputMode="adjustPan" androID:harDWareAccelerated="true"> </activity> <activity androID:name="com.***.***.Map" androID:label="@string/app_name" androID:theme="@style/theme.Sherlock.light.DarkActionbar" ></activity> <activity androID:name="com.***.***.WelcomeActivity" androID:label="@string/app_name" androID:theme="@style/theme.Sherlock.NoActionbar" androID:harDWareAccelerated="true" > <intent-filter> <action androID:name="androID.intent.action.MAIN" /> <category androID:name="androID.intent.category.LAUNCHER" /> </intent-filter> </activity> <Meta-data androID:name="com.Google.androID.maps.v2.API_KEY" androID:value="*********************" /> </application></manifest>解决方法:
虽然这是一个老问题,但我在这里提供了对我有用的东西.此解决方案的工作原理是它覆盖了onResume()处理程序.如果您使用的是mapVIEw,则需要从onResume()处理程序调用mapVIEw.onResume().例:
@OverrIDepublic voID onResume() { mMapVIEw.onResume(); super.onResume();} 总结 以上是内存溢出为你收集整理的除非您触摸mapview,否则不会加载Android MapView全部内容,希望文章能够帮你解决除非您触摸mapview,否则不会加载Android MapView所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)