1. 2015 is going to be a great year for Android! Why wait??
    Samsung Galaxy Note 5 | Samsung Galaxy S6 | HTC One M9
  2. New Forum Created: Samsung Gear VR!

GoogleMap resets and stops responding!?


  1. JamTheMan

    JamTheMan Well-Known Member

    Hi all..

    I am not sure this is the right sub-forum to post in, but here goes.

    I am working on an app that uses a GoogleMap and lots of overlays/markers. Controls and navigation is handled automatically (no direct user interaction with the map needed so far).

    Things work the way I want right until the app pauses and goes into the background. When I resume the app the map has zoomed out to 0:0 and it doesn't react to animateMap or anything anymore. I can't seem to figure how I get it back to the state where it doesn't react to user interaction and actually updates with my markers and stuff..

    Below are the three methods handling the map, and it doesn't seem to react on any of it after a resume. Any hints?

    Code:
    private void setupMap(){
    		getSupportFragmentManager().beginTransaction().replace(R.id.trackeractivity_map, new SupportMapFragment()).commit();
    		FragmentManager fragmentManager = getSupportFragmentManager();
    		SupportMapFragment supportMapFragment = (SupportMapFragment) fragmentManager.findFragmentById(R.id.trackeractivity_map);
    		mMap = supportMapFragment.getMap();
    		mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
    		mMap.setMyLocationEnabled(true);
    		
    		Log.d(TAG, "Max zoom level " + mMap.getMaxZoomLevel());
    	}
    	
    private void updateUserLocation(double lat, double lon){
    		Log.d(TAG, "updateUserLocation - " + lat + " : " + lon);
    		mLastLocationLat = lat;
    		mLastLocationLon = lon;
    		CameraPosition userPos = new CameraPosition(new LatLng(lat, lon), mMap.getMaxZoomLevel()-4, 0, 0);
    		mMap.animateCamera(CameraUpdateFactory.newCameraPosition(userPos));
    	}
    	
    private void updateMapOverlay(double lat, double lon){
    		Log.d(TAG, "updateMapOverlay - " + lat + " : " + lon + " - Type " + mCurrentType);
    		MarkerOptions marker = new MarkerOptions();
    		marker.position(new LatLng(lat, lon));
    		marker.draggable(false);
    		marker.icon(BitmapDescriptorFactory.fromResource(getTypeDrawableID(mCurrentType)));
    		mMap.addMarker(marker);
    	}
    

    Advertisement
    :
  2. JamTheMan

    JamTheMan Well-Known Member

    No one?
Loading...

Share This Page