i'm working on a project for indoor navigation and need to add a groundOverlay with the floorplan of the building. I've followed the guidelines on the Documentation from Google dev site. But its giving me NullPointerException when i try to add the overlay to the map. Heres my code:
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
mMap.setIndoorEnabled(true);
mMap.setOnIndoorStateChangeListener(this);
mMap.setPadding(0,0,50,0);
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(-28.666957, -55.994823), 19));
//add mapOverlay
LatLngBounds iffBounds = new LatLngBounds(
new LatLng(-28.667177,-55.995104),
new LatLng(-28.667061,-55.994443)
);
GroundOverlayOptions iffMap = new GroundOverlayOptions()
.image(BitmapDescriptorFactory.fromResource(R.raw.piso_1))
.positionFromBounds(iffBounds);
mapOverlay = mMap.addGroundOverlay(iffMap);
}
I have tried debbuging the code and i can't see anything wrong, everything is being correctly instantiated, but when it executes the last line
mapOverlay = mMap.addGroundOverlay(iffmap);
My app crashes.
Here's the StackTrace from logCat:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: br.com.imerljak.vegvisir, PID: 2390
java.lang.NullPointerException: null reference
at maps.w.c.a(Unknown Source)
at maps.ad.g$a.<init>(Unknown Source)
at maps.ad.g.a(Unknown Source)
at maps.ad.w.<init>(Unknown Source)
at maps.ad.u.a(Unknown Source)
at vo.onTransact(:com.google.android.gms.DynamiteModulesB:182)
at android.os.Binder.transact(Binder.java:380)
at com.google.android.gms.maps.internal.IGoogleMapDelegate$zza$zza.addGroundOverlay(Unknown Source)
at com.google.android.gms.maps.GoogleMap.addGroundOverlay(Unknown Source)
at br.com.imerljak.vegvisir.MapsActivity.onMapReady(MapsActivity.java:62)
at com.google.android.gms.maps.SupportMapFragment$zza$1.zza(Unknown Source)
at com.google.android.gms.maps.internal.zzt$zza.onTransact(Unknown Source)
at android.os.Binder.transact(Binder.java:380)
at xz.a(:com.google.android.gms.DynamiteModulesB:82)
at maps.ad.u$5.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5312)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696)
PS: if anyone has any tips that will help me developing this app (like a good API for indoor navigation) i will be grateful :)