当我调用我在onCameraChange侦听器中创建的方法时,我的Google地图活动正在崩溃。
地图正常工作,直到我实际触摸地图并调用侦听器:
mMap.setOnCameraChangeListener(new GoogleMap.OnCameraChangeListener() {
@Override
public void onCameraChange(CameraPosition position) {
VisibleRegion vr = mMap.getProjection().getVisibleRegion();
double left = vr.latLngBounds.southwest.longitude;
double top = vr.latLngBounds.northeast.latitude;
double right = vr.latLngBounds.northeast.longitude;
double bottom = vr.latLngBounds.southwest.latitude;
zoomFix(position);
checkXYAxis(left, top, right, bottom);
}
});
如果我发表评论方法' checkXYAxis'它工作正常。方法:
public void checkXYAxis(double left, double top, double right, double bottom) {
//X
if (left < -87.896567) {
left = -87.896567;
}
else if (right > -87.874628) {
right = -87.874628;
}
//Y
if (top > 43.178949) {
top = 43.169292;
}
else if (bottom < 43.169292) {
bottom = 43.169292;
}
//update camera position
LatLng southwest = new LatLng(bottom, left);
LatLng northeast = new LatLng(top, right);
LatLngBounds newBounds = new LatLngBounds(southwest, northeast);
CameraUpdate update = CameraUpdateFactory.newLatLngBounds(newBounds, 0);
mMap.moveCamera(update);
}
在该方法的某处,它会导致崩溃。
以下是错误输出:
12-23 23:46:21.903 16841-16841/com.lightningboltstudios.audubontrailmap I/art: Late-enabling -Xcheck:jni
12-23 23:46:21.973 16841-16841/com.lightningboltstudios.audubontrailmap W/ActivityThread: Application com.lightningboltstudios.audubontrailmap can be debugged on port 8100...
12-23 23:46:22.033 16841-16862/com.lightningboltstudios.audubontrailmap I/GMPM: App measurement is starting up
12-23 23:46:22.043 16841-16862/com.lightningboltstudios.audubontrailmap E/GMPM: getGoogleAppId failed with status: 10
12-23 23:46:22.043 16841-16862/com.lightningboltstudios.audubontrailmap E/GMPM: Uploading is not possible. App measurement disabled
12-23 23:46:22.153 16841-16864/com.lightningboltstudios.audubontrailmap D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
12-23 23:46:22.153 16841-16841/com.lightningboltstudios.audubontrailmap D/Atlas: Validating map...
12-23 23:46:22.203 16841-16864/com.lightningboltstudios.audubontrailmap I/Adreno-EGL: <qeglDrvAPI_eglInitialize:379>: EGL 1.4 QUALCOMM build: AU_LINUX_ANDROID_LA.BR.1.1.3_RB1.05.01.00.032.017_msm8916_32_LA.BR.1.1.3_RB1__release_AU ()
OpenGL ES Shader Compiler Version: E031.25.03.04
Build Date: 04/20/15 Mon
Local Branch:
Remote Branch: quic/LA.BR.1.1.3_rb1.11
Local Patches: NONE
Reconstruct Branch: AU_LINUX_ANDROID_LA.BR.1.1.3_RB1.05.01.00.032.017 + 26a3cba + 6f69ea6 + 8bc2bc8 + 649fcde + a52cccf + dbf281f + NOTHING
12-23 23:46:22.203 16841-16864/com.lightningboltstudios.audubontrailmap I/OpenGLRenderer: Initialized EGL, version 1.4
12-23 23:46:22.223 16841-16864/com.lightningboltstudios.audubontrailmap D/OpenGLRenderer: Enabling debug mode 0
12-23 23:46:22.313 16841-16841/com.lightningboltstudios.audubontrailmap I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@24d7d29d time:28513116