Maps API会在animateTo()方法上抛出NullPointerException(Maps API throws NullPointerException on animateTo() m

编程入门 行业动态 更新时间:2024-10-28 20:18:46
Maps API会在animateTo()方法上抛出NullPointerException(Maps API throws NullPointerException on animateTo() method)

在尝试将地图设置为某个GeoPoint动画时,我遇到致命异常 - 这是例外:

12-20 17:53:20.400: E/Crittercism(3523): java.lang.NullPointerException 12-20 17:53:20.400: E/Crittercism(3523): at com.amazon.geo.maps.MercatorProjection.latLongToWorldPixels(MercatorProjection.java:397) 12-20 17:53:20.400: E/Crittercism(3523): at com.amazon.geo.maps.MercatorProjection.toPixels(MercatorProjection.java:69) 12-20 17:53:20.400: E/Crittercism(3523): at com.amazon.geo.maps.MapView.animateTo_AmazonInternal(MapView.java:1801) 12-20 17:53:20.400: E/Crittercism(3523): at com.amazon.geo.maps.MapController.animateTo(MapController.java:46) 12-20 17:53:20.400: E/Crittercism(3523): at com.fatattitude.myapplication.MyMapActivity.moveMapToPoint(BusMapActivity.java:1564)

这是我的代码。 我的日志输出还显示GeoPoint的值为LatitudeE6 = 51537141LongitudeE6 = -246271

private void moveMapToPoint(GeoPoint gp, int zoomLevel) { MapController mc = mapView.getController(); if (zoomLevel < 0) zoomLevel = mapView.getZoomLevel(); mc.stopAnimation(true); mc.setZoom(zoomLevel); String strGeoPointInfo = String.format("Lat:%d, Lng:%d", gp.getLatitudeE6(), gp.getLongitudeE6() ); Log.i("GeoPoint-Info", "**moveMapToPoint: " + strTestOutput); mc.animateTo(gp); }

如果我评论该行

//mc.stopAnimation(true);

我不再得到例外。

谁能帮助我理解为什么会发生这种异常?

请帮帮我。

I'm getting a fatal exception when trying to animate the map to a certain GeoPoint - here is the Exception:

12-20 17:53:20.400: E/Crittercism(3523): java.lang.NullPointerException 12-20 17:53:20.400: E/Crittercism(3523): at com.amazon.geo.maps.MercatorProjection.latLongToWorldPixels(MercatorProjection.java:397) 12-20 17:53:20.400: E/Crittercism(3523): at com.amazon.geo.maps.MercatorProjection.toPixels(MercatorProjection.java:69) 12-20 17:53:20.400: E/Crittercism(3523): at com.amazon.geo.maps.MapView.animateTo_AmazonInternal(MapView.java:1801) 12-20 17:53:20.400: E/Crittercism(3523): at com.amazon.geo.maps.MapController.animateTo(MapController.java:46) 12-20 17:53:20.400: E/Crittercism(3523): at com.fatattitude.myapplication.MyMapActivity.moveMapToPoint(BusMapActivity.java:1564)

Here is my code. My log output also shows that the GeoPoint had values of LatitudeE6= 51537141 and LongitudeE6= -246271

private void moveMapToPoint(GeoPoint gp, int zoomLevel) { MapController mc = mapView.getController(); if (zoomLevel < 0) zoomLevel = mapView.getZoomLevel(); mc.stopAnimation(true); mc.setZoom(zoomLevel); String strGeoPointInfo = String.format("Lat:%d, Lng:%d", gp.getLatitudeE6(), gp.getLongitudeE6() ); Log.i("GeoPoint-Info", "**moveMapToPoint: " + strTestOutput); mc.animateTo(gp); }

If I comment the line

//mc.stopAnimation(true);

I no longer get the exception.

Can anyone help me to understand why this exception has occurred?

Please help me on this.

最满意答案

该应用程序可能会在GPS传感器寻找位置之前等待。

mMyLocationOverlay.runOnFirstFix(new Runnable() { public void run() { mapView.getController().animateTo(myLocation); }});

The app is likely to wait before the GPS Sensor is looking for the location.

mMyLocationOverlay.runOnFirstFix(new Runnable() { public void run() { mapView.getController().animateTo(myLocation); }});

更多推荐

本文发布于:2023-04-27 20:49:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1329015.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:会在   抛出   方法   API   Maps

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!