Search code examples
androidgoogle-mapsgoogle-maps-markersmotorola-droid

Custom marker is not drawn on some devices


I wanted to draw a marker on Google map based on some location data I collected. When I tested the code using Galaxy S5 it draws the marker but when I try to do the same thing using a Motorola it fails to draw the marker at times and draws it other times. The object the marker represents is always there even in the Motorola. The Galaxy runs Android 5.1.1 and the Motorola 5.1: the code is as follows.

private MarkerOptions getMarkerForItem(Provider pro, LatLng lctionll, float brng){
        MarkerOptions mo = new MarkerOptions();
        isMarkerAlive = true;
       mo.icon((BitmapDescriptorFactory.fromResource(R.drawable.cuteMarker)))
               .anchor(0.5f, 0.5f) //so marker rotates around the center
               .position(lctionll)
               .rotation(brng)
               .flat(true);
        return mo;
    }

There is similar question in SO but there is no answer regarding the hardware differences and how to deal with these issues. Can someone help?

EDIT---> The Galaxy has Google play services 9.2.56 and the Motorola has 9.4.52


Solution

  • Adding .visible(true) fixed it in the Motorola phone. I will test other devices and update this answer as needed.

    MarkerOptions mo = new MarkerOptions().icon((BitmapDescriptorFactory.fromResource(R.drawable.movingcab)))
                    .anchor(0.5f, 0.5f) //so marker rotates around the center
                    .position(lctionll)
                    .rotation(brng)
                    .visible(true)
                    .flat(true);