- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在尝试在我的 Activity 的 oncreateMethod 中放大 Google MapView。每次我尝试通过 mapController 缩放 map 时,我都会收到 IllegalArgumentException:
04-15 10:16:51.012: ERROR/AndroidRuntime(528): java.lang.RuntimeException: Unable to start activity ComponentInfo{android.client/android.client.ui.showstores.StoreMap}: java.lang.IllegalArgumentException: width and height must be > 0
如果我调用 MapController 的 zoomOut 或 zoomIn 函数,则会抛出此异常。 .遗憾的是,我使用的 zoomIn 函数没有任何参数。
我调用缩放函数的 onCreateMethod 如下所示:
mapView = (MapView) findViewById(R.id.map);
mapView.setBuiltInZoomControls(true);
MapController mapController = mapView.getController();
mapController.zoomIn();
我在这里有点不知所措,因为我没有做任何特别的事情。
整个堆栈跟踪是:
04-15 10:16:51.012: ERROR/AndroidRuntime(528): java.lang.RuntimeException: Unable to start activity ComponentInfo{android.client/android.client.ui.showstores.StoreMap}: java.lang.IllegalArgumentException: width and height must be > 0
04-15 10:16:51.012: ERROR/AndroidRuntime(528): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2401)
04-15 10:16:51.012: ERROR/AndroidRuntime(528): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417)
04-15 10:16:51.012: ERROR/AndroidRuntime(528): at android.app.ActivityThread.access$2100(ActivityThread.java:116)
04-15 10:16:51.012: ERROR/AndroidRuntime(528): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
04-15 10:16:51.012: ERROR/AndroidRuntime(528): at android.os.Handler.dispatchMessage(Handler.java:99)
04-15 10:16:51.012: ERROR/AndroidRuntime(528): at android.os.Looper.loop(Looper.java:123)
04-15 10:16:51.012: ERROR/AndroidRuntime(528): at android.app.ActivityThread.main(ActivityThread.java:4203)
04-15 10:16:51.012: ERROR/AndroidRuntime(528): at java.lang.reflect.Method.invokeNative(Native Method)
04-15 10:16:51.012: ERROR/AndroidRuntime(528): at java.lang.reflect.Method.invoke(Method.java:521)
04-15 10:16:51.012: ERROR/AndroidRuntime(528): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
04-15 10:16:51.012: ERROR/AndroidRuntime(528): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
04-15 10:16:51.012: ERROR/AndroidRuntime(528): at dalvik.system.NativeStart.main(Native Method)
04-15 10:16:51.012: ERROR/AndroidRuntime(528): Caused by: java.lang.IllegalArgumentException: width and height must be > 0
04-15 10:16:51.012: ERROR/AndroidRuntime(528): at android.graphics.Bitmap.nativeCreate(Native Method)
04-15 10:16:51.012: ERROR/AndroidRuntime(528): at android.graphics.Bitmap.createBitmap(Bitmap.java:468)
04-15 10:16:51.012: ERROR/AndroidRuntime(528): at com.google.android.maps.ZoomHelper.createSnapshot(ZoomHelper.java:305)
04-15 10:16:51.012: ERROR/AndroidRuntime(528): at com.google.android.maps.ZoomHelper.doZoom(ZoomHelper.java:137)
04-15 10:16:51.012: ERROR/AndroidRuntime(528): at com.google.android.maps.ZoomHelper.doZoom(ZoomHelper.java:126)
04-15 10:16:51.012: ERROR/AndroidRuntime(528): at com.google.android.maps.MapView.doZoom(MapView.java:1459)
04-15 10:16:51.012: ERROR/AndroidRuntime(528): at com.google.android.maps.MapView.doZoom(MapView.java:1468)
04-15 10:16:51.012: ERROR/AndroidRuntime(528): at com.google.android.maps.MapController.zoomIn(MapController.java:427)
04-15 10:16:51.012: ERROR/AndroidRuntime(528): at android.client.ui.showstores.StoreMap.onCreate(StoreMap.java:58)
04-15 10:16:51.012: ERROR/AndroidRuntime(528): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
04-15 10:16:51.012: ERROR/AndroidRuntime(528): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364)
04-15 10:16:51.012: ERROR/AndroidRuntime(528): ... 11 more
最佳答案
我找到了解决这种情况的方法。
int zoomSteps = 2;
int currentLatitudeSpan = mMapView.getLatitudeSpan();
int currentLongitudeSpan = mMapView.getLongitudeSpan();
int zoomedLatitudeSpan = 2 * zoomSteps * currentLatitudeSpan;
int zoomedLongitudeSpan = 2 * zoomSteps * currentLongitudeSpan;
mMapController.zoomToSpan(zoomedLatitudeSpan, zoomedLongitudeSpan);'
这段代码将 map 缩放了两次
关于android - IllegalArgumentException:在 Google MapView 的 zoomOut 期间宽度和高度必须 > 0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2643705/
我正在使用来自 here 的 TouchImageView . 我正在尝试为双击实现 ZoomOut。我已经部分完成了。但是,缩小时我遇到了一些问题。如果我缩放图像并双击,则图像无法正确呈现。 这是我
我想知道如何使用 Google Maps API 平滑地放大动画。 我有两分,一分在中国,一分在法国。当我放大中国时,点击法国按钮。我希望它逐渐平滑缩小,一次缩放一个级别。当它被缩小时,它应该平移到新
我准备一个图片库,我想放大和缩小已经在页面控制和 ScrollView 中的图像。有人可以帮我.. 问候.. 最佳答案 为 ScrollView 设置委托(delegate)。以下代码缩放您的图像。
我已经实现了一个 UIButton 动画,至于现在它会缩放,但我还想在 UIButton 消失时交叉淡入淡出。 这是我的按钮动画示例代码。 (void)centerButtonAnimation{
您能帮我解决 Appium 中 Java for Android 的缩放/捏合工作方法吗? 我已经尝试过使用 MultiTouch 操作 ( How to zoom in a mobile web u
我在我的ImageView中使用了PinchGesture。此代码运行完美,现在我想在某个尺寸处停止ZoomOut,我应该做什么? UIPanGestureRecognizer *panGesture
我创建了一个自定义缩放控件并希望在单击时放大和缩小...我可以访问 Google v3 API 中默认为 zoomIn 和 zoomOut 的方法吗? 最佳答案 不,没有这样的功能。您只需调用 map
我需要将 swipeGesture 添加到我的 UIWebView,但是我需要停止那个 UIWebView 的 ZoomIn 和 ZoomOut /*Swipe is enabled and zoom
我正在尝试在我的 Activity 的 oncreateMethod 中放大 Google MapView。每次我尝试通过 mapController 缩放 map 时,我都会收到 IllegalAr
我正在使用 http://daneden.github.io/animate.css/ 中的 animate.css|并且有 2 个很酷的转换,我想集成或自定义到我的 jquery 移动应用程序,其中
我是一名优秀的程序员,十分优秀!