我有一个带有三个按钮的初始窗口的应用程序。当我点击其中一个时,我会在加载Google Map V2并在其上绘制一些标记时启动进度对话框。
在onMapReady回调中,我关闭了进度对话框:
@Override
public void onMapReady(final GoogleMap map) {
Log.i(MyMoneyBackActivity.TAG, "ShopsMapActivity onMapReady");
GMap = map;
if (needsInit) {
CameraUpdate center=
CameraUpdateFactory.newLatLng(new LatLng(CAMERA_LAT,
CAMERA_LNG));
CameraUpdate zoom=CameraUpdateFactory.zoomTo(12f);
map.moveCamera(center);
map.animateCamera(zoom);
}
// Enabling MyLocation Layer of Google Map
map.setMyLocationEnabled(true);
// Clears all the existing coordinates
map.clear();
// Creating a criteria object to retrieve provider
Criteria criteria = new Criteria();
// Getting the name of the best provider
provider = mLocationManager.getBestProvider(criteria, true);
// Get best last location measurement
mBestReading = bestLastKnownLocation(MIN_LAST_READ_ACCURACY, FIVE_MIN);
mLocationManager.requestLocationUpdates(provider, 20000, 0, this);
Log.i(MyMoneyBackActivity.TAG, "Map");
Geocoder geoCoder = new Geocoder(ShopsMapActivity.this, Locale.getDefault());
if ( geoCoder.isPresent() )
Log.i(MyMoneyBackActivity.TAG, "Geocoder available");
else
Log.i(MyMoneyBackActivity.TAG, "Geocoder NOT available");
// Add a marker for every shop
for (ShopElement rec : MyMoneyBackActivity.shopElementsList) {
//String addressStr = "Aquileia 39,Udine,Italy";
String addressStr = rec.getaddress() + "," + rec.getcity() +",Italy";
Log.i(MyMoneyBackActivity.TAG, "addressStr -" + addressStr + "-");
try {
List<Address> addresses = geoCoder.getFromLocationName(addressStr, 1);
if (addresses.size() > 0) {
latitude = addresses.get(0).getLatitude();
longitude = addresses.get(0).getLongitude();
}
} catch (IOException e) { // TODO Auto-generated catch block
e.printStackTrace();
}
Log.i(MyMoneyBackActivity.TAG, "Position : " + latitude + " " + longitude);
point = new LatLng(latitude, longitude);
// Add a new marker for this shop
drawMarker(map, point, rec, "");
}
map.setInfoWindowAdapter(new PopupAdapter(this,
getLayoutInflater(),
images));
//point = new LatLng(CAMERA_LAT, CAMERA_LNG);
//drawMarker(map, point, null, "Centro");
// Display last reading information
if(mBestReading!=null){
onLocationChanged(mBestReading);
}
if (MyMoneyBackActivity.progressDialog.isShowing()) {
MyMoneyBackActivity.progressDialog.dismiss();
MyMoneyBackActivity.progressDialog = null;
}
}
但是,在实际绘制地图之前,我在几十秒内得到的是一个完全黑屏。
答案 0 :(得分:0)
检查它是否适用于Google Play服务6.7.76 - 请参阅此处https://code.google.com/p/gmaps-api-issues/issues/detail?id=7679。
答案 1 :(得分:0)
硬件加速和大堆是我的问题。我从应用程序级别删除它们并在他们使用的活动中使用它们。
问题发生在Manifest
。
<application
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:hardwareAccelerated="false"
android:largeHeap="true">
从Manifest
移除并在Activity
<activity
android:name="com.mycompayname.activities.SignUpActivity"
android:hardwareAccelerated="false"
android:largeHeap="true"/>