0

I use below code to add ground ovelay to google map using api 2 from android.

LatLng ne = currentHole.getNe();
    LatLng sw = currentHole.getSw();
    LatLngBounds mOverlayBound = new LatLngBounds(ne,sw);
    BitmapDescriptor mDesc= BitmapDescriptorFactory.
    fromAsset(currentHole.getGroundOverLay()); GroundOverlayOptions mOverlayOp = new GroundOverlayOptions().image(mDesc).positionFromBounds(mOverlayBound).zIndex(2); mOverlayOp.bearing(0);
    gOverLay = googleMap.addGroundOverlay(mOverlayOp);

All input parmeters are valid and it works fine when I load BitMapDescriptor from resource instead of asset and this code was working fine before recently I touched the code for some changes then it started showing error as below.

02-23 10:07:22.982: W/System.err(3538): java.lang.NullPointerException 

02-23 10:07:22.986: W/System.err(3538): at com.google.k.a.cj.a(Unknown 

       Source) 
02-23 10:07:22.986: W/System.err(3538): at 
        com.google.maps.api.android.lib6.c.dc.<init>(Unknown Source) 
02-23 10:07:22.986: W/System.err(3538): at   com.google.maps.api.android.lib6.c.db.a(Unknown Source) 
02-23 10:07:22.986: W/System.err(3538): at com.google.maps.api.android.lib6.c.eu.<init>(Unknown Source) 
02-23 10:07:22.986: W/System.err(3538): at com.google.maps.api.android.lib6.c.el.a(Unknown Source) 
02-23 10:07:22.986: W/System.err(3538): at com.google.android.gms.maps.internal.l.onTransact(SourceFile:182) 
02-23 10:07:22.986: W/System.err(3538): at android.os.Binder.transact(Binder.java:380) 
02-23 10:07:22.986: W/System.err(3538): at com.google.android.gms.maps.internal.IGoogleMapDelegate$a$a.addGroundOverlay(Unknown Source) 
02-23 10:07:22.986: W/System.err(3538): at com.google.android.gms.maps.GoogleMap.addGroundOverlay(Unknown Source) --
Sufian
  • 6,405
  • 16
  • 66
  • 120
1'hafs
  • 559
  • 7
  • 25
  • Do you just need to add a image to your markers in your infoWindow? – bjiang Feb 23 '15 at 17:50
  • The code above is to add ground overlay, it works fine when when I generate BitmapDescriptor from resources instead of asset. – 1'hafs Feb 24 '15 at 05:13

1 Answers1

0

I think the problem is with the line

BitmapDescriptor mDesc= BitmapDescriptorFactory. fromAsset(currentHole.getGroundOverLay());

Which is probably giving you the NullpointerException. Make sure you just pass the String as the image stored in the assests directory of your project. May be the currentHole.getGroundOverLay() is not a valid image in the assests directory and hence it is giving a NullPointer.

AniV
  • 3,997
  • 1
  • 12
  • 17
  • The image path is perfect I checked and confirmed that, and you know it was a working code but suddenly without making any changes it started showing this error. I doubt if there is any change in Google Map API. – 1'hafs Feb 24 '15 at 05:21
  • Yeah there are a lot of changes... But the thing is your logcat doesnt say anything about those. At which line you are getting the Null Pointer? – AniV Feb 24 '15 at 17:39
  • gOverLay = googleMap.addGroundOverlay(mOverlayOp); exactly on this line when I load BitmapDescriptorFactory. fromAsset, the image path and bound is perfect those are not null. – 1'hafs Feb 25 '15 at 04:44