question

mrcarlosp avatar image
mrcarlosp asked

Maps API throws NullPointerException on animateTo() method

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); // Debug info String strGeoPointInfo = String.format("Lat:%d, Lng:%d", gp.getLatitudeE6(), gp.getLongitudeE6() ); Log.i("GeoPoint-Info", "**moveMapToPoint: " + strTestOutput); mc.animateTo(gp); } What could be causing this?
amazon maps
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

mrcarlosp avatar image
mrcarlosp answered
Update - if I comment out this line I no longer get the exception: //mc.stopAnimation(true); So it's no longer urgent, but still could be an issue to report?
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sachin@Amazon avatar image
Sachin@Amazon answered
Hi, It looks like the app is likely to wait before the GPS Sensor is looking for the location which means you are trying to get your location before the sensor got it. You should animate to your geoPoint in the runOnFirstFix method mMyLocationOverlay.runOnFirstFix(new Runnable() { public void run() { mapView.getController().animateTo(myLocation); }});
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.