Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • google map lite mode in mapview is not working with marshmallow

    • 1
    • 0
    • 0
    • 1
    • 0
    • 0
    • 0
    • 323
    Answer it

    => I'm using following MapView in my layout:-

        ------------------------------------------------------------

    <com.google.android.gms.maps.MapView
        android:id="@+id/map"
        class="com.google.android.gms.maps.MapFragment"
        android:layout_width="match_parent"
        android:layout_height="190dp"
        android:layout_gravity="bottom"
        android:layout_marginTop="5dp"
        android:layout_marginBottom="10dp"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_below="@+id/ivLocation"
        android:padding="1dp"
        android:background="#D3D3D3"
        map:liteMode="true"
      />

    => I have the following code in onCreateView() of fragment:-

    ---------------------------------------------------------------------------------------

    MapsInitializer.initialize(this.getActivity());
    mapView = (MapView) view.findViewById(R.id.map);
    mapView.onCreate(savedInstanceState);
    mapView.getMapAsync(this);
    mapView.setClickable(false);
    

     

    => And i also have the following code in the fragment class :-

    ----------------------------------------------------------------------------------------

    @Override
    public void onPause() {
        super.onPause();
        mapView.onPause();
    }
    
    @Override
    public void onDestroy() {
        super.onDestroy();
        mapView.onDestroy();
    }
    
    @Override
    public void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        mapView.onSaveInstanceState(outState);
    }
    
    @Override
    public void onLowMemory() {
        super.onLowMemory();
        mapView.onLowMemory();
    }
    
    @Override
    public void onResume() {
        super.onResume();
        mapView.onResume();
    }
    
    @Override
    public void onDestroyView() {
        super.onDestroyView();
    }
    
    @Override
    public void onMapReady(GoogleMap googleMap) {
        map = googleMap;
        if (ActivityCompat.checkSelfPermission(getContext(), android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(getContext(), android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
            // TODO: Consider calling
            //    ActivityCompat#requestPermissions
            // here to request the missing permissions, and then overriding
            //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
            //                                          int[] grantResults)
            // to handle the case where the user grants the permission. See the documentation
            // for ActivityCompat#requestPermissions for more details.
            return;
        }
        map.setMapType(GoogleMap.MAP_TYPE_NORMAL);
        LocationManager locationManager = (LocationManager) getContext().getSystemService(Context.LOCATION_SERVICE);
        Location lastLocation = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
        LatLng latLng = new LatLng(lastLocation.getLatitude(), lastLocation.getLongitude());
        googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 16));
        map.addMarker(new MarkerOptions().position(latLng).title("City Coordinator location at login").icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_YELLOW)));
        map.getUiSettings().setMapToolbarEnabled(false);
    }

     

    This code is working in moto e2 phone with lollipop android, but not working in moto g3 phone with marshmallow android. In marshmallow, map is not loading at all in googlemap lite mode. If i remove this attribute( map:liteMode="true") in mapview, map is loading but marker is not present.

 1 Answer(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: